yisuiban commited on
Commit
a4be7e8
·
verified ·
1 Parent(s): 3cb1b37

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. README.md +82 -0
  2. adapter_config.json +41 -0
  3. adapters.safetensors +3 -0
README.md ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ base_model: mlx-community/Qwen2.5-Coder-7B-Instruct-4bit
4
+ tags:
5
+ - mlx
6
+ - lora
7
+ - qwen
8
+ - commit-message
9
+ - conventional-commits
10
+ - git
11
+ - chinese
12
+ ---
13
+
14
+ # git-ai-commit-sft
15
+
16
+ A LoRA adapter fine-tuned on Qwen2.5-Coder-7B-Instruct-4bit to generate **Chinese Conventional Commits** commit messages from git diffs.
17
+
18
+ Built for [git-ai-commit](https://github.com/your-org/git-ai-commit), an IntelliJ plugin that uses LLMs to generate commit messages.
19
+
20
+ ## Model
21
+
22
+ - **Base model:** [mlx-community/Qwen2.5-Coder-7B-Instruct-4bit](https://huggingface.co/mlx-community/Qwen2.5-Coder-7B-Instruct-4bit)
23
+ - **Fine-tuning:** LoRA (rank 8, 16 layers, 11.5M trainable params)
24
+ - **Format:** MLX adapter (safetensors)
25
+
26
+ ## Training Data
27
+
28
+ 548 high-quality commit messages from two real-world repositories (one Java backend, one Go microservice), filtered to Chinese-only Conventional Commits format. Each training sample pairs a git diff (processed through the plugin's exact runtime pipeline — GitDiffFilter + PromptBuilder) with the corresponding human-written commit message.
29
+
30
+ ## Evaluation
31
+
32
+ | Metric | Before | After |
33
+ |---|---|---|
34
+ | Conventional Commits rate | 96% | **100%** |
35
+ | Chinese rate | 100% | 100% |
36
+ | Single-line rate | 100% | 100% |
37
+ | Mean similarity to reference | 0.339 | **0.546** |
38
+ | Mean output length | 51 chars | 27 chars |
39
+
40
+ ## Usage
41
+
42
+ ```bash
43
+ # Install mlx-lm
44
+ pip install mlx-lm
45
+
46
+ # Download and load
47
+ python -m mlx_lm.generate \
48
+ --model mlx-community/Qwen2.5-Coder-7B-Instruct-4bit \
49
+ --adapter-path yisuiban/git-ai-commit-sft \
50
+ --prompt "你是一位资深工程师,擅长根据 git diff 生成一句中文提交信息。..."
51
+ ```
52
+
53
+ From Python:
54
+
55
+ ```python
56
+ from mlx_lm import load, generate
57
+ from mlx_lm.sample_utils import make_sampler
58
+
59
+ model, tokenizer = load(
60
+ "mlx-community/Qwen2.5-Coder-7B-Instruct-4bit",
61
+ adapter_path="yisuiban/git-ai-commit-sft"
62
+ )
63
+
64
+ prompt = tokenizer.apply_chat_template(
65
+ [{"role": "user", "content": "你的提示词..."}],
66
+ tokenize=False, add_generation_prompt=True
67
+ )
68
+ response = generate(model, tokenizer, prompt=prompt, max_tokens=64,
69
+ sampler=make_sampler(temp=0.0))
70
+ ```
71
+
72
+ For Ollama deployment, see the [training repository](https://github.com/your-org/git-ai-commit-sft) for the full Modelfile and export pipeline.
73
+
74
+ ## Training Details
75
+
76
+ - **Hardware:** Apple M1 Max (64GB unified memory)
77
+ - **Framework:** MLX LoRA (mlx-lm 0.31.3)
78
+ - **Optimizer:** Adam, learning rate 1e-5
79
+ - **Batch:** 1 × gradient accumulation 8 (effective batch 8)
80
+ - **Steps:** 250 (~4 epochs over 473 training samples)
81
+ - **Max sequence length:** 4096 tokens
82
+ - **Training time:** ~20 minutes on M1 Max
adapter_config.json ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "adapter_path": "adapters/qwen25-coder-7b-sft",
3
+ "batch_size": 1,
4
+ "clear_cache_threshold": 0,
5
+ "config": "configs/train.json",
6
+ "data": "data",
7
+ "fine_tune_type": "lora",
8
+ "grad_accumulation_steps": 8,
9
+ "grad_checkpoint": false,
10
+ "iters": 250,
11
+ "learning_rate": 1e-05,
12
+ "lora_parameters": {
13
+ "rank": 8,
14
+ "dropout": 0.0,
15
+ "scale": 20.0
16
+ },
17
+ "lr_schedule": null,
18
+ "mask_prompt": true,
19
+ "max_seq_length": 4096,
20
+ "model": "mlx-community/Qwen2.5-Coder-7B-Instruct-4bit",
21
+ "num_layers": 16,
22
+ "optimizer": "adam",
23
+ "optimizer_config": {
24
+ "adam": {},
25
+ "adamw": {},
26
+ "muon": {},
27
+ "sgd": {},
28
+ "adafactor": {}
29
+ },
30
+ "project_name": null,
31
+ "report_to": null,
32
+ "resume_adapter_file": null,
33
+ "save_every": 100,
34
+ "seed": 42,
35
+ "steps_per_eval": 25,
36
+ "steps_per_report": 10,
37
+ "test": false,
38
+ "test_batches": 500,
39
+ "train": true,
40
+ "val_batches": 10
41
+ }
adapters.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ae4b49bef517767fbf4903c328eb989590fee1da89e6c50e031f42c289bb340e
3
+ size 46161566