Initial SQL-only 1C adapter baseline

This commit is contained in:
2026-07-22 03:03:47 +03:00
commit e2503b77e7
545 changed files with 184711 additions and 0 deletions
+45
View File
@@ -0,0 +1,45 @@
# 1C Training
Контур дообучения для 1С.
Рекомендуемый порядок:
1. собрать проверенные примеры;
2. удалить секреты и персональные данные;
3. привести к chat/instruction формату;
4. прогнать базовые eval-тесты;
5. обучить LoRA/adapter;
6. сравнить базовую модель, RAG и адаптер;
7. опубликовать адаптер через model card.
## Data Validation
Синтетический пример:
```powershell
python scripts/validate_1c_training_data.py plugins/1c/training/examples/instruction.examples.jsonl
python scripts/generate_1c_training_data.py
python scripts/validate_1c_training_data.py plugins/1c/training/raw/generated.instruction.jsonl
python scripts/prepare_1c_training_data.py --input plugins/1c/training/examples/instruction.examples.jsonl --output plugins/1c/training/prepared/train.chat.jsonl
```
`prepare_1c_training_data.py` автоматически добавляет `plugins/1c/training/raw/generated.instruction.jsonl`, если файл существует. `generate_1c_training_data.py` также добавляет проверенные write-route примеры из `reports/1c-sql/upo_test/write-matrix-verified-registry-*.json` и manual learning-plan примеры из `write-learning-plan-*.json`; лимиты регулируются `--max-write-records` и `--max-learning-records`. `raw` и `prepared` игнорируются git. Реальные обучающие данные должны проходить secret-scan и экспертное ревью.
## LoRA Training
Config: `plugins/1c/training/configs/qwen3-coder-30b-a3b-lora.yaml`.
Preflight:
```powershell
python scripts/preflight_1c_training.py
```
Dry run:
```powershell
python scripts/train_1c_lora.py --dry-run
```
Runbook: `docs/runbooks/1c-lora-training.md`.
@@ -0,0 +1,35 @@
id: qwen3-4b-1c-lora-v1
base_model_path: /models/base/qwen3-4b-instruct-2507
dataset_path: /workspace/plugins/1c/training/prepared/train.chat.jsonl
output_dir: /models/adapters/1c/qwen3-4b-1c-lora-v1
max_seq_length: 2048
train:
num_train_epochs: 3
per_device_train_batch_size: 1
gradient_accumulation_steps: 8
learning_rate: 0.0002
warmup_ratio: 0.03
logging_steps: 1
save_strategy: "no"
save_total_limit: 1
bf16: true
fp16: false
lora:
r: 16
lora_alpha: 32
lora_dropout: 0.05
bias: none
target_modules:
- q_proj
- k_proj
- v_proj
- o_proj
- gate_proj
- up_proj
- down_proj
quantization:
load_in_4bit: true
bnb_4bit_quant_type: nf4
bnb_4bit_use_double_quant: true
bnb_4bit_compute_dtype: bfloat16
notes: "Training config for the first 1C LoRA adapter. Requires complete base model and GPU host."
@@ -0,0 +1,41 @@
id: qwen3-coder-30b-a3b-1c-lora-v1
base_model_path: /models/base/qwen3-coder-30b-a3b-instruct
base_model_card_id: qwen3-coder-30b-a3b-instruct
required_base_files:
- config.json
- tokenizer.json
- tokenizer_config.json
- model.safetensors.index.json
dataset_path: /workspace/plugins/1c/training/prepared/train.chat.jsonl
output_dir: /models/adapters/1c/qwen3-coder-30b-a3b-1c-lora-v1
max_seq_length: 4096
train:
num_train_epochs: 2
per_device_train_batch_size: 1
gradient_accumulation_steps: 16
learning_rate: 0.0001
warmup_ratio: 0.03
logging_steps: 1
save_strategy: "no"
save_total_limit: 1
bf16: true
fp16: false
lora:
r: 16
lora_alpha: 32
lora_dropout: 0.05
bias: none
target_modules:
- q_proj
- k_proj
- v_proj
- o_proj
- gate_proj
- up_proj
- down_proj
quantization:
load_in_4bit: true
bnb_4bit_quant_type: nf4
bnb_4bit_use_double_quant: true
bnb_4bit_compute_dtype: bfloat16
notes: "Default 1C LoRA training config for the current Qwen3-Coder 30B A3B family behind the Q6 GGUF runtime."
@@ -0,0 +1,2 @@
{"id":"bsl-if-example","messages":[{"role":"system","content":"Ты помощник по 1С и BSL."},{"role":"user","content":"Покажи пример условия Если Тогда Иначе на BSL."},{"role":"assistant","content":"```bsl\nЕсли ЗначениеЗаполнено(Наименование) Тогда\n Сообщить(Наименование);\nИначе\n Сообщить(\"Наименование не заполнено\");\nКонецЕсли;\n```\n\nЭто общий пример без привязки к конкретной конфигурации."}],"metadata":{"domain":"1c","task":"bsl-code","source":"synthetic"}}
{"id":"metadata-required","messages":[{"role":"system","content":"Ты помощник по 1С. Не выдумывай метаданные."},{"role":"user","content":"Какие реквизиты есть у справочника Номенклатура?"},{"role":"assistant","content":"Чтобы ответить точно, нужно получить метаданные конкретной базы 1С. Без metadata snapshot или вызова инструмента я не должен перечислять реквизиты, потому что они зависят от конфигурации."}],"metadata":{"domain":"1c","task":"metadata-safety","source":"synthetic"}}
@@ -0,0 +1,34 @@
id: 1c-instruction-v1
name: 1C Instruction Dataset v1
status: draft
format: chat-jsonl
example_path: plugins/1c/training/examples/instruction.examples.jsonl
generated_path: plugins/1c/training/raw/generated.instruction.jsonl
prepared_path: plugins/1c/training/prepared/train.chat.jsonl
validation:
script: scripts/validate_1c_training_data.py
generation:
script: scripts/generate_1c_training_data.py
sources:
- plugins/1c/metadata/examples/metadata-v2.example.json
- plugins/1c/metadata/examples/bsl-modules.example.json
- reports/1c-sql/upo_test/write-matrix-verified-registry-configsave-91ce.json
- reports/1c-sql/upo_test/write-matrix-verified-registry-configsave-fa44.json
- reports/1c-sql/upo_test/write-learning-plan-configsave-91ce.json
- reports/1c-sql/upo_test/write-learning-plan-configsave-fa44.json
write_artifacts:
verified_registry_limit_per_file: 25
learning_plan_limit_per_file: 12
privacy:
allow_client_data: false
require_secret_scan: true
require_expert_review: true
tasks:
- bsl-code
- metadata-safety
- metadata-write-verified
- metadata-write-learning-plan
- 1c-query
- explanation
notes: "Use curated, reviewed examples for quality training. Generated synthetic records are allowed for pipeline checks and guardrail pretraining, but still require review before production use."
+1
View File
@@ -0,0 +1 @@
+1
View File
@@ -0,0 +1 @@