|
|
4 сар өмнө | |
|---|---|---|
| .. | ||
| data | 4 сар өмнө | |
| .gitignore | 4 сар өмнө | |
| README.md | 4 сар өмнө | |
| evaluate_baseline.py | 4 сар өмнө | |
| evaluate_model.py | 4 сар өмнө | |
| evaluation_0.6B.json | 4 сар өмнө | |
| evaluation_0.6B_v2.json | 4 сар өмнө | |
| evaluation_1.7B.json | 4 сар өмнө | |
| evaluation_1.7B_v2.json | 4 сар өмнө | |
| evaluation_baseline_0.6B.json | 4 сар өмнө | |
| export_gguf.py | 4 сар өмнө | |
| generate_data.py | 4 сар өмнө | |
| generate_data_offline.py | 4 сар өмнө | |
| prepare_data.py | 4 сар өмнө | |
| train_0.6B.py | 4 сар өмнө | |
| train_1.7B.py | 4 сар өмнө | |
| train_1.7B_v2.py | 4 сар өмнө | |
| train_grpo.py | 4 сар өмнө | |
| train_hf_job.py | 4 сар өмнө | |
Finetune small Qwen models for QMD's query expansion task.
Train models that convert user queries into retrieval-optimized outputs:
Input: "how to configure authentication"
Output:
lex: authentication setup
lex: auth configuration
vec: how to set up user authentication in the application
hyde: To configure authentication, set the AUTH_SECRET environment variable and enable the auth middleware in your application config.
| Type | Purpose | Count |
|---|---|---|
lex |
BM25 keyword variations | 1-3 |
vec |
Semantic reformulations | 1-3 |
hyde |
Hypothetical document passage | 0-1 |
| Model | HuggingFace | Format Compliance | Status |
|---|---|---|---|
| Qwen3-0.6B (finetuned) | tobil/qmd-query-expansion-0.6B | 95% | Recommended |
| Qwen3-1.7B (finetuned) | tobil/qmd-query-expansion-1.7B | 0% | Training issues |
| Qwen3-0.6B (baseline) | - | 0% | Untrained |
finetune/
├── README.md # This file
├── DATASETS.md # Dataset research findings
├── TRAINING_JOBS.md # HuggingFace Jobs tracking
├── generate_data_offline.py # Transform s-emanuilov dataset to QMD format
├── prepare_data.py # Upload to HuggingFace Hub
├── train_0.6B.py # Training script for 0.6B model
├── train_1.7B.py # Training script for 1.7B model
├── train_grpo.py # GRPO RL training (optional)
├── evaluate_model.py # Evaluate finetuned models
├── evaluate_baseline.py # Evaluate base models
├── data/
│ ├── qmd_expansion.jsonl # Generated training data
│ └── train/ # Prepared chat format
└── evaluation_*.json # Evaluation results
# Transform s-emanuilov dataset to QMD format (no API needed)
uv run generate_data_offline.py
# Convert to chat format and upload to HuggingFace Hub
uv run prepare_data.py
# Train Qwen3-0.6B (recommended)
hf jobs uv run --flavor a10g-large --timeout 3h --secrets HF_TOKEN \
"https://huggingface.co/tobil/qmd-training-scripts/resolve/main/train_0.6B.py"
# Evaluate finetuned model
uv run evaluate_model.py --model tobil/qmd-query-expansion-0.6B --base-model Qwen/Qwen3-0.6B
# Compare to baseline
uv run evaluate_baseline.py --model Qwen/Qwen3-0.6B --num-queries 10
# Convert to GGUF for node-llama-cpp (TODO)
uv run export_gguf.py --model tobil/qmd-query-expansion-0.6B --quantization Q8_0
| Parameter | Value |
|---|---|
| Method | LoRA (rank 16, alpha 32) |
| Learning Rate | 2e-4 |
| Epochs | 3 |
| Batch Size | 4 (with 4x gradient accumulation) |
| Max Seq Length | 512 |
| Target Modules | q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj |
The models are trained on this simple prompt format:
Expand this search query:
{query}
The model responds with lex/vec/hyde lines directly.
Sample outputs:
| Query | Output |
|---|---|
how to configure authentication |
lex: steps for setting up authentication vec: steps for setting up authentication in cloud services hyde: The process of configure authentication... |
kubernetes vs docker swarm |
lex: kubernetes and docker swarm vec: kubernetes vs docker swarm hyde: Kubernetes vs docker swarm is an important concept... |
cors error fix |
lex: how to fix cors vec: how to fix cors issues in web apps hyde: The topic of cors error fix guide... |
The untrained model generates random prose, code blocks, or repetitive text with no understanding of the lex/vec/hyde format.