VietnamAIHub
commited on
Update README.md
Browse files
README.md
CHANGED
@@ -1,63 +1,8 @@
|
|
1 |
# VietCoMath Model Usage
|
2 |
|
3 |
## Overview
|
4 |
-
This
|
5 |
|
6 |
-
## Installation
|
7 |
-
|
8 |
-
### Prerequisites
|
9 |
-
- Python 3.8+
|
10 |
-
- PyTorch
|
11 |
-
- Transformers library
|
12 |
-
|
13 |
-
### Required Dependencies
|
14 |
-
```bash
|
15 |
-
pip install transformers torch
|
16 |
-
```
|
17 |
-
|
18 |
-
## Usage
|
19 |
-
|
20 |
-
### Basic Text Generation
|
21 |
-
```python
|
22 |
-
import transformers
|
23 |
-
import torch
|
24 |
-
|
25 |
-
# Load the model
|
26 |
-
model_id = "VietnamAIHub/VietCoMath-o1-8B"
|
27 |
-
pipeline = transformers.pipeline(
|
28 |
-
"text-generation",
|
29 |
-
model=model_id,
|
30 |
-
model_kwargs={"torch_dtype": torch.bfloat16},
|
31 |
-
device_map="auto",
|
32 |
-
)
|
33 |
-
|
34 |
-
# Prepare messages
|
35 |
-
messages = [
|
36 |
-
{"role": "system", "content": ""},
|
37 |
-
{"role": "user", "content": "Who are you?"},
|
38 |
-
]
|
39 |
-
|
40 |
-
# Define terminators
|
41 |
-
terminators = [
|
42 |
-
pipeline.tokenizer.eos_token_id,
|
43 |
-
pipeline.tokenizer.convert_tokens_to_ids("<|eot_id|>")
|
44 |
-
]
|
45 |
-
|
46 |
-
# Generate text
|
47 |
-
outputs = pipeline(
|
48 |
-
messages,
|
49 |
-
max_new_tokens=256,
|
50 |
-
eos_token_id=terminators,
|
51 |
-
do_sample=True,
|
52 |
-
temperature=0.6,
|
53 |
-
top_p=0.9,
|
54 |
-
)
|
55 |
-
|
56 |
-
# Print generated text
|
57 |
-
print(outputs[0]["generated_text"][-1])
|
58 |
-
```
|
59 |
-
|
60 |
-
### Advanced Usage with Response Parsing
|
61 |
|
62 |
#### Helper Functions
|
63 |
```python
|
@@ -116,48 +61,83 @@ def parse_response(response):
|
|
116 |
return answer, reflection, steps, ""
|
117 |
```
|
118 |
|
119 |
-
|
|
|
|
|
|
|
120 |
```python
|
121 |
-
|
|
|
122 |
|
123 |
-
|
124 |
-
|
125 |
-
|
|
|
|
|
|
|
|
|
126 |
)
|
127 |
|
|
|
128 |
# Example mathematical word problem
|
|
|
129 |
problem = "Có 100 sinh viên đỗ đại học. Trong số đó, có 55 sinh viên chọn âm nhạc, 44 sinh viên chọn thể thao, và 20 sinh viên chọn cả 2. Hỏi có bao nhiêu sinh viên không chọn âm nhạc, cũng không chọn thể thao?"
|
130 |
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
137 |
temperature=0.6,
|
138 |
top_p=0.9,
|
139 |
-
max_tokens=4096,
|
140 |
)
|
141 |
|
142 |
-
|
|
|
|
|
143 |
answer, reflection, steps, clarification = parse_response(generated_text)
|
144 |
-
```
|
145 |
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
|
|
|
|
|
|
|
|
|
|
150 |
|
151 |
## Limitations
|
152 |
-
- The model is
|
153 |
-
|
154 |
|
155 |
## License
|
156 |
-
[
|
157 |
|
158 |
## Citation
|
159 |
-
[If applicable, add citation information for the model]
|
160 |
-
```
|
161 |
|
162 |
-
|
163 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
# VietCoMath Model Usage
|
2 |
|
3 |
## Overview
|
4 |
+
This example snipe code for running the VietCoMath-01 small model for mathematical Coding problem-solving and General Multi tasks.
|
5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
#### Helper Functions
|
8 |
```python
|
|
|
61 |
return answer, reflection, steps, ""
|
62 |
```
|
63 |
|
64 |
+
|
65 |
+
## Usage
|
66 |
+
|
67 |
+
### Basic Text Generation
|
68 |
```python
|
69 |
+
import transformers
|
70 |
+
import torch
|
71 |
|
72 |
+
# Load the model
|
73 |
+
model_id = "VietnamAIHub/VietCoMath-o1-8B"
|
74 |
+
pipeline = transformers.pipeline(
|
75 |
+
"text-generation",
|
76 |
+
model=model_id,
|
77 |
+
model_kwargs={"torch_dtype": torch.bfloat16},
|
78 |
+
device_map="auto",
|
79 |
)
|
80 |
|
81 |
+
|
82 |
# Example mathematical word problem
|
83 |
+
|
84 |
problem = "Có 100 sinh viên đỗ đại học. Trong số đó, có 55 sinh viên chọn âm nhạc, 44 sinh viên chọn thể thao, và 20 sinh viên chọn cả 2. Hỏi có bao nhiêu sinh viên không chọn âm nhạc, cũng không chọn thể thao?"
|
85 |
|
86 |
+
# Prepare messages
|
87 |
+
messages = [
|
88 |
+
{"role": "system", "content": ""},
|
89 |
+
{"role": "user", "content": f"{problem}"},
|
90 |
+
]
|
91 |
+
|
92 |
+
# Define terminators
|
93 |
+
terminators = [
|
94 |
+
pipeline.tokenizer.eos_token_id,
|
95 |
+
pipeline.tokenizer.convert_tokens_to_ids("<|eot_id|>")
|
96 |
+
]
|
97 |
+
|
98 |
+
# Generate text
|
99 |
+
outputs = pipeline(
|
100 |
+
messages,
|
101 |
+
max_new_tokens=256,
|
102 |
+
eos_token_id=terminators,
|
103 |
+
do_sample=True,
|
104 |
temperature=0.6,
|
105 |
top_p=0.9,
|
|
|
106 |
)
|
107 |
|
108 |
+
# Print generated text
|
109 |
+
generated_text=outputs[0]["generated_text"][-1]
|
110 |
+
|
111 |
answer, reflection, steps, clarification = parse_response(generated_text)
|
|
|
112 |
|
113 |
+
print(clarification)
|
114 |
+
print("------------Internal Thinking-------------")
|
115 |
+
print(steps)
|
116 |
+
print(reflection)
|
117 |
+
print("------------End of Internal Thinking-------------\n")
|
118 |
+
|
119 |
+
print("------------Final Answer-------------")
|
120 |
+
print(answer)
|
121 |
+
print("------------End of Answer-------------")
|
122 |
|
123 |
## Limitations
|
124 |
+
- The model is Small scale May Failed in Very difficult problems, Please check the result
|
125 |
+
|
126 |
|
127 |
## License
|
128 |
+
[Model is based LLama 3B]
|
129 |
|
130 |
## Citation
|
|
|
|
|
131 |
|
132 |
+
@misc {VietnamAIHub,
|
133 |
+
author = { {VietnamAIHub} },
|
134 |
+
title = { VietCoMath-o1-8B},
|
135 |
+
year = 2024,
|
136 |
+
url = { https://huggingface.co/VietnamAIHub/VietCoMath-o1-8B },
|
137 |
+
doi = { 10.57967/hf/3743 },
|
138 |
+
publisher = { Hugging Face }
|
139 |
+
}
|
140 |
+
|
141 |
+
## Collaboration & Contribution
|
142 |
+
Bạn có thể kết nối trực tiếp với Trần Nhiệm [email protected]
|
143 |
+
Hoặc có thể chat trực tiếp ở: LinkedIn Facebook. X. Zalo +886 934 311 751
|