Instructions to use balrampandey/indian-tax-law-slm-base with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use balrampandey/indian-tax-law-slm-base with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="balrampandey/indian-tax-law-slm-base")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("balrampandey/indian-tax-law-slm-base") model = AutoModelForCausalLM.from_pretrained("balrampandey/indian-tax-law-slm-base", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use balrampandey/indian-tax-law-slm-base with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "balrampandey/indian-tax-law-slm-base" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "balrampandey/indian-tax-law-slm-base", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/balrampandey/indian-tax-law-slm-base
- SGLang
How to use balrampandey/indian-tax-law-slm-base with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "balrampandey/indian-tax-law-slm-base" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "balrampandey/indian-tax-law-slm-base", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "balrampandey/indian-tax-law-slm-base" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "balrampandey/indian-tax-law-slm-base", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use balrampandey/indian-tax-law-slm-base with Docker Model Runner:
docker model run hf.co/balrampandey/indian-tax-law-slm-base
indian-tax-law-slm-base
indian-tax-law-slm-base is a domain-specialized language model for Indian legal and tax text, trained from scratch on a curated corpus of statutes, judgments, and legal documents. It is the first release in an ongoing series of increasingly capable open models targeting the Indian legal domain.
This initial model is a compact 31.8M-parameter base checkpoint that demonstrates strong, measurable domain specialization. Larger models β with substantially improved fluency and retrieval-grounded factual accuracy β are actively in development.
Highlights
- π― Purpose-built for Indian legal & tax language β statutes, case law, and procedure
- π 10.6Γ stronger on legal text than on general English (perplexity: 40.7 vs 431.7)
- π§± Standard Llama architecture β loads with
AutoModelForCausalLM, no custom code - π§ Fine-tuning ready β clean base for LoRA/PEFT adaptation to specific legal tasks
- πͺΆ Custom 16K tokenizer trained on the domain for efficient legal text encoding
- π Fully open β Apache-2.0, permissively-licensed training data
Model Summary
| Architecture | LlamaForCausalLM (grouped-query attention, RoPE, SwiGLU) |
| Parameters | 31.8M |
| Layers | 8 |
| Hidden size | 512 |
| Attention heads | 8 (4 KV heads) |
| Context length | 512 tokens |
| Vocabulary | 16,000 (custom byte-level BPE) |
| Precision | fp16 |
| Corpus | ~430M tokens, ~68% Indian legal by weight |
Evaluation
Held-out perplexity (lower = better):
| Domain | Perplexity |
|---|---|
| Indian legal | 40.7 |
| General English | 431.7 |
The model is 10.6Γ more confident on Indian legal text than on general text β clear, quantitative evidence of domain specialization. This is the intended behavior of a domain base model: it internalizes the vocabulary, structure, and register of Indian statutory and case law.
Try it live
An interactive demo is available as a Hugging Face Space:
Usage
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained("balrampandey/indian-tax-law-slm-base")
tok = AutoTokenizer.from_pretrained("balrampandey/indian-tax-law-slm-base")
ids = tok("The assessee", return_tensors="pt")
out = model.generate(**ids, max_new_tokens=40, repetition_penalty=1.3)
print(tok.decode(out[0], skip_special_tokens=True))
Fine-tuning
The model is designed as a base for adaptation. Attach a LoRA adapter with peft:
from peft import LoraConfig, get_peft_model
model = get_peft_model(model, LoraConfig(
task_type="CAUSAL_LM", r=8, lora_alpha=16,
target_modules=["q_proj", "k_proj", "v_proj", "o_proj"],
))
Training Data
A curated mix of general English (for language competence) and open Indian legal text (for domain specialization):
| Source | Content | Licence |
|---|---|---|
| allenai/c4 | General English | ODC-By |
| KanoonGPT/indian-legal-documents | Legal documents | Apache-2.0 |
| KanoonGPT/indian-case-laws | Case law | Apache-2.0 |
| 169Pi/indian_law | Legal Q&A / reasoning | Apache-2.0 |
| vihaannnn/Indian-Supreme-Court-Judgements-Chunked | SC judgments | MIT |
| varshith7/income-tax-act-india | Income Tax Act | CC-BY-4.0 |
The underlying text of Acts and judgments is exempt from copyright under s.52(1)(q) of the Indian Copyright Act; dataset compilations retain the licences above.
Intended Use
- A base model for fine-tuning on Indian legal and tax tasks (LoRA/PEFT)
- Research on domain-specialized language modeling
- A foundation for the larger models in this series
As an early, compact checkpoint, generation fluency is limited and outputs should not be treated as authoritative legal or tax information. Factual grounding via retrieval is planned for larger releases.
Roadmap
This model is the first step in a staged program:
- β v0 β 32M base (this release) β validated pipeline, measurable specialization
- π In progress β larger base models β improved fluency and coherence at greater scale
- π Planned β retrieval-augmented variants β factual grounding on live statutory text
- π Planned β instruction-tuned releases β task-ready models for legal workflows
License
Apache-2.0 (code and weights).
- Downloads last month
- 65