Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,123 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language:
|
3 |
+
- ru
|
4 |
+
datasets:
|
5 |
+
- IlyaGusev/saiga_scored
|
6 |
+
- IlyaGusev/saiga_preferences
|
7 |
+
license: apache-2.0
|
8 |
+
---
|
9 |
+
|
10 |
+
|
11 |
+
# Saiga/MistralNemo 12B, Russian fine-tune of Mistral Nemo
|
12 |
+
|
13 |
+
Based on [an abliterated version](https://huggingface.co/natong19/Mistral-Nemo-Instruct-2407-abliterated) of [Mistral Nemo](https://huggingface.co/mistralai/Mistral-Nemo-Instruct-2407).
|
14 |
+
|
15 |
+
Llama.cpp version: TBD
|
16 |
+
|
17 |
+
Colab: [link](https://colab.research.google.com/drive/1qxgIPymzW6_H6s_wwXu3lknkkYM45Db4)
|
18 |
+
|
19 |
+
## Prompt format
|
20 |
+
|
21 |
+
% if messages[0]['role'] == 'system' %}{% set system_message = messages[0]['content'] | trim + '\n\n' %}{% set messages = messages[1:] %}{% else %}{% set system_message = '' %}{% endif %}{{- bos_token + system_message}}{% for message in messages %}{% if message['role'] == 'user' %}{{ '[INST] ' + message['content'] | trim + ' [/INST]' }}{% elif message['role'] == 'assistant' %}{{ ' ' + message['content'] | trim + eos_token }}{% endif %}{% endfor %}",
|
22 |
+
|
23 |
+
Original Misral Nemo prompt format, but the system prompt is in the beginning:
|
24 |
+
```
|
25 |
+
<s>Ты — Сайга, русскоязычный автоматический ассистент. Ты разговариваешь с людьми и помогаешь им.
|
26 |
+
[INST]Как дела?[/INST]
|
27 |
+
Отлично, а у тебя?</s>
|
28 |
+
[INST]Шикарно. Как пройти в библиотеку?[/INST]
|
29 |
+
```
|
30 |
+
|
31 |
+
## Code example
|
32 |
+
```python
|
33 |
+
# Исключительно ознакомительный пример.
|
34 |
+
# НЕ НАДО ТАК ИНФЕРИТЬ МОДЕЛЬ В ПРОДЕ.
|
35 |
+
# См. https://github.com/vllm-project/vllm или https://github.com/huggingface/text-generation-inference
|
36 |
+
|
37 |
+
import torch
|
38 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, GenerationConfig
|
39 |
+
|
40 |
+
MODEL_NAME = "IlyaGusev/saiga_nemo_12b"
|
41 |
+
|
42 |
+
model = AutoModelForCausalLM.from_pretrained(
|
43 |
+
MODEL_NAME,
|
44 |
+
load_in_8bit=True,
|
45 |
+
torch_dtype=torch.bfloat16,
|
46 |
+
device_map="auto"
|
47 |
+
)
|
48 |
+
model.eval()
|
49 |
+
|
50 |
+
tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
|
51 |
+
generation_config = GenerationConfig.from_pretrained(MODEL_NAME)
|
52 |
+
print(generation_config)
|
53 |
+
|
54 |
+
inputs = ["Почему трава зеленая?", "Сочини длинный рассказ, обязательно упоминая следующие объекты. Дано: Таня, мяч"]
|
55 |
+
for query in inputs:
|
56 |
+
prompt = tokenizer.apply_chat_template([{
|
57 |
+
"role": "user",
|
58 |
+
"content": query
|
59 |
+
}], tokenize=False, add_generation_prompt=True)
|
60 |
+
data = tokenizer(prompt, return_tensors="pt", add_special_tokens=False)
|
61 |
+
data = {k: v.to(model.device) for k, v in data.items()}
|
62 |
+
output_ids = model.generate(**data, generation_config=generation_config)[0]
|
63 |
+
output_ids = output_ids[len(data["input_ids"][0]):]
|
64 |
+
output = tokenizer.decode(output_ids, skip_special_tokens=True).strip()
|
65 |
+
print(query)
|
66 |
+
print(output)
|
67 |
+
print()
|
68 |
+
print("==============================")
|
69 |
+
print()
|
70 |
+
```
|
71 |
+
|
72 |
+
## Output examples
|
73 |
+
```
|
74 |
+
User: Почему трава зеленая?
|
75 |
+
Saiga: TBD
|
76 |
+
```
|
77 |
+
|
78 |
+
```
|
79 |
+
User: Сочини длинный рассказ, обязательно упоминая следующие объекты. Дано: Таня, мяч
|
80 |
+
Saiga: TBD
|
81 |
+
```
|
82 |
+
|
83 |
+
|
84 |
+
## Versions
|
85 |
+
v1:
|
86 |
+
- [87a83ce252ff0142cd4cc918fb3e6a9875ca4638](https://huggingface.co/IlyaGusev/saiga_nemo_12b/commit/87a83ce252ff0142cd4cc918fb3e6a9875ca4638)
|
87 |
+
- Other name: saiga_nemo_12b_sft_m9_d14_simpo_m19_d31
|
88 |
+
- SFT dataset config: [sft_d14.json](https://github.com/IlyaGusev/saiga/blob/main/configs/datasets/sft_d14.json)
|
89 |
+
- SFT model config: [saiga_nemo_12b_sft_m9.json](https://github.com/IlyaGusev/saiga/blob/main/configs/models/saiga_nemo_12b_sft_m9.json)
|
90 |
+
- SimPO dataset config: [pref_d31.json](https://github.com/IlyaGusev/saiga/blob/main/configs/datasets/pref_d31.json)
|
91 |
+
- SimPO model config: [saiga_nemo_12b_simpo_m19.json](https://github.com/IlyaGusev/saiga/blob/main/configs/models/saiga_nemo_12b_simpo_m19.json)
|
92 |
+
- SFT wandb: [link](https://wandb.ai/ilyagusev/rulm_self_instruct/runs/2ympfu9y)
|
93 |
+
- SimPO wandb: [link](https://wandb.ai/ilyagusev/rulm_self_instruct/runs/9zn4825e)
|
94 |
+
|
95 |
+
|
96 |
+
## Evaluation
|
97 |
+
|
98 |
+
* Dataset: https://github.com/IlyaGusev/rulm/blob/master/self_instruct/data/tasks.jsonl
|
99 |
+
* Framework: https://github.com/tatsu-lab/alpaca_eval
|
100 |
+
* Evaluator: alpaca_eval_cot_gpt4_turbo_fn
|
101 |
+
|
102 |
+
Pivot: chatgpt_3_5_turbo
|
103 |
+
| model | length_controlled_winrate | win_rate | standard_error | avg_length |
|
104 |
+
|-----|-----|-----|-----|-----|
|
105 |
+
|chatgpt_4_turbo | 76.04 | 90.00 |1.46 | 1270 |
|
106 |
+
|chatgpt_3_5_turbo | 50.00 | 50.00 | 0.00 | 536 |
|
107 |
+
|saiga_llama3_8b, v6 | 49.33 | 68.31 | 2.26 | 1262 |
|
108 |
+
|sfr-iter-dpo | 49.11 | 74.94 | 2.13 | 1215 |
|
109 |
+
|suzume | 49.05 | 71.57 | 2.20 | 1325 |
|
110 |
+
|saiga_llama3_8b, v7| 48.95 | 69.40 | 2.25 | 1266 |
|
111 |
+
|saiga_llama3_8b, v5 | 47.13 | 66.18 | 2.31 | 1194 |
|
112 |
+
|saiga_llama3_8b, v4 | 43.64 | 65.90 | 2.31 | 1200 |
|
113 |
+
|saiga_llama3_8b, v3 | 36.97 | 61.08 | 2.38 | 1162 |
|
114 |
+
|saiga_llama3_8b, v2 | 33.07 | 48.19 | 2.45 | 1166 |
|
115 |
+
|saiga_mistral_7b | 23.38 | 35.99 | 2.34 | 949 |
|
116 |
+
|
117 |
+
Pivot: sfr
|
118 |
+
| model | length_controlled_winrate | win_rate | standard_error | avg_length |
|
119 |
+
|-----|-----|-----|-----|-----|
|
120 |
+
| sfr | 50.00 | 50.00 | 0.00 | 1215 |
|
121 |
+
| saiga_llama3_8b, v7 | 48.95 | 49.16 | 2.46 | 1266 |
|
122 |
+
| saiga_llama3_8b, v6 | 46.91 | 47.23 | 2.45 | 1262 |
|
123 |
+
| suzume_8b | 43.69 | 48.19 | 2.46 | 1325 |
|