gcw_6a3w2yXz/vn-address-normalizer-npu-model
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

Vietnamese Address Normalizer - NPU Adaptation

Model Overview

Seq2Seq Transformer model for normalizing Vietnamese address strings to canonical post-2025 administrative form. Uses province-constrained beam search over 187K clean canonical addresses.

  • Architecture: Custom Seq2Seq Transformer (Encoder-Decoder)
  • Parameters: 6.59M
  • Encoder: 4-layer, 256-dim, 4-head, GELU, Pre-LN
  • Decoder: 3-layer, same config
  • Input: Character-level tokenization (287-token vocab)
  • Output: Character-level decoding (269-token vocab)
  • Task: Vietnamese address normalization (seq2seq)

NPU Adaptation

This model has been adapted to run on Ascend NPU (Ascend910B). Key adaptations:

  1. Model loaded and moved to npu:0
  2. Input tensors explicitly created on NPU device
  3. All inference runs on NPU with device proof logging
  4. Province-constrained beam search with trie filtering

Device Proof

Model device: npu:0
input_ids device: npu:0
encoder output device: npu:0

Quick Start

pip install -r requirements.txt
python inference.py "p tan dinh q1 tphcm"

Usage

CLI

python inference.py "p tan dinh q1 tphcm"

Python API

from inference import normalize

result = normalize("p tan dinh q1 tphcm")
print(result["canonical"])  # "Phường Tân Định, Thành phố Hồ Chí Minh"
print(result["valid"])      # True

Performance

MetricValue
Model parameters6.59M
Inference latency~1000-1500ms (NPU, warm)
Search space170-699 candidates

Evidence

Agent Workflow NPU Device Call Model Result

Requirements

  • Python 3.8+
  • PyTorch >= 1.13.0
  • torch_npu (for Ascend NPU)
  • safetensors >= 0.3.0
  • unidecode >= 1.3.0

License

MIT