Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: cc-by-nc-4.0
|
3 |
+
language:
|
4 |
+
- en
|
5 |
+
base_model:
|
6 |
+
- Qwen/Qwen2.5-3B-Instruct
|
7 |
+
pipeline_tag: text-generation
|
8 |
+
tags:
|
9 |
+
- finance
|
10 |
+
---
|
11 |
+
|
12 |
+
This is a toy model using CoT-sft with GRPO.
|
13 |
+
|
14 |
+
## Usage
|
15 |
+
|
16 |
+
```
|
17 |
+
tokenizer = AutoTokenizer.from_pretrained("yixuantt/Qwen2.5-3B-R1-Finance")
|
18 |
+
|
19 |
+
model = AutoModelForCausalLM.from_pretrained("yixuantt/Qwen2.5-3B-R1-Finance",
|
20 |
+
torch_dtype = torch.bfloat16,
|
21 |
+
device_map = "auto"
|
22 |
+
)
|
23 |
+
model.eval()
|
24 |
+
|
25 |
+
print(model)
|
26 |
+
def generate(text):
|
27 |
+
conv = [{"role": "system",
|
28 |
+
"content": "You are a helpful AI Assistant that provides well-reasoned and detailed responses. You first think about the reasoning process as an internal monologue and then provide the user with the answer."},{"role": "user", "content": text}]
|
29 |
+
prompt = tokenizer.apply_chat_template(conversation=conv, tokenize=False, add_generation_prompt=True)
|
30 |
+
encoded = tokenizer(prompt, return_tensors="pt")
|
31 |
+
generate_params = dict(
|
32 |
+
max_new_tokens=1024,
|
33 |
+
do_sample=True,
|
34 |
+
top_k=20,
|
35 |
+
)
|
36 |
+
with torch.no_grad():
|
37 |
+
generation_output = model.generate(input_ids=encoded.input_ids.cuda(),
|
38 |
+
attention_mask=encoded.attention_mask.cuda(),
|
39 |
+
tokenizer=tokenizer,
|
40 |
+
**generate_params)
|
41 |
+
|
42 |
+
generation_output = generation_output[:, encoded.input_ids.shape[1]:]
|
43 |
+
out = tokenizer.decode(generation_output[0], skip_special_tokens=True)
|
44 |
+
# print(out)
|
45 |
+
return out
|
46 |
+
```
|