Views
No views yet
Plan an in depth tour itinerary of France that includes Paris, Lyon, and Provence.
Describe a classic road trip itinerary along the California coastline in the United States.
Create a holiday plan that combines cultural experiences in Bangkok, Thailand, with beach relaxation in Phuket.
apply_chat_template to show you how to load the tokenizer and model and how to generate contents.1from transformers import AutoModelForCausalLM, AutoTokenizer
2device = "cuda" # the device to load the model onto
3
4model = AutoModelForCausalLM.from_pretrained(
5 "alibaba-pai/Qwen2-1.5B-Instruct-Exp",
6 torch_dtype="auto",
7 device_map="auto"
8)
9tokenizer = AutoTokenizer.from_pretrained("alibaba-pai/Qwen2-1.5B-Instruct-Exp")
10
11prompt = "Give me a short introduction to large language model."
12messages = [
13 {"role": "user", "content": prompt}
14]
15text = tokenizer.apply_chat_template(
16 messages,
17 tokenize=False,
18 add_generation_prompt=True
19)
20model_inputs = tokenizer([text], return_tensors="pt").to(device)
21
22generated_ids = model.generate(
23 model_inputs.input_ids,
24 max_new_tokens=2048,
25 eos_token_id=151645,
26)
27generated_ids = [
28 output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
29]
30
31response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]| Model | Math | Impl. |
|---|---|---|
| Qwen2-1.5B-Instruct | 57.90% | 28.96% |
| + Qwen2-1.5B-Instruct-Exp | 59.15% | 31.22% |
| + Qwen2-7B-Instruct-Exp | 58.32% | 39.37% |
| Qwen2-7B-Instruct | 71.40% | 28.85% |
| + Qwen2-1.5B-Instruct-Exp | 73.90% | 35.41% |
| + Qwen2-7B-Instruct-Exp | 72.53% | 32.92% |
@misc{data-augmentation-family,
title={Building a Family of Data Augmentation Models for Low-cost LLM Fine-tuning on the Cloud},
author={Yuanhao Yue and Chengyu Wang and Jun Huang and Peng Wang},
year={2024},
eprint={2412.04871},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2412.04871},
}