evilfreelancer
commited on
Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,126 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: mit
|
3 |
+
datasets:
|
4 |
+
- Egor-AI/Russian_thinking_dataset
|
5 |
+
language:
|
6 |
+
- ru
|
7 |
+
- en
|
8 |
+
base_model:
|
9 |
+
- evilfreelancer/o1_gigachat-20b-a3b_lora
|
10 |
+
pipeline_tag: text-generation
|
11 |
+
tags:
|
12 |
+
- o1
|
13 |
+
- thinking
|
14 |
+
- reflection
|
15 |
+
---
|
16 |
+
|
17 |
+
# Russian o1 / GigaChat 20B-A3B Instruct
|
18 |
+
|
19 |
+
LoRA-адаптер для модели [GigaChat-20B-A3B](https://huggingface.co/ai-sage/GigaChat-20B-A3B-instruct-bf16) обученный на
|
20 |
+
датасете [Egor-AI/Russian_thinking_dataset](https://huggingface.co/datasets/Egor-AI/Russian_thinking_dataset) (машинный
|
21 |
+
перевод на русский язык
|
22 |
+
датасета [BintangFortuna/OpenO1-SFT-EN-SY](https://huggingface.co/datasets/BintangFortuna/OpenO1-SFT-EN-SY)).
|
23 |
+
|
24 |
+
Обученная модель способна имитировать логические размышлению на русском языке по аналогии с тем, как
|
25 |
+
это делает `o1` от `OpenAI`.
|
26 |
+
|
27 |
+
Необходимо использовать следующего вида системный промт:
|
28 |
+
|
29 |
+
```
|
30 |
+
Вы — ИИ-помощник. Отформатируйте свои ответы следующим образом: <Thought> Ваши мысли (понимание, рассуждения) </Thought> <output> Ваш ответ </output>
|
31 |
+
```
|
32 |
+
|
33 |
+
W&B отчёт: https://api.wandb.ai/links/evilfreelancer/nlec8bt8
|
34 |
+
|
35 |
+
Обучение производилось при помощи утилиты [impruver](https://github.com/EvilFreelancer/impruver) используя конфигурацию
|
36 |
+
[GigaChat/20B-A3B_lora_o1](https://github.com/EvilFreelancer/impruver/blob/main/recipes/configs/GigaChat/20B-A3B_lora_o1.yaml).
|
37 |
+
|
38 |
+
На всё про всё ушло примерно 117 часов на RTX 4090, при этом понадобилось 23Гб видеопамяти.
|
39 |
+
|
40 |
+
```yaml
|
41 |
+
output_dir: ./models/GigaChat_20B-A3B_lora_thinking
|
42 |
+
train_path: ./train.GigaChat_20B-A3B_lora_thinking.jsonl
|
43 |
+
val_path: ./val.GigaChat_20B-A3B_lora_thinking.jsonl
|
44 |
+
|
45 |
+
datasets:
|
46 |
+
- name: Egor-AI/Russian_thinking_dataset
|
47 |
+
converter: impruver.instruction_to_messages
|
48 |
+
mapping:
|
49 |
+
system: system
|
50 |
+
instruction: prompt
|
51 |
+
output: response
|
52 |
+
|
53 |
+
model:
|
54 |
+
class: custom.gigachat.DeepseekForCausalLM
|
55 |
+
name: ai-sage/GigaChat-20B-A3B-instruct-bf16
|
56 |
+
attn_implementation: flash_attention_2
|
57 |
+
load_in_4bit: true
|
58 |
+
load_in_8bit: false
|
59 |
+
dtype: bf16
|
60 |
+
|
61 |
+
lora:
|
62 |
+
r: 8
|
63 |
+
lora_alpha: 32
|
64 |
+
lora_dropout: 0.1
|
65 |
+
bias: none
|
66 |
+
target_modules: [ q_proj, v_proj, k_proj, o_proj, gate_proj, down_proj, up_proj ]
|
67 |
+
task_type: CAUSAL_LM
|
68 |
+
|
69 |
+
tokenizer:
|
70 |
+
class: transformers.AutoTokenizer
|
71 |
+
name: ai-sage/GigaChat-20B-A3B-instruct
|
72 |
+
max_tokens_count: 1500
|
73 |
+
special_tokens:
|
74 |
+
pad_token_id: 1
|
75 |
+
pad_token: <s>
|
76 |
+
bos_token_id: 1
|
77 |
+
bos_token: <s>
|
78 |
+
eos_token_id: 128001
|
79 |
+
eos_token: <|message_sep|>
|
80 |
+
chat_template: >
|
81 |
+
{% if messages[0]['role'] == 'system' -%}
|
82 |
+
{%- set loop_messages = messages[1:] -%}
|
83 |
+
{%- set system_message = bos_token + messages[0]['content'] + additional_special_tokens[1] -%}
|
84 |
+
{%- else -%}
|
85 |
+
{%- set loop_messages = messages -%}
|
86 |
+
{%- set system_message = bos_token + '' -%}
|
87 |
+
{%- endif -%}
|
88 |
+
{%- for message in messages %}
|
89 |
+
{%- if message['role'] == 'system' -%}
|
90 |
+
{{ system_message -}}
|
91 |
+
{%- endif -%}
|
92 |
+
{%- if message['role'] == 'user' -%}
|
93 |
+
{{ message['role'] + additional_special_tokens[0] + message['content'] + additional_special_tokens[1] -}}
|
94 |
+
{{ 'available functions' + additional_special_tokens[0] + additional_special_tokens[2] + additional_special_tokens[3] + additional_special_tokens[1] -}}
|
95 |
+
{%- endif -%}
|
96 |
+
{%- if message['role'] == 'assistant' -%}
|
97 |
+
{{ message['role'] + additional_special_tokens[0] + message['content'] + additional_special_tokens[1] -}}
|
98 |
+
{%- endif -%}
|
99 |
+
{%- if loop.last and add_generation_prompt -%}
|
100 |
+
{{ 'assistant' + additional_special_tokens[0] -}}
|
101 |
+
{%- endif -%}
|
102 |
+
{%- endfor %}
|
103 |
+
|
104 |
+
trainer:
|
105 |
+
eval_strategy: steps
|
106 |
+
save_strategy: steps
|
107 |
+
eval_steps: 100
|
108 |
+
save_steps: 100
|
109 |
+
per_device_train_batch_size: 1
|
110 |
+
per_device_eval_batch_size: 1
|
111 |
+
gradient_accumulation_steps: 8
|
112 |
+
logging_steps: 1
|
113 |
+
learning_rate: 0.0004
|
114 |
+
num_train_epochs: 2
|
115 |
+
lr_scheduler_type: cosine
|
116 |
+
warmup_steps: 16
|
117 |
+
optim: adamw_torch_4bit
|
118 |
+
metric_for_best_model: eval_loss
|
119 |
+
load_best_model_at_end: true
|
120 |
+
save_total_limit: 2
|
121 |
+
seed: 42
|
122 |
+
remove_unused_columns: false
|
123 |
+
max_grad_norm: 1.0
|
124 |
+
weight_decay: 0.08
|
125 |
+
torch_compile: false
|
126 |
+
```
|