Views
No views yet
qwen-2.5-3b-r1-countdown a mini R1 experiments1from vllm import LLM, SamplingParams
2from datasets import load_dataset
3from random import randint
4
5sampling_params = SamplingParams(temperature=0.8, top_p=0.95, max_tokens=512)
6
7# use revision without "checkpoints-" as vLLM downloads all of them
8llm = LLM(model="philschmid/qwen-2.5-3b-r1-countdown", revision="099c0f8cbfc522e7c3a476edfb749f576b164539")
9
10# Load dataset from Hugging Face Hub
11dataset_id = "Jiayi-Pan/Countdown-Tasks-3to4"
12dataset = load_dataset(dataset_id, split="train")
13sample = dataset[randint(0, len(dataset))]
14
15# create conversation
16messages = [
17 {"role": "system", "content": "You are a helpful assistant. You first thinks about the reasoning process in the mind and then provides the user with the answer."},
18 {"role": "user", "content": f"Using the numbers {sample['nums']}, create an equation that equals {sample['target']}. You can use basic arithmetic operations (+, -, *, /) one or multiple times but each number can only be used once. Show your work in <think> </think> tags. And return the final equation in <answer> </answer> tags, for example <answer> (1 + 2) / 3 </answer>. Think step by step inside <think> tags."},
19 {"role": "assistant", "content": "Let me solve this step by step.\n<think>"}
20]
21# generate response
22res = llm.generate(llm.get_tokenizer().apply_chat_template(messages, tokenize=False, continue_final_message=True), sampling_params)
23res = "<think>" + res[0].outputs[0].text
24print(res)
25
26# <think> We need to use the numbers 37, 15, 4, and 13 with basic arithmetic operations to make 16. Let's try different combinations:
27# - 37 - 15 - 4 - 13 = 6 (too low)
28# - 37 - 15 + 4 - 13 = 13 (too low)
29# - 37 + 15 - 4 - 13 = 35 (too high)
30# - 37 - 15 + 4 + 13 = 39 (too high)
31# - 15 + 4 + 13 - 37 = -1 (too low)
32# - 37 + 15 + 4 - 13 = 43 (too high)
33# - 15 + 4 * 13 / 37 = 15 + 52 / 37 (not an integer)
34# - 15 * 4 / 37 - 37 = -28.24 (not a whole number)
35# - 4 * 13 / 15 - 37 = 41.3333 (not a whole number)
36# After all combinations, I got not any integer result as 16.
37# </think>
38# <answer> 37 - 15 + 4 + 13 </answer>