Views
No views yet
1from unsloth import FastLanguageModel
2from vllm import SamplingParams
3import torch
4
5# Load the Model & Tokenizer
6model, tokenizer = FastLanguageModel.from_pretrained(
7 model_name = "AdamLucek/Qwen2.5-3B-Instruct-GRPO-2K-GSM8K",
8 max_seq_length = 2048,
9 load_in_4bit = True,
10 fast_inference = True,
11 gpu_memory_utilization = 0.7,
12)
13
14# Prep the Message
15PROMPT = "How many r's are in the word strawberry?"
16
17SYSTEM_PROMPT = """
18A conversation between User and Assistant. The user asks a question,
19and the Assistant solves it. The assistant first thinks about the
20reasoning process in the mind and then provides the user with the answer.
21Respond in the following format:
22<reasoning>
23...
24</reasoning>
25<answer>
26...
27</answer>
28"""
29
30text = tokenizer.apply_chat_template([
31 {"role" : "system", "content" : SYSTEM_PROMPT},
32 {"role" : "user", "content" : PROMPT},
33], tokenize = False, add_generation_prompt = True)
34
35# Generate a response
36sampling_params = SamplingParams(
37 temperature = 0.8,
38 top_p = 0.95,
39 max_tokens = 1024,
40)
41output = model.fast_generate(
42 text,
43 sampling_params = sampling_params,
44)[0].outputs[0].text1@article{zhihong2024deepseekmath,
2 title = {{DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models}},
3 author = {Zhihong Shao and Peiyi Wang and Qihao Zhu and Runxin Xu and Junxiao Song and Mingchuan Zhang and Y. K. Li and Y. Wu and Daya Guo},
4 year = 2024,
5 eprint = {arXiv:2402.03300},
6}
71@misc{vonwerra2022trl,
2 title = {{TRL: Transformer Reinforcement Learning}},
3 author = {Leandro von Werra and Younes Belkada and Lewis Tunstall and Edward Beeching and Tristan Thrush and Nathan Lambert and Shengyi Huang and Kashif Rasul and Quentin Gallouédec},
4 year = 2020,
5 journal = {GitHub repository},
6 publisher = {GitHub},
7 howpublished = {\url{https://github.com/huggingface/trl}}
8}