Views
No views yet
1from transformers import AutoModelForCausalLM, AutoTokenizer
2
3model_name = "jiangchengchengNLP/qwen-test-ppo"
4
5model = AutoModelForCausalLM.from_pretrained(
6 model_name,
7 torch_dtype="auto",
8 device_map="auto"
9)
10tokenizer = AutoTokenizer.from_pretrained(model_name)
11
12prompt = "How many integers $n>1$ are there such that $n$ divides $x^{13}-x$ for every positive integer $x$ ? Show your work in <think> </think> tags. And return the final answer in <answer> </answer> tags."
13messages = [
14 {"role": "system", "content": "You are Qwen, created by Alibaba Cloud. You are a helpful assistant."},
15 {"role": "user", "content": prompt}
16]
17text = tokenizer.apply_chat_template(
18 messages,
19 tokenize=False,
20 add_generation_prompt=True
21)
22model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
23
24generated_ids = model.generate(
25 **model_inputs,
26 max_new_tokens=1024,
27 temperature=0.2
28)
29generated_ids = [
30 output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
31]
32
33response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]Open resoner zero, and find hardship samples from them, to create a 9K train data.But, train this model after 620 step, I find the model's solving ability betbeen countdown and other category of promblem is much confict. It make model can't find a best solution to solve those problem.