Views
No views yet
1from transformers import AutoTokenizer, AutoModelForCausalLM
2import torch
3
4model_name = "tergel/gemma-2-2b-it-math-fs-gpt4o-bon"
5device = "cuda" if torch.cuda.is_available() else "cpu"
6
7tokenizer = AutoTokenizer.from_pretrained(model_name)
8model = AutoModelForCausalLM.from_pretrained(model_name, device_map=device, torch_dtype=torch.bfloat16)
9
10question = "If $f(x) = \\frac{3x-2}{x-2}$, what is the value of $f(-2) +f(-1)+f(0)$? Express your answer as a common fraction"
11
12inputs = tokenizer(question, return_tensors="pt").to(device)
13input_length = len(inputs['input_ids'][0])
14
15outputs = model.generate(**inputs, max_new_tokens=512)
16
17response = tokenizer.decode(outputs[0][input_length:], skip_special_tokens=True)
18print(response)@article{munkhbat2025self,
title={Self-Training Elicits Concise Reasoning in Large Language Models},
author={Munkhbat, Tergel and Ho, Namgyu and Kim, Seohyun and Yang, Yongjin and Kim, Yujin and Yun, Se-Young},
journal={arXiv preprint arXiv:2502.20122},
year={2025}
}