Views
No views yet
title (≤ 65 chars) and up to 3 bullets, so your CLI/agents can parse it deterministically.git diff patches into concise, Conventional Commit–compliant titles with optional bullets.{"title": "...", "bullets": ["...", "..."]}.unsloth/LFM2-350M-unsloth-bnb-4bit (4-bit quantized base, trained with QLoRA)ethanke/lfm2_350m_commit_diff_summarizer1from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
2from peft import PeftModel
3import torch, json
4
5BASE = "unsloth/LFM2-350M-unsloth-bnb-4bit"
6ADAPTER = "ethanke/lfm2_350m_commit_diff_summarizer" # replace with your repo id
7
8bnb = BitsAndBytesConfig(load_in_4bit=True, bnb_4bit_quant_type="nf4",
9 bnb_4bit_use_double_quant=True, bnb_4bit_compute_dtype=torch.float16)
10
11tok = AutoTokenizer.from_pretrained(BASE, use_fast=True)
12mdl = AutoModelForCausalLM.from_pretrained(BASE, quantization_config=bnb, device_map="auto")
13mdl = PeftModel.from_pretrained(mdl, ADAPTER)
14
15diff = "...your git diff text..."
16prompt = (
17 "You are a commit message summarizer.\n"
18 "Return a concise JSON object with fields 'title' (<=65 chars) and 'bullets' (0-3 items).\n"
19 "Follow the Conventional Commit style for the title.\n\n"
20 "### DIFF\n" + diff + "\n\n### OUTPUT JSON\n"
21)
22
23inputs = tok(prompt, return_tensors="pt").to(mdl.device)
24with torch.no_grad():
25 out = mdl.generate(**inputs, max_new_tokens=200, do_sample=False)
26text = tok.decode(out[0], skip_special_tokens=True)
27
28# naive JSON extraction
29js = text[text.rfind("{"): text.rfind("}")+1]
30obj = json.loads(js)
31print(obj)Maxscha/commitbench (diff → commit message).^(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)(\([^)]+\))?(!)?:\s.+$SFTTrainer + QLoRA (PEFT).### DIFF + ### OUTPUT JSON target (title/bullets).max_length=2048, per_device_train_batch_size=2, grad_accum=4lr=2e-4, scheduler=cosine, warmup_ratio=0.03epochs=1 over capped subsetr=16, alpha=32, dropout=0.05, targets: q/k/v/o + MLP projeval_loss ≈ 1.18 → perplexity ≈ 3.26eval_mean_token_accuracy ≈ 0.77transformers, trl, peft, bitsandbytes, datasets, unslothethanke on Hugging Face.