Views
No views yet
google/gemma-3-1b-it is a compact student model and a good fit for distillation. We trained it to solve Countdown-style arithmetic tasks: given a set of numbers and basic operators (+, -, *, /), the model must create an equation that reaches a target value. Example:[75, 80, 90, 24]6190 - 80 + 75 - 24 = 61Qwen3-4B-Instruct-2507, from the Countdown dataset and learns to produce the final equation in <answer> format.target, nums, and messages. The final maximum sequence length is 1024 and the split is 95/5:20,216 samples1,064 samples
10244812e-40.1adamw_torch16320.05

1,064 examples. The validation accuracy is:0.1310 (131/1000)0.8412 (895/1064)1import torch
2from transformers import AutoTokenizer, AutoModelForCausalLM
3from peft import PeftModel
4
5base_model_id = "google/gemma-3-1b-it"
6adapter_id = "pymlex/gemma3-1b-countdown"
7
8tokenizer = AutoTokenizer.from_pretrained(base_model_id, trust_remote_code=True)
9if tokenizer.pad_token is None:
10 tokenizer.pad_token = tokenizer.eos_token
11tokenizer.padding_side = "left"
12
13base_model = AutoModelForCausalLM.from_pretrained(
14 base_model_id,
15 device_map="auto",
16 torch_dtype=torch.bfloat16 if torch.cuda.is_available() and torch.cuda.is_bf16_supported() else torch.float16,
17 trust_remote_code=True,
18)
19
20model = PeftModel.from_pretrained(base_model, adapter_id)
21model.eval()1def generate_continuation(model, tokenizer, prompt, max_new_tokens=850):
2 inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
3 prompt_len = inputs.input_ids.shape[1]
4
5 outputs = model.generate(
6 **inputs,
7 max_new_tokens=max_new_tokens,
8 temperature=0.7,
9 top_p=0.95,
10 do_sample=True,
11 repetition_penalty=1.05,
12 eos_token_id=tokenizer.eos_token_id,
13 pad_token_id=tokenizer.pad_token_id,
14 )
15
16 decoded = tokenizer.decode(outputs[0][prompt_len:], skip_special_tokens=True)
17 return decoded.strip()
18
19
20sample_prompt = (
21 "Using the numbers [78, 46, 93], create an equation that equals 61. "
22 "You can use basic arithmetic operations (+, -, *, /) and each number can only be used once."
23)
24
25output = generate_continuation(model, tokenizer, sample_prompt, max_new_tokens=850)
26print("Prompt:")
27print(sample_prompt)
28print("\nGenerated continuation:")
29print(output)