wow we had bad inference code
Browse files
README.md
CHANGED
@@ -43,21 +43,27 @@ messages = [
|
|
43 |
]
|
44 |
|
45 |
# Generate reasoning
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
|
|
|
|
|
|
50 |
|
51 |
-
print("REASONING: " +
|
52 |
|
53 |
# Generate answer
|
54 |
messages.append({"role": "reasoning", "content": reasoning_output})
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
|
|
|
|
|
|
59 |
|
60 |
-
print("
|
61 |
```
|
62 |
|
63 |
- **Trained by:** [Piotr Zalewski](https://huggingface.co/lunahr)
|
|
|
43 |
]
|
44 |
|
45 |
# Generate reasoning
|
46 |
+
input_ids = tokenizer.apply_chat_template(messages, tokenize=False, add_reasoning_prompt=True, return_tensors="pt")
|
47 |
+
output = model.generate(
|
48 |
+
input_ids.to("cuda"),
|
49 |
+
eos_token_id=tokenizer.eos_token_id,
|
50 |
+
max_new_tokens=MAX_REASONING_TOKENS,
|
51 |
+
do_sample=False,
|
52 |
+
)
|
53 |
|
54 |
+
print("REASONING: " + tokenizer.decode(output[0]))
|
55 |
|
56 |
# Generate answer
|
57 |
messages.append({"role": "reasoning", "content": reasoning_output})
|
58 |
+
input_ids = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True, return_tensors="pt")
|
59 |
+
output = model.generate(
|
60 |
+
input_ids.to("cuda"),
|
61 |
+
eos_token_id=tokenizer.eos_token_id,
|
62 |
+
max_new_tokens=MAX_RESPONSE_TOKENS,
|
63 |
+
do_sample=False,
|
64 |
+
)
|
65 |
|
66 |
+
print("REASONING: " + tokenizer.decode(output[0]))
|
67 |
```
|
68 |
|
69 |
- **Trained by:** [Piotr Zalewski](https://huggingface.co/lunahr)
|