File size: 2,563 Bytes
e540d3b
 
dde3195
 
 
 
 
 
 
 
 
e540d3b
 
 
 
950df8f
e540d3b
59e591b
e540d3b
59e591b
0c39784
 
 
 
4801eb9
 
 
 
 
0c39784
 
59e591b
ec402d0
4801eb9
 
 
 
 
 
 
 
59e591b
 
 
 
 
 
 
 
 
ec402d0
 
59e591b
ec402d0
59e591b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ec402d0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
---
library_name: transformers
tags:
- grpo
- trl
datasets:
- openai/gsm8k
metrics:
- accuracy
base_model:
- google/gemma-2-2b-it
---

# Model Card for Model ID

This model is a fine-tuned version of [Google/gemma-2-2b-it](https://huggingface.co/google/gemma-2-2b-it) on the dataset [GSM8k](https://huggingface.co/datasets/openai/gsm8k). It has been trained using GRPOTrainer from TRL.

## Quick start

```python
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline

tokenizer_name = "Google/gemma-2-2b-it"
model_name="lmassaron/gemma-2-2b-it-grpo-gsm8k"
tokenizer = AutoTokenizer.from_pretrained(tokenizer_name,
                                          trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(model_name,
                                             device_map="auto",
                                             use_cache=True)

FORMAT = """<reasoning>\n</reasoning>\n<answer>\n</answer>\n"""

question = "Which is bigger? 9.11 or 9.9?"
generator = pipeline("text-generation",
                      model=model,
                      tokenizer=tokenizer,
                      do_sample=False,
                      batch_size=1)
output = generator([{"role": "user", "content": FORMAT + question}],
                    max_new_tokens=256,
                    return_full_text=False)[0]
print(output["generated_text"])
```

## Training procedure

This model was trained with GRPO, a method introduced in [DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models](https://huggingface.co/papers/2402.03300).

### Framework versions

- TRL: 0.15.1
- Transformers: 4.49.0
- Pytorch: 2.5.1+cu124
- Datasets: 3.3.1
- Tokenizers: 0.21.0

## Citations

Cite GRPO as:

```bibtex
@article{zhihong2024deepseekmath,
    title        = {{DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models}},
    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},
    year         = 2024,
    eprint       = {arXiv:2402.03300},
}

```

Cite TRL as:
    
```bibtex
@misc{vonwerra2022trl,
	title        = {{TRL: Transformer Reinforcement Learning}},
	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},
	year         = 2020,
	journal      = {GitHub repository},
	publisher    = {GitHub},
	howpublished = {\url{https://github.com/huggingface/trl}}
}
```