evilfreelancer commited on
Commit
86f57cc
·
verified ·
1 Parent(s): 225d501

Update README.md

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