Telugu property-document extraction β€” Gemma 3 12B QLoRA (v2, multi-state)

A LoRA adapter for Gemma 3 12B Instruct that reads the OCR of a Telugu-language property document and returns one JSON object: the parties and their identifiers, the property, the amounts and the registration details.

Sibling of the Kannada model anandkaman/gemma3_12b_deedexp.

v2 is a breaking change β€” read this before upgrading

v1 (2026-11-06) covered Andhra Pradesh only, and its card said in so many words that this was not a multi-state model. v2 reverses that. One model now covers both Andhra Pradesh and Telangana, because the two document families express the same intentions in different layouts, and a model that reads the meaning rather than the form should handle both.

Two things changed that will break existing callers:

  1. The prompts are different. All three PROMPT_*.txt files were replaced. The task sentence now names both states, and the rules block defines roles and fees by meaning instead of by AP's EX/CL/WT endorsement codes and RF/SD fee-table rows β€” none of which exist in a Telangana document. If you keep sending v1's prompt text to v2, you are using a prompt this adapter was never trained on. Re-download the three files.
  2. The fee rule is stricter. v1's rules named the AP fee-table rows to read. v2's say every fee is copied from the figure printed for it and never calculated β€” not from the consideration, not from a rate, not from another fee. Registration fee happens to be 0.5 % of consideration in much of this corpus; the model is deliberately not taught that, because rates differ by state and change by year. Where only one combined amount is printed, the individual fees are null.

Measured accuracy

The two document families are scored separately and never averaged, so that a gain on one cannot mask a regression on the other.

Andhra Pradesh β€” 11 held-out documents (the regression guard)

The same 11 documents and the same labels used to score v1, so these columns are comparable.

v1 (AP-only) v2 (multi-state)
buyer/seller role swaps 0 0
buyer count exact 11/11 11/11
seller count exact 11/11 11/11
sale consideration exact 11/11 11/11
registration date exact 11/11 11/11
registration office exact 11/11 11/11
state exact 11/11 11/11
stamp duty exact 9/11 11/11
registration fee exact 9/11 11/11
party names recovered 24/32 25/32
output failed to parse as JSON 0/11 0/11
pincode exact 0/5 0/5
schedule address exact 0/11 0/11

No field regressed. Both fee fields went to 11/11, which is the clearest evidence that the meaning-based fee rule is an improvement and not merely a reword: the fields it governs are the fields that moved.

Telangana β€” 5 held-out documents, parties only

result
buyer/seller role swaps 0 β€” but see the caveat below
buyer count exact 5/5
seller count exact 5/5
party names recovered 8/17
output failed to parse as JSON 0/5

The role-swap figure is weaker than it looks. Swaps are detected by intersecting predicted names with gold names. On 3 of these 5 documents the gold names are in Telugu script and the model answered in Latin, so the intersection is empty and no swap can be detected either way. The honest reading is 0 swaps across 2 documents where the metric can see, and unmeasured on the other 3. Read party names recovered: 8/17 as the figure that is not inflated by this.

Telangana rows are parties-only on purpose. A training label must never assert null for a field the document does carry β€” that teaches the model to drop it. The party roles were verified against each document's own payment challan; the property, amounts and registration details were not verified line by line, and the first date in these documents is usually a recital date from a prior transaction rather than the registration date. So the Telangana half of the corpus teaches the half that was verified, and the fee and date reasoning is carried by the phase-2 question/answer stage instead. Subset-schema training lifts full-schema accuracy as well as enabling the short form, so this is not a loss β€” but it does mean the Telangana property and amount fields are not independently measured here.

Read the limits with the numbers

  • n = 11 and n = 5, against the Kannada model's 60. These are also the harder documents by construction β€” held out for length, and length tracks party count.
  • 6 of the 11 AP prompts and 1 of the 5 Telangana prompts still exceed the training window, so part of the OCR is truncated at generation and the model still recovers the fields above.
  • Telangana coverage is partial: 18 of 57 available documents are labelled (13 trained, 5 held out). The unlabelled remainder are from a sub-registrar office whose buyer marker the OCR mangles differently in nearly every file, so they were left out rather than labelled by guesswork.
  • Two fields score 0 and are not model weaknesses. pincode and the schedule address have an unsettled labelling convention in the source register β€” the pincode values trace to an architect's letterhead, a sub-registrar's address and a tax receipt, among others β€” so neither can be scored until the convention is fixed. Both scored 0 identically in v1, so nothing regressed. The address field recovers roughly 0.4 of the gold's tokens while scoring 0 on exact match.
  • Output script is not yet normalised. The AP training labels are Latin-script names, the Telangana labels are Telugu-script, and only 6 of 18 Telangana documents carry an English roster to transliterate from. The model therefore answers in whichever script the document leans toward. If you need one script, normalise downstream.

Prompts β€” full and subset

Three prompts are trained. All three use the same rules block; they differ in one sentence naming the schema to return. They are published byte-identical to the strings that were trained.

file returns trained on
PROMPT_full.txt everything: parties, property, document details 49 rows
PROMPT_subset_1.txt parties only β€” buyer, seller, confirming party 17 rows
PROMPT_subset_2.txt property and registration details only 7 rows

Where the saving is. The subset prompts are not shorter on input β€” they are ~63 characters longer. The saving is in the output: a subset answer averages 568 characters against 1017 for the full schema, 56 % of the size. Because decoding is sequential, that is a meaningfully faster call when you only need one half of the record. It is not a way to shorten the input.

33 % of the training rows are subset-schema variants (up from 18 % in v1), which lifts per-field accuracy on the full schema rather than only enabling the short form.

Use

from unsloth import FastLanguageModel
from unsloth.chat_templates import get_chat_template

model, tok = FastLanguageModel.from_pretrained(
    "anandkaman/gemma3_12b_deedexp_te", max_seq_length=11264, load_in_4bit=True)
FastLanguageModel.for_inference(model)
tok = get_chat_template(tok, chat_template="gemma-3")

rules  = open("PROMPT_full.txt").read()          # or PROMPT_subset_1.txt / _2.txt
prompt = rules + "\n\nOCR:\n" + ocr_text

text = tok.apply_chat_template(
    [{"role": "user", "content": [{"type": "text", "text": prompt}]}],
    tokenize=False, add_generation_prompt=True)
ids = tok(text, return_tensors="pt", add_special_tokens=False).input_ids.to("cuda")
out = model.generate(input_ids=ids, max_new_tokens=2600, do_sample=False)
print(tok.decode(out[0][ids.shape[1]:], skip_special_tokens=True))

Greedy decoding. Trained at max_seq_length=11264; longer OCR should be cut from the middle, keeping the instruction block and the start and end of the document.

Runs in about 11.4 GB of VRAM in 4-bit.

Design rules it was trained to follow

  • Roles come from what a party does, never from where it appears on the page or from one state's form layout. A document states this in whatever words it uses β€” Telugu or English, in the body, an endorsement or a payment challan.
  • A witness is never a party, and a power-of-attorney holder is not a party either.
  • People named in recited earlier transactions are not parties to this sale.
  • Every fee is copied from the printed figure, never derived. A fee block is often printed twice side by side and OCR can interleave the copies; trust the copy whose amounts add up to the stated total.
  • Missing data is acceptable; invented data is a critical error. Any field the document does not carry is null. A malformed identifier is null rather than a guess.

Base model, quantization and merging

Read MERGE.md before merging. The essentials:

base unsloth/gemma-3-12b-it-bnb-4bit β€” bitsandbytes NF4, double quant, bf16 compute. Not the dynamic -unsloth-bnb-4bit variant
identity re-verified for this release: all 16 base files match the Hub repo's sizes, both shards included
adapter plain LoRA, r=16, alpha=32 β†’ merge scaling 2.0; no DoRA / rsLoRA / QALoRA, no modules_to_save
adapted 417 modules = 336 text (48 layers x 7 projections) + 81 vision (27 SigLIP layers x q/k/v) β€” unchanged from v1
merge target bf16 unsloth/gemma-3-12b-it (google/gemma-3-12b-it is gated)
lineage three phases, each loading the previous phase's weights into a fresh same-rank LoRA. This adapter is self-contained β€” there is no second adapter to stack

Three things that will bite you, all covered in MERGE.md:

  1. Attach to Gemma3ForConditionalGeneration, not the text-only class. 81 of the 417 adapted modules are in the SigLIP vision tower, matched by name. A text-only load leaves them unresolved.
  2. Key layout. The adapter was saved from the model.language_model.layers.* module tree; the Hub checkpoints still use language_model.model.layers.* on disk. Verified 417/417 resolved on transformers 5.5.0; run check_adapter_keys.py on your own stack first β€” it builds the model on the meta device, so it costs no download and no GPU.
  3. A bf16 merge is not the model that was evaluated. The accuracy tables above were measured with this adapter on the 4-bit base. The LoRA was fitted against NF4-dequantized weights, so merging into bf16 is the standard QLoRA path but not numerically identical β€” re-score after merging. For exactly the evaluated model, do not merge: attach the adapter to the 4-bit base.

Two scripts ship here: check_adapter_keys.py (seconds, no weights) and merge_lora_streaming.py, which merges shard by shard so it runs on a 16 GB machine, refuses an ambiguous key mapping, and spot-checks the arithmetic afterwards.

Training

QLoRA (rank 16, alpha 32) on unsloth/gemma-3-12b-it-bnb-4bit, built on a Telugu-adapted base.

phase data config final loss
2 β€” question/answer 69 rows, AP + Telangana max_seq 2048, 4 epochs, 36 steps, lr 1e-4 1.465
3 — document→JSON SFT 73 rows from 62 documents (49 AP + 13 Telangana) max_seq 11264, 5 epochs, 50 steps, lr 2e-4 0.8071

Phase 3: batch 1 x grad-accum 8, cosine schedule, warmup_ratio 0.03, weight_decay 0.01, adamw_8bit, seed 42, packing=False, bf16, unsloth offloading gradient checkpointing, 1.84 h on one 15.478 GiB RTX 5060 Ti at a 14.6 GiB device peak. Stack: unsloth 2026.5.2 / torch 2.10.0 / transformers 5.5.0 / trl 0.24.0 / peft 0.19.1 / bitsandbytes 0.49.2.

Labels are derived from each document's own registration endorsement or payment challan rather than from the accompanying register β€” which, on the AP half, corrected 11 buyer/seller role swaps and removed 5 identifying witnesses that a register-derived label set had recorded as parties. On the Telangana half the register was not used at all.

Privacy

No document text, identifier or party name is published here β€” only the adapter, the tokenizer, the three rules prompts, the merge documentation and this card. Scanned for Aadhaar-shaped digit runs, PAN patterns and Telugu text outside the prompt files: clean.

Contact: kamananand98@gmail.com

Downloads last month
35
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for anandkaman/gemma3_12b_deedexp_te

Adapter
(9)
this model