Views
No views yet
1# L denotes the noise length hyperparameter, which is typically set to 5.
2dataset = [
3 {"source_ids": "Query prompt.",
4 "input_ids": "Concatenation of the query and response.",
5 "output_ids": "Copy of input_ids as label for LM task."}
6]
7for source_ids, input_ids in dataset:
8 start_idx = random.randrange(len(source_ids), len(input_ids)-L)
9 for mask_i in range(start_idx, start_idx+L):
10 # Noise is added only to the input portion corresponding to the response.
11 input_ids[mask_i] = random.choice(input_ids[:mask_i])
12
src/inference_msn.py.1# jacobi decoding
2spec_res_ids, new_tokens, forward_steps, accpet_list = noise_forward(input_ids.cuda(), model, tokenizer, args.max_new_tokens)
3
4print("msn output")
5print(tokenizer.decode(spec_res_ids[0]))
6print("#MTA")
7print(new_tokens/forward_steps)
8print("Accepted Length List")
9print(accpet_list)
10
11# msn output
12# <|begin_of_text|><|start_header_id|>system<|end_header_id|>
13# Give me some advices about how to write an academic paper?<|eot_id|><|start_header_id|>assistant<|end_header_id|>
14# 1. Start by researching your topic and gathering relevant information. Make sure to take notes and organize your research in a way that makes sense.
15# ...
16# 8. Submit your paper. Make sure to follow any submission guidelines and make sure to submit your paper on time.<|eot_id|><|eot_id|>.
17
18# #MTA
19# 2.2
20
21# Accepted Length List
22# [1, 2, 1, 1, 3, 1, 2, 2, 3, 1, 2, 2, 2, 2, 2, 1, 3, 1, 3, 1, 2, 1, 3, 2, 2, 2, 1, 2, 1, 2, 3, 2, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 1, 5, 1, 3, 1, 5, 2, 1, 3, 2, 2, 2, 3, 2, 5, 1, 3, 2, 3, 2, 3, 2, 1, 4, 3, 1, 2, 2, 3, 6, 1, 2, 2, 2, 3, 2, 2, 3, 3, 2, 3, 2, 2, 2, 1, 2, 2, 2, 3, 3, 3, 1, 4, 2, 1, 2, 2, 2]sh run_case.sh to obtain the execution process of a test sample.
The interface design of the entire noise_forward is kept consistent with Spec-Bench.@inproceedings{wang-etal-2024-make,
title = "Make Some Noise: Unlocking Language Model Parallel Inference Capability through Noisy Training",
author = "Wang, Yixuan and
Luo, Xianzhen and
Wei, Fuxuan and
Liu, Yijun and
Zhu, Qingfu and
Zhang, Xuanyu and
Yang, Qing and
Xu, Dongliang and
Che, Wanxiang",
editor = "Al-Onaizan, Yaser and
Bansal, Mohit and
Chen, Yun-Nung",
booktitle = "Proceedings of the 2024 Conference on Empirical Methods in Natural Language Processing",
month = nov,
year = "2024",
address = "Miami, Florida, USA",
publisher = "Association for Computational Linguistics",
url = "https://aclanthology.org/2024.emnlp-main.718/",
doi = "10.18653/v1/2024.emnlp-main.718",
pages = "12914--12926",
}