gemma3_4b_deedexp_v8
This model reads the OCR text of a Karnataka property registration document (Kannada + English) and returns one JSON record: the buyers, the sellers, property details and document details.
It is a fine-tune of Gemma 3 4B-it, trained in three stages:
- domain-adaptive pre-training on registered-document text;
- an instruction "bridge" stage that teaches what the document wording means (roles, IDs, dates);
- supervised extraction training.
Status: v8 candidate, for testing. Feedback and failure cases are welcome. Contact: kamananand98@gmail.com.
Output schema
{
"buyer_details": [{"name", "gender": "Male|Female|null", "father_name", "aadhaar_number", "pan_card_number", "address", "state"}],
"seller_details": [ ...same fields... ],
"property_details": {"schedule_c_property_address", "state", "sale_consideration", "registration_fee", "paid_in_cash": "yes|no"},
"document_details": {"transaction_date": "YYYY-MM-DD", "registration_office"}
}
Main rules the model was trained on. The full list is in prompts/single_full.txt.
- Roles come from what the document says each party does (sells or receives), not from the order they are printed in. Confirming and consenting parties are never sellers.
transaction_date= the document's registration date from the Sub-Registrar endorsement, not the execution date.- IDs are copied only for the person they are printed for. Invalid, masked or partial IDs →
null. IDs are never repaired. - Missing or unreadable →
null. The model is trained to leave a value out rather than guess it.
How to call
One request per document: a single user message = the prompt text + "\n\n" + the document's OCR text.
Use greedy decoding and up to 5,000 new tokens.
| prompt file | status |
|---|---|
prompts/single_full.txt | default. The short rule set, used for every number on this card. |
prompts/single_full_medium.txt | alternative. The same rules explained in more detail. It tied the default on a 9-document check (one registration-fee miss). Try it if the default misses something on your documents. |
Both prompts are part of the training data. Use them exactly as written: the model was trained on that text, so edited prompts can lower accuracy. A longer prompt variant was also trained, but it scored lower in our checks (it once swapped buyers and sellers), so it is not shipped.
pip install "transformers>=4.50" torch accelerate
python inference.py document_ocr.txt # default prompt
python inference.py document_ocr.txt --prompt medium # alternative prompt
Use the tokenizer's chat template as provided. It already starts with <bos>, so do not add a second one.
Training inputs were up to 20,480 tokens (prompt + OCR + answer).
Evaluation (preliminary)
The test set is 78 held-out documents from many Sub-Registrar offices. Each document got one single-shot prompt (style rotated). Scores are F1 or exact match, in %:
| field | score |
|---|---|
| transaction_date | 98.1 |
| registration_fee | 98.1 |
| aadhaar_number | 97.2 |
| sale_consideration | 96.8 |
| paid_in_cash | 96.8 |
| registration_office | 96.8 |
| buyer count exact | 93.6 |
| pan_card_number | 92.5 |
| names | 92.4 |
| father_name | 89.0 |
| seller count exact | 87.2 |
| valid JSON | 77 / 78 |
Known weak spots: long party lists (10+ sellers), where the model can stop the list early, and minors who sell through a guardian, who are sometimes left out.
Limitations and responsible use
- The model works on OCR text, so OCR errors in IDs or names carry through. Always check extracted IDs against the document.
- It was trained on Karnataka property transfer documents. Other document types (agreements, mortgages, partitions) and other states are out of scope.
- The training documents contain personal data. Use the model only on documents you are authorised to process, and do not use it to look up or reconstruct information about individuals.
License
This model is a derivative of Gemma 3 and is distributed under the Gemma Terms of Use. Use is subject to the Gemma Prohibited Use Policy.