Sarvam-Translate Full FT — MILPaC Legal Translation Model
Model: Sarvam-Translate, full fine-tuned on MILPaC (legal domain) Architecture: Causal LM (Gemma3-4B-IT based), 4.3B parameters Checkpoint size: ~8.6 GB (bf16) Prepared by: Bharath Chandra Nimmala, NIT Warangal Contact: bharath_jrf_0326@nitw.ac.in, nb26csr1r10@student.nitw.ac.in
MILPaC Dataset: https://github.com/Law-AI/MILPaC
This package contains a fine-tuned translation model plus a standalone
inference script that can be used for integration. Use
translate_batch() from infer_sarvam.py as the primary integration
point.
1. What this model does
Translates English legal text into 9 Indic languages. Fine-tuned specifically on legal-domain text (MILPaC dataset — Acts, CCI_FAQ, IP categories), so it performs best on legal/formal register text, not general conversational text.
Supported languages (pass the exact English name shown):
| Language | Pass as |
|---|---|
| Bengali | "Bengali" |
| Gujarati | "Gujarati" |
| Hindi | "Hindi" |
| Malayalam | "Malayalam" |
| Marathi | "Marathi" |
| Odia | "Odia" |
| Punjabi | "Punjabi" |
| Tamil | "Tamil" |
| Telugu | "Telugu" |
2. Files in this package
| File | Purpose |
|---|---|
infer_sarvam.py | Standalone inference script — load model, translate |
requirements.txt | Pinned dependency versions |
README.md | This file |
| Model checkpoint | Hosted on Hugging Face (see Section 3) |
3. Getting the model
The checkpoint (~8.6 GB) is public on Hugging Face:
Repo: https://huggingface.co/imnbharath/milpac-sarvam-full
No access token needed. Load it directly by repo ID:
from infer_sarvam import load_model
model, tokenizer = load_model("imnbharath/milpac-sarvam-full")
from_pretrained() will download and cache it automatically on first
use. Alternatively, clone it locally:
git clone https://huggingface.co/imnbharath/milpac-sarvam-full
and point --model_path at the local folder.
4. Setup
pip install torch==2.6.0+cu124 --extra-index-url https://download.pytorch.org/whl/cu124
pip install -r requirements.txt
The torch build above is validated on CUDA 12.4. If your environment
uses a different CUDA version, install a matching torch build from
https://pytorch.org/get-started/locally/ instead, and keep
transformers, accelerate, tokenizers, and safetensors at the
versions listed in requirements.txt.
5. Usage
As a Python module (recommended for integration)
from infer_sarvam import load_model, translate, translate_batch
model, tokenizer = load_model("imnbharath/milpac-sarvam-full")
# Single sentence
output = translate(model, tokenizer, "The petitioner filed an appeal.", "Hindi")
# Batch (recommended when translating more than one sentence at a time --
# see Section 7 on reproducibility)
outputs = translate_batch(
model, tokenizer,
["Sentence one.", "Sentence two.", "Sentence three."],
"Telugu"
)
Load the model once and reuse model/tokenizer across calls — do not
reload per request.
From the command line
python3 infer_sarvam.py \
--model_path imnbharath/milpac-sarvam-full \
--text "The petitioner filed an appeal before the High Court." \
--lang Hindi
6. Hardware requirements
Measured on an NVIDIA A100 (bf16):
| GPU memory | |
|---|---|
| After model load | ~8.6 GB |
| Peak during inference (batch of 8) | ~9.7 GB |
A GPU with at least 16 GB VRAM is recommended to leave comfortable
headroom for larger batches or concurrent requests. CPU inference is
technically possible via transformers but will be slow for a 4.3B
model — not recommended for production use.
7. Reproducibility note
Generation is deterministic (do_sample=False, num_beams=4,
max_new_tokens=256, max_length=2048). However, batch composition
affects floating-point (bf16) numerical reduction order on GPU, which
can occasionally shift beam-search decisions at close calls. This
means:
- Outputs will be very close in quality and meaning across runs, but individual translations may not always be byte-identical.
translate_batch()(default entry point, batch of 8 recommended) is the most stable and consistent option for batch translation.- This is expected numerical behavior, not a bug — do not attempt to "fix" it by changing generation settings.
Note on output length: max_new_tokens=256 caps how much text the
model can generate per translation. This is enough for most
sentence-level legal text, but longer paragraphs or documents may get
truncated. If you notice outputs cutting off mid-sentence, increase
MAX_NEW_TOKENS in infer_sarvam.py (e.g. to 512) — this is safe to
change and does not affect translation quality, only the output length
budget.
8. Sample input/output pairs (all 9 languages)
Generated with translate_batch(), single-item batches, for
verification purposes. Use these to confirm your integration is
producing reasonable output before wiring it in.
Bengali SRC: (2) Where it appears to the Tribunal that, in consequence of any decision of a competent Civil Court, any order made under section 9 should be cancelled or varied, it shall cancel the order or, as the case may be, vary the same accordingly. TRANSLATION: (২) যেক্ষেত্রে ট্রাইব্যুনালের নিকট ইহা প্রতীয়মান হইবে যে, কোন উপযুক্ত দেওয়ানী আদালতের কোন সিদ্ধান্তের ফলে, ৯ ধারা অনুযায়ী প্রদত্ত কোন আদেশ বাতিল বা ভিন্নরূপ করিতে হইবে সেক্ষেত্রে, ক্ষেত্রানুযায়ী, আদেশখানি বাতিল করিবেন অথবা উহা ভিন্নরূপ করিবেন।
Gujarati SRC: (f) in respect of any other matter relating to requesting or obtaining access to records under this Act. TRANSLATION: (છ) આ અધિનિયમ હેઠળ રેકર્ડ મેળવવાની અથવા તેના સુધી પહોંચવાની વિનંતી કરવા સંબંધિત બીજી કોઇ બાબતમાં.
Hindi SRC: (4) Any person being a relative of a senior citizen and having sufficient means shall maintain such senior citizen provided he is in possession of the property of such citizen or he would inherit the property of such senior citizen: TRANSLATION: (4) कोई व्यक्ति, ऐसे वरिष्ठ नागरिक का नातेदार है और उसके पास पर्याप्त साधन है तो वह ऐसे वरिष्ठ नागरिक का भरणपोषण करेगा, किन्तु उस समय तक जब तक उस व्यक्ति के कब्जे में ऐसे वरिष्ठ नागरिक की सम्पत्ति है या उसे ऐसी वरिष्ठ नागरिक की सम्पत्ति विरासत में प्राप्त होगी :
Malayalam SRC: 5. Manner of constitution of Agency and conditions of service of members.— TRANSLATION: ഏജൻസി രൂപവൽക്കരിക്കേണ്ട രീതിയും അംഗങ്ങളുടെ സേവന വ്യവസ്ഥകളും.
Marathi SRC: 17. Search of births and deaths register.— TRANSLATION: जन्म-मृत्यु नोंदपुस्तकाचा शोध.
Odia SRC: The State Government may, by notification in the Official Gazette, divide the territory within the State into such registration divisions as it may think fit and prescribe different rules for different registration divisions. TRANSLATION: 3. ରାଜ୍ୟ ସରକାର, ସରକାରୀ ଗେଜେଟରେ ଅଧିସୂଚନା ଦ୍ବାର, ରାଜ୍ୟ ମଧ୍ୟରେ ଥିବା କୌଣସି ଅଞ୍ଚଳକୁ ସେ ଯେପରି ଉଚିତ ମନେ କରିବେ ସେପରି ପଞ୍ଜୀକରଣ ଡିଭିଜନରେ ବିଭକ୍ତ କରିପାରିବେ ଏବଂ ବିଭିନ୍ନ ପଞ୍ଜୀକରଣ ଡିଭିଜନ ନିମନ୍ତେ ବିଭିନ୍ନ ନିୟମ ବିହିତ କରିପାରିବେ ।
Punjabi SRC: 7. Property of bonded labourer to be freed from mortgage, etc.— TRANSLATION: ਬੰਧਤ ਮਜ਼ਦੂਰ ਦੀ ਸੰਪੱਤੀ ਦਾ ਗਿਰਵੀ ਆਦਿ ਤੋਂ ਮੁਕਤ ਹੋਣਾ ।
Tamil SRC: Provided that the Central Government may, if satisfied that it is necessary or expedient in the public interest so to do, by notification in the Official Gazette, add any other spice to the Schedule or omit any spice therefrom. TRANSLATION: வரத்து, மைய அரசு, அவ்வாறு செய்வதில் பொது நலன் கருதி அவ்வாறு செய்வது அவசியம் அல்லது உகந்தது என்று அது திருப்தியடைந்தால், அதிகாரமுறை அரசிதழில் அறிவிக்கை வாயிலாக, மற்ற எந்த நறுமணப்பொருளையும் இணைப்புப்பட்டியலில் சேர்த்துக் கொள்ளலாம் அல்லது அதிலிருந்து எந்த நறுமணப்பொருளையும் நீக்கலாம்.
Telugu SRC: (a) terms and conditions of service of the Chairperson and Members of the State Commission and their salaries and allowances under section 20; TRANSLATION: (ఎ) 20వ పరిచ్ఛేదము క్రింద రాజ్య కమీషను యొక్క ఛైర్ పర్సన్ మరియు సభ్యుల యొక్క సేవా నిబంధనలు మరియు షరతులు మరియు వారి జీతములు మరియు భత్యములు;
9. Known limitations
- Odia: weakest-performing language, due to limited training data (only 295 legal-domain rows available for fine-tuning — no supplementary Odia legal corpus was used). Expect lower translation quality on Odia relative to other languages.
- Context window: this model has a large context window (RoPE-based)
and does not truncate typical legal document lengths. If you are
batching very long documents, be aware
max_length=2048(input tokens) is enforced in this script — texts longer than that will be truncated. IncreaseMAX_LENGTHininfer_sarvam.pyif your documents regularly exceed this, but note this differs from the canonical evaluation setting. - Domain specificity: fine-tuned specifically on legal text. Quality on non-legal/general text is not validated and may be lower than a general-purpose translation model.
10. Questions
Contact Bharath Chandra Nimmala (bharath_jrf_0326@nitw.ac.in) for access issues, questions about the inference recipe, or anything that looks inconsistent with the sample outputs above.