bigcode/commitpackft
Viewer • Updated • 702k • 475k • 100
Fine-tuned Qwen-0.5B model for generating professional Git commit messages from code diffs.
This model was fine-tuned using LoRA (Low-Rank Adaptation) on the CommitPackFT dataset to generate concise, professional commit messages from git diffs.
Base Model: Qwen-0.5B
Fine-tuning Method: LoRA (r=16, alpha=32)
Training Data: 55K filtered commits from CommitPackFT
Languages: Python, JavaScript, TypeScript, Java, C++, Go, Rust, and more
Generate commit messages for staged changes in a Git repository.
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
# Load model and tokenizer
model_name = "rajtiwariee/auto-commit"
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(model_name, trust_remote_code=True)
# Prepare your diff
diff = """
Diff:
File: src/auth.py
Language: Python
Old content:
def login(username, password):
user = get_user(username)
if user.password == password:
return True
return False
New content:
def login(username, password):
user = get_user(username)
if user and user.password == password:
return True
return False
"""
# Generate commit message
prompt = f"Write a git commit message:\n\n{diff}\n\nCommit message:\n"
inputs = tokenizer(prompt, return_tensors="pt")
with torch.no_grad():
outputs = model.generate(
**inputs,
max_new_tokens=30,
do_sample=False, # Deterministic
pad_token_id=tokenizer.eos_token_id,
)
message = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(message.split("Commit message:")[-1].strip())
# Output: "Check for user existence before accessing password"
For easier usage, install the companion CLI tool from the GitHub repository:
pip install -e .
commit-gen generate --commit
This model is intended to assist developers in writing commit messages, not replace human judgment. Users should:
@misc{git-commit-generator,
author = {Raj Tiwari},
title = {Git Commit Message Generator},
year = {2024},
publisher = {Hugging Face},
howpublished = {\url{https://huggingface.co/rajtiwariee/auto-commit}},
}
MIT License