Qwen Commit LoRA - Conventional Commit Message Generator

Generates conventional commit messages from git diffs using a fine-tuned Qwen2.5-Coder-3B model with QLoRA adapters.

Model Details

  • Base Model: Qwen/Qwen2.5-Coder-3B-Instruct
  • Fine-tuning Method: QLoRA (4-bit quantized, rank=8, alpha=16)
  • Training Data: 210 real conventional commits from open-source repositories
  • Target Modules: q_proj, k_proj, v_proj, o_proj

Usage

from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer

# Load base model
base_model = AutoModelForCausalLM.from_pretrained(
    "Qwen/Qwen2.5-Coder-3B-Instruct",
    load_in_4bit=True,
    device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2.5-Coder-3B-Instruct")

# Load LoRA adapters
model = PeftModel.from_pretrained(base_model, "Pavloffm/qwen-commit-lora")

# Generate commit message
diff = """diff --git a/src/main.py b/src/main.py
index 1234567..abcdefg 100644
--- a/src/main.py
+++ b/src/main.py
@@ -1,3 +1,5 @@
+def new_feature():
+    pass
"""

messages = [{"role": "user", "content": f"Generate a conventional commit message for this diff:\n{diff}"}]
inputs = tokenizer.apply_chat_template(messages, return_tensors="pt").to(model.device)
outputs = model.generate(inputs, max_new_tokens=100)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))

Training

  • 2 epochs
  • Learning rate: 1.5e-4
  • LoRA rank: 8, alpha: 16
  • 210 training examples

License

MIT License

Downloads last month
11
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for Pavloffm/qwen-commit-lora

Base model

Qwen/Qwen2.5-3B
Adapter
(33)
this model