Update README.md
Browse files
README.md
CHANGED
|
@@ -1,9 +1,8 @@
|
|
| 1 |
---
|
| 2 |
-
base_model:
|
| 3 |
tags:
|
| 4 |
- text-generation-inference
|
| 5 |
- transformers
|
| 6 |
-
- unsloth
|
| 7 |
- qwen2
|
| 8 |
- trl
|
| 9 |
- sft
|
|
@@ -11,13 +10,56 @@ license: apache-2.0
|
|
| 11 |
language:
|
| 12 |
- en
|
| 13 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
-
|
|
|
|
| 16 |
|
| 17 |
-
|
| 18 |
-
- **License:** apache-2.0
|
| 19 |
-
- **Finetuned from model :** unsloth/qwen2.5-7b-instruct-bnb-4bit
|
| 20 |
|
| 21 |
-
|
|
|
|
| 22 |
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
base_model: Qwen/Qwen2.5-7B-Instruct
|
| 3 |
tags:
|
| 4 |
- text-generation-inference
|
| 5 |
- transformers
|
|
|
|
| 6 |
- qwen2
|
| 7 |
- trl
|
| 8 |
- sft
|
|
|
|
| 10 |
language:
|
| 11 |
- en
|
| 12 |
---
|
| 13 |
+
### Model detail
|
| 14 |
+
Reasoning natural and smarter
|
| 15 |
+
No system prompt training
|
| 16 |
+
LoRA training rank 16 and alpha 16
|
| 17 |
+
Tool calling support
|
| 18 |
+
### Usage:
|
| 19 |
+
```
|
| 20 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 21 |
+
import torch
|
| 22 |
|
| 23 |
+
MAX_REASONING_TOKENS = 4096
|
| 24 |
+
MAX_RESPONSE_TOKENS = 1024
|
| 25 |
|
| 26 |
+
model_name = "beyoru/ThinkAgain1.4"
|
|
|
|
|
|
|
| 27 |
|
| 28 |
+
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.float16, device_map="auto")
|
| 29 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 30 |
|
| 31 |
+
messages = []
|
| 32 |
+
|
| 33 |
+
def stream_output(output_text):
|
| 34 |
+
for char in output_text:
|
| 35 |
+
print(char, end="", flush=True)
|
| 36 |
+
|
| 37 |
+
while True:
|
| 38 |
+
prompt = input("USER: ")
|
| 39 |
+
|
| 40 |
+
messages.append({"role": "user", "content": prompt})
|
| 41 |
+
|
| 42 |
+
# Generate reasoning
|
| 43 |
+
reasoning_template = tokenizer.apply_chat_template(messages, tokenize=False, add_reasoning_prompt=True)
|
| 44 |
+
reasoning_inputs = tokenizer(reasoning_template, return_tensors="pt").to(model.device)
|
| 45 |
+
reasoning_ids = model.generate(**reasoning_inputs, max_new_tokens=MAX_REASONING_TOKENS)
|
| 46 |
+
reasoning_output = tokenizer.decode(reasoning_ids[0, reasoning_inputs.input_ids.shape[1]:], skip_special_tokens=True)
|
| 47 |
+
|
| 48 |
+
messages.append({"role": "reasoning", "content": reasoning_output})
|
| 49 |
+
|
| 50 |
+
print("REASONING: ", end="")
|
| 51 |
+
stream_output(reasoning_output)
|
| 52 |
+
print()
|
| 53 |
+
|
| 54 |
+
# Generate answer
|
| 55 |
+
response_template = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
| 56 |
+
response_inputs = tokenizer(response_template, return_tensors="pt").to(model.device)
|
| 57 |
+
response_ids = model.generate(**response_inputs, max_new_tokens=MAX_RESPONSE_TOKENS)
|
| 58 |
+
response_output = tokenizer.decode(response_ids[0, response_inputs.input_ids.shape[1]:], skip_special_tokens=True)
|
| 59 |
+
|
| 60 |
+
messages.append({"role": "assistant", "content": response_output})
|
| 61 |
+
|
| 62 |
+
print("ASSISTANT: ", end="")
|
| 63 |
+
stream_output(response_output)
|
| 64 |
+
print()
|
| 65 |
+
```
|