Views
No views yet

1import transformers
2
3messages = [
4 {'content': 'A conversation between User and Assistant. The user asks a question, and the Assistant solves it. The assistant first thinks and then provides the user with the answer. You begin you answer with the reasoning process and answer enclosed within <think> </think> and <answer> </answer> tags, respectively, i.e., <think> reasoning process here </think><answer>\\boxed{letter}</answer>. Your reasoning process should be detailed and should include all the steps you took to arrive at the answer. The answer should be based on the reasoning process and should be only the answer letter.',
5 'role': 'system'},
6 {'content': 'What happens to the equilibrium constant when the concentration of a reactant is increased in a reversible reaction?A: The equilibrium constant will fluctuate until a new equilibrium is reached.\nB: The equilibrium constant will increase.\nC: The equilibrium constant will decrease.\nD: The equilibrium constant will not change.',
7 'role': 'user'}
8]
9
10model_name = "PhilSad/Lucie-7B-GRPO-Science-500"
11model = transformers.AutoModelForCausalLM.from_pretrained(
12 model_lora_path,
13 device_map="auto",
14)
15tokenizer = transformers.AutoTokenizer.from_pretrained("OpenLLM-France/Lucie-7B-Instruct-v1.1")
16
17
18pipeline_base = transformers.pipeline(
19 "text-generation",
20 model=model,
21 tokenizer=tokenizer,
22 max_length=512,
23 device_map="cuda",
24 temperature=0.1,
25 top_p=0.95,
26 top_k=50,
27)
28
29with torch.no_grad():
30 out = pipeline(exemple["prompt"])
31
32print(out[0]["generated_text"][-1]["content"]
33
34# > <think> When the concentration of a reactant is increased in a reversible reaction, the system will shift towards the products to re-establish equilibrium. This shift will cause the equilibrium constant to decrease, as the reaction will favor the formation of more products. </think><answer>\boxed{D}</answer>
35