Downloads · 30 days
10
22% of all-time downloads
SatyamGhosh/qlora-legal-clause-extractor
qlora-legal-clause-extractor is a machine learning model from SatyamGhosh. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for peft.
LoRA adapter fine-tuned on top of Qwen/Qwen2.5-3B-Instruct (4-bit QLoRA) to convert real legal contract clauses into structured JSON: clausetype, risklevel, obligatedparty, haspenalty, summary.
Downloads · 30 days
10
22% of all-time downloads
All-time downloads
45
Public
Repo size
131 MB
Likes
0
Public
Click a slice to open those files.
.safetensors59.9 MB · 84%
From the Hugging Face model README
LoRA adapter fine-tuned on top of Qwen/Qwen2.5-3B-Instruct (4-bit QLoRA) to convert real legal
contract clauses into structured JSON: clause_type, risk_level, obligated_party,
has_penalty, summary.
Clause text is real, sourced from CUAD (Contract Understanding Atticus Dataset,
Hendrycks et al., NeurIPS 2021, CC-BY-4.0) -- 333 real clauses sampled across CUAD's
original 41 categories. Structured labels (risk level, obligated party, penalty flag,
summary) were generated with an LLM-assisted labeling pipeline (llama-3.1-8b-instant)
and spot-checked by hand.
| Metric | Baseline (zero-shot) | Fine-tuned (this adapter) |
|---|---|---|
| JSON validity | 61.2% | 100.0% |
| Field accuracy | 33.9% | 66.5% |
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
from peft import PeftModel
import torch
bnb_config = BitsAndBytesConfig(load_in_4bit=True, bnb_4bit_quant_type="nf4",
bnb_4bit_compute_dtype=torch.bfloat16)
base = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-3B-Instruct", quantization_config=bnb_config, device_map="auto")
model = PeftModel.from_pretrained(base, "SatyamGhosh/qlora-legal-clause-extractor")
tokenizer = AutoTokenizer.from_pretrained("SatyamGhosh/qlora-legal-clause-extractor")