File size: 2,727 Bytes
f3adba3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
---
# For reference on model card metadata, see the spec: https://github.com/huggingface/hub-docs/blob/main/modelcard.md?plain=1
# Doc / guide: https://huggingface.co/docs/hub/model-cards
{}
---

# MetaMath Mistral7B Lora fine tuning

<!-- Provide a quick summary of what the model is/does. -->

This is the LoRa weight fine-tuning version of Meta-Math-Mistral-7B on Vietnamese Elementary Maths Solving

## Model Details

### Model Description

<!-- Provide a longer summary of what this model is. -->

- **Model type:** LoRa(rank = 128, alpha = 256)
- **Languages (NLP):** English, Vietnamese
- **Finetuned from model [optional]:** meta-math/MetaMath-Mistral-7B

### Model Sources [optional]

<!-- Provide the basic links for the model. -->
- **Repository:** [tien02/llm-math](https://github.com/tien02/llm-math)

## Uses

* Instruction with explanation
```
INS_EXP_PROMPT = '''
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.

### Instruction:
{question}

### Input:
{choices}

### Rationale:
{explanation}

### Response: {answer}
'''
```

* Instruction with no explanation
```
INS_EXP_PROMPT = '''
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.

### Instruction:
{question}

### Input:
{choices}

### Response: {answer}
'''
```  
* Evaluation prompt
```
INS_PROMPT = '''
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.

### Instruction:
{question}

### Input:
{choices}

### Rationale:
'''
```

## How to Get Started with the Model

Use the code below to get started with the model.
```
import torch
from peft import PeftModel
from transformers import AutoTokenizer, AutoModelForCausalLM

model_name_or_path = "meta-math/MetaMath-Mistral-7B"
lora_path = "tienda02/metamath-mistral7B-lora"

tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, use_fast=False)
model = AutoModelForCausalLM.from_pretrained(model_name_or_path, device_map='auto')
model = PeftModel.from_pretrained(model, lora_path)
model = model.merge_and_unload()
```