Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
# For reference on model card metadata, see the spec: https://github.com/huggingface/hub-docs/blob/main/modelcard.md?plain=1
|
3 |
+
# Doc / guide: https://huggingface.co/docs/hub/model-cards
|
4 |
+
{}
|
5 |
+
---
|
6 |
+
|
7 |
+
# MetaMath Mistral7B Lora fine tuning
|
8 |
+
|
9 |
+
<!-- Provide a quick summary of what the model is/does. -->
|
10 |
+
|
11 |
+
This is the LoRa weight fine-tuning version of Meta-Math-Mistral-7B on Vietnamese Elementary Maths Solving
|
12 |
+
|
13 |
+
## Model Details
|
14 |
+
|
15 |
+
### Model Description
|
16 |
+
|
17 |
+
<!-- Provide a longer summary of what this model is. -->
|
18 |
+
|
19 |
+
- **Model type:** LoRa(rank = 128, alpha = 256)
|
20 |
+
- **Languages (NLP):** English, Vietnamese
|
21 |
+
- **Finetuned from model [optional]:** meta-math/MetaMath-Mistral-7B
|
22 |
+
|
23 |
+
### Model Sources [optional]
|
24 |
+
|
25 |
+
<!-- Provide the basic links for the model. -->
|
26 |
+
- **Repository:** [tien02/llm-math](https://github.com/tien02/llm-math)
|
27 |
+
|
28 |
+
## Uses
|
29 |
+
|
30 |
+
* Instruction with explanation
|
31 |
+
```
|
32 |
+
INS_EXP_PROMPT = '''
|
33 |
+
You are a helpful assistant in evaluating the quality of the outputs for a given instruction. \
|
34 |
+
Please propose at most a precise answer about whether a potential output is a good output for a given instruction. \
|
35 |
+
Another assistant will evaluate different aspects of the output by answering all the questions.
|
36 |
+
|
37 |
+
### Instruction:
|
38 |
+
{question}
|
39 |
+
|
40 |
+
### Input:
|
41 |
+
{choices}
|
42 |
+
|
43 |
+
### Rationale:
|
44 |
+
{explanation}
|
45 |
+
|
46 |
+
### Response: {answer}
|
47 |
+
'''
|
48 |
+
```
|
49 |
+
|
50 |
+
* Instruction with no explanation
|
51 |
+
```
|
52 |
+
INS_EXP_PROMPT = '''
|
53 |
+
You are a helpful assistant in evaluating the quality of the outputs for a given instruction. \
|
54 |
+
Please propose at most a precise answer about whether a potential output is a good output for a given instruction. \
|
55 |
+
Another assistant will evaluate different aspects of the output by answering all the questions.
|
56 |
+
|
57 |
+
### Instruction:
|
58 |
+
{question}
|
59 |
+
|
60 |
+
### Input:
|
61 |
+
{choices}
|
62 |
+
|
63 |
+
### Response: {answer}
|
64 |
+
'''
|
65 |
+
```
|
66 |
+
* Evaluation prompt
|
67 |
+
```
|
68 |
+
INS_PROMPT = '''
|
69 |
+
You are a helpful assistant in evaluating the quality of the outputs for a given instruction. Please propose at most a precise answer about whether a potential output is a good output for a given instruction. Another assistant will evaluate different aspects of the output by answering all the questions.
|
70 |
+
|
71 |
+
### Instruction:
|
72 |
+
{question}
|
73 |
+
|
74 |
+
### Input:
|
75 |
+
{choices}
|
76 |
+
|
77 |
+
### Rationale:
|
78 |
+
'''
|
79 |
+
```
|
80 |
+
|
81 |
+
## How to Get Started with the Model
|
82 |
+
|
83 |
+
Use the code below to get started with the model.
|
84 |
+
```
|
85 |
+
import torch
|
86 |
+
from peft import PeftModel
|
87 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
88 |
+
|
89 |
+
model_name_or_path = "meta-math/MetaMath-Mistral-7B"
|
90 |
+
lora_path = "tienda02/metamath-mistral7B-lora"
|
91 |
+
|
92 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, use_fast=False)
|
93 |
+
model = AutoModelForCausalLM.from_pretrained(model_name_or_path, device_map='auto')
|
94 |
+
model = PeftModel.from_pretrained(model, lora_path)
|
95 |
+
model = model.merge_and_unload()
|
96 |
+
```
|
97 |
+
|
98 |
+
|
99 |
+
|