Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,89 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: mit
|
| 3 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
---
|
| 4 |
+
---
|
| 5 |
+
base_model: Qwen/Qwen2.5-3B-Instruct
|
| 6 |
+
library_name: transformers
|
| 7 |
+
tags:
|
| 8 |
+
- math
|
| 9 |
+
- reasoning
|
| 10 |
+
- qwen
|
| 11 |
+
- fine-tuned
|
| 12 |
+
- loRA
|
| 13 |
+
datasets:
|
| 14 |
+
- nvidia/OpenMathInstruct-2
|
| 15 |
+
pipeline_tag: text-generation
|
| 16 |
+
---
|
| 17 |
+
|
| 18 |
+
# Emo-v1
|
| 19 |
+
|
| 20 |
+
<div align="center">
|
| 21 |
+
|
| 22 |
+

|
| 23 |
+

|
| 24 |
+

|
| 25 |
+
|
| 26 |
+
**A lightweight 3B parameter model fine-tuned to "Think like O1".**
|
| 27 |
+
*Specialized in Algebra, Logic Puzzles, and Step-by-Step Reasoning.*
|
| 28 |
+
|
| 29 |
+
</div>
|
| 30 |
+
|
| 31 |
+
## 📖 Model Description
|
| 32 |
+
|
| 33 |
+
**Emo-Qwen2.5-3B** is a fine-tuned version of [Qwen/Qwen2.5-3B-Instruct](https://huggingface.co/Qwen/Qwen2.5-3B-Instruct), optimized for mathematical reasoning and logic.
|
| 34 |
+
|
| 35 |
+
Unlike standard chat models that often guess answers, Emo-Qwen is trained to **decompose problems into explicit steps** before providing a final solution. It mimics the "Chain of Thought" (CoT) process found in larger reasoning models (like OpenAI's o1), making it surprisingly capable for its small size.
|
| 36 |
+
|
| 37 |
+
### 🚀 Key Features
|
| 38 |
+
* **Step-by-Step Reasoning:** Forces a "Let's break this down" approach to minimize logic errors.
|
| 39 |
+
* **Math Specialist:** Trained on the `nvidia/OpenMathInstruct-2` dataset, covering algebra, calculus, and probability.
|
| 40 |
+
* **LaTeX Support:** Optimized to output mathematical formulas in clean LaTeX format (e.g., $x^2 + y^2$).
|
| 41 |
+
* **Efficient:** At only 3 Billion parameters, it runs on consumer hardware (even free Kaggle/Colab T4 GPUs) with low latency.
|
| 42 |
+
|
| 43 |
+
## 💻 How to Use
|
| 44 |
+
|
| 45 |
+
### System Prompt (Crucial)
|
| 46 |
+
To trigger the reasoning capability, you **must** use the specific system prompt below:
|
| 47 |
+
|
| 48 |
+
> **"You are a helpful math assistant. Think step by step. IMPORTANT: Use LaTeX formatting for all math."**
|
| 49 |
+
|
| 50 |
+
### Python Inference Code
|
| 51 |
+
|
| 52 |
+
```python
|
| 53 |
+
import torch
|
| 54 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 55 |
+
|
| 56 |
+
# 1. Load Model
|
| 57 |
+
model_id = "PrimeTJ/Emo-Qwen2.5-3B-Full"
|
| 58 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 59 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 60 |
+
model_id,
|
| 61 |
+
torch_dtype=torch.float16,
|
| 62 |
+
device_map="auto"
|
| 63 |
+
)
|
| 64 |
+
|
| 65 |
+
# 2. Define the Prompt
|
| 66 |
+
system_prompt = "You are a helpful math assistant. Think step by step."
|
| 67 |
+
user_prompt = "A bat and a ball cost $1.10 in total. The bat costs $1.00 more than the ball. How much does the ball cost?"
|
| 68 |
+
|
| 69 |
+
messages = [
|
| 70 |
+
{"role": "system", "content": system_prompt},
|
| 71 |
+
{"role": "user", "content": user_prompt}
|
| 72 |
+
]
|
| 73 |
+
|
| 74 |
+
# 3. Generate
|
| 75 |
+
text = tokenizer.apply_chat_template(
|
| 76 |
+
messages,
|
| 77 |
+
tokenize=False,
|
| 78 |
+
add_generation_prompt=True
|
| 79 |
+
)
|
| 80 |
+
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
|
| 81 |
+
|
| 82 |
+
generated_ids = model.generate(
|
| 83 |
+
**model_inputs,
|
| 84 |
+
max_new_tokens=1024,
|
| 85 |
+
temperature=0.6 # Low temperature for logic
|
| 86 |
+
)
|
| 87 |
+
|
| 88 |
+
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
| 89 |
+
print(response)
|