the goal

convert natural language prompts into complete, legally-sound indian contract documents. a user describes what they need -- "draft an employment agreement for a software engineer in bangalore with a 90-day notice period and non-compete clause" -- and the model produces a full contract with proper legal structure, indian law references, and enforceable clauses.

the constraint: it has to run on consumer hardware. no cloud apis, no 70b parameter models, no a100 clusters. a single gpu that someone might actually own.

base model and approach

the base model is llama-3.2-1b-instruct. at 1 billion parameters, it is small enough to run on a laptop gpu but capable enough to follow complex instructions when fine-tuned on a specific domain. the instruct variant already understands conversational formatting, which gives us a head start on the input/output structure.

fine-tuning uses lora (low-rank adaptation), which only adjusts a small subset of the model's parameters. specifically, the adapter targets the attention projection layers: q_proj, k_proj, v_proj, and o_proj. this keeps the vast majority of the model frozen while teaching it the specific patterns of legal contract drafting. combined with 4-bit quantization via the unsloth library, the entire training process fits comfortably in consumer-grade vram.

dataset generation

there is no public dataset of indian legal contracts paired with natural language descriptions. so the dataset was generated synthetically using a local ollama endpoint running deepseek-r1:14b. the generation process produced hundreds of contract templates spanning common agreement types: employment agreements, confidentiality agreements, service contracts, lease agreements, partnership deeds, and more.

each training example is structured as a conversational exchange. the user provides a natural language description of the contract they need. the model first explains its legal reasoning in a chain-of-thought format -- which jurisdiction applies, which clauses are standard, which specific provisions the user's requirements demand -- and then generates the final contract document. this two-stage output teaches the model to think before drafting, which produces more coherent and legally consistent documents.

training details

training used small batch sizes with gradient accumulation to simulate larger effective batches on limited hardware. the optimizer was adamw 8-bit, which halves optimizer memory compared to standard adamw. training ran for 40 steps -- deliberately short to prevent overfitting on the synthetic dataset while still teaching the model the core patterns of contract structure and legal language.

the unsloth library handles the 4-bit quantization and lora integration, making the training loop straightforward. the entire fine-tuning process completes in minutes on a single consumer gpu. the resulting adapter weights are small (a few hundred megabytes) and can be merged back into the base model or loaded dynamically at inference time.

results

the fine-tuned model generates structurally complete contracts with proper clause numbering, indian legal terminology, and jurisdiction-appropriate references. it handles the standard sections -- definitions, scope, obligations, termination, dispute resolution, governing law -- and adapts them to the specific contract type requested. the chain-of-thought reasoning stage helps it make coherent decisions about which clauses to include and how to parameterize them based on the user's description.

the model is not a replacement for a lawyer. it is a drafting assistant that produces a solid first draft requiring human review. but the practical value is real: generating a reasonable first draft in seconds instead of hours, on hardware that costs a few hundred dollars instead of cloud api bills.

artifacts

  • model: axondendriteplus/contract_drafter-Llama-3.2-1B-Instruct on huggingface
  • code: adw777/contract_drafter on github

key insight

you do not need 70b models for domain-specific tasks. specialized fine-tuning on a 1b parameter model, using synthetically generated training data and parameter-efficient techniques, produces genuinely useful output for a narrow domain. the combination of lora, 4-bit quantization, and synthetic data generation makes legal document drafting accessible on modest hardware. the bottleneck is data quality and domain expertise, not compute.