Skip to main content

indian-address-parser

Parse raw, unstructured Indian address strings into 13 structured fields. Two model backends, both downloaded automatically from Hugging Face — this package ships only inference code, no weights:

  • t5 (default) — a full fine-tune of google/flan-t5-small (model card). ~77M params, single download, faster and lighter.
  • qwen — a LoRA adapter on Qwen/Qwen3-0.6B (model card). ~596M params, needs both the adapter and the base model, ~2 points higher mean field accuracy.
Input:  "FLAT NO.32, UTTARA TOWERS, MG ROAD GUWAHATI , Kamrup Unclassified AS 781029"
Output: {"houseNumber": "FLAT NO.32", "houseName": "UTTARA TOWERS", "poi": null,
         "street": "MG ROAD", "subsubLocality": null, "subLocality": null, "locality": null,
         "village": null, "subDistrict": null, "district": "Kamrup", "city": "GUWAHATI",
         "state": "AS", "pincode": "781029"}

Install

pip install indian-address-parser

Usage

Python

from indian_address_parser import AddressParser

parser = AddressParser()  # default backend "t5" — downloads model weights from HF on first use
result = parser.parse("FLAT NO.32, UTTARA TOWERS, MG ROAD GUWAHATI , Kamrup Unclassified AS 781029")
print(result)

# Batch
results = parser.parse_batch([addr1, addr2, addr3])

# Larger, more accurate model
parser = AddressParser(backend="qwen")

CLI

# Single address (defaults to the t5 backend)
indian-address-parser "FLAT NO.32, UTTARA TOWERS, MG ROAD GUWAHATI , Kamrup Unclassified AS 781029"

# Batch from stdin
cat addresses.txt | indian-address-parser --stdin

# Batch from a file, JSONL output
indian-address-parser --file addresses.txt --out results.jsonl

# Larger, more accurate model
indian-address-parser --backend qwen "..."

Fields

houseNumber, houseName, poi, street, subsubLocality, subLocality,
locality, village, subDistrict, district, city, state, pincode

Any field not present in the address is null. If the model output can't be parsed as JSON, all fields are null and a _parse_error key holds the raw model output.

Choosing a backend

t5 (default) qwen
Base model google/flan-t5-small Qwen/Qwen3-0.6B + LoRA
Params ~77M ~596M
Download single model adapter + base model
Mean field accuracy (held-out test) 80.6% 82.4%
JSON parse rate 100% 100%

t5 is the better default for most uses — it's smaller, faster, and CPU-friendly with a small accuracy trade-off. Reach for qwen when the extra couple of points matter more than latency or footprint (its edge is largest on the lower-recall fields like poi, subDistrict, subLocality).

Model details, evaluation metrics, and known limitations

See the model cards for training data, config, full per-field evaluation results, and known limitations (locality/subLocality/subsubLocality/village field-boundary ambiguity, etc.):

Datasets

Comparison to other models

benchmarks/ has a head-to-head comparison against Shiprocket's open-tinybert-indian-address-ner on a 237-example held-out gold test set (using the qwen backend). Summary: this model scores higher on every one of the 9 conceptually-shared fields (sometimes by a wide margin — e.g. city 91.3% vs 17.4%, pincode 100% vs 69.2%), while Shiprocket's 6-layer TinyBERT is ~240x faster per address. See benchmarks/README.md for the full field-by-field results and methodology (the two models use different field taxonomies, so only overlapping fields are scored).

Apple Silicon (MLX) users

This package uses transformers (+peft for the qwen backend), which works on CUDA, MPS, and CPU but is not the fastest path on Apple Silicon. For MLX-native inference of the qwen backend, see the mlx/ subfolder of its Hugging Face repo instead.

License

Apache 2.0 (matching the base models, google/flan-t5-small and Qwen/Qwen3-0.6B).

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

indian_address_parser-0.2.0.tar.gz (60.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

indian_address_parser-0.2.0-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

File details

Details for the file indian_address_parser-0.2.0.tar.gz.

File metadata

  • Download URL: indian_address_parser-0.2.0.tar.gz
  • Upload date:
  • Size: 60.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for indian_address_parser-0.2.0.tar.gz
Algorithm Hash digest
SHA256 6288c1bad37780df63f80a929c1c62f50ecb390d6ef15007d4ef59a6710cbc5a
MD5 b002f126d60f7f3b0381330ea9a76233
BLAKE2b-256 4c245f4a45bc4a75a39721461ab82d845190f13385723cbbcb2c15a9044bcef7

See more details on using hashes here.

File details

Details for the file indian_address_parser-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for indian_address_parser-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9a5e4f32bb0c534872d09081752ca90d0f1f56d6ba34a96569085457c5f4847d
MD5 e7bd4c0c1f8bff1d5e6f012f17892a76
BLAKE2b-256 40027421cd6b38fcf720a88d09caace610890e3151d2d6c8b10eed3177ea2b7b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page