--- license: apache-2.0 language: - vi base_model: vinai/phobert-base library_name: transformers pipeline_tag: token-classification tags: - ner - vietnamese - address-parsing - phobert metrics: - precision - recall - f1 model-index: - name: bert_all results: - task: type: token-classification name: Vietnamese Address NER metrics: - type: f1 value: 0.8212719298245614 - type: precision value: 0.7741602067183463 - type: recall value: 0.8744892002335085 --- # bert_all Fine-tuned PhoBERT for **Vietnamese address Named Entity Recognition**. Extracts structured fields from free-form Vietnamese addresses (place name, house number, street, ward, district, city). **Source artefact**: `bert_all` **Base model**: `vinai/phobert-base` **Trained on**: Vietnamese address corpus (mixed sources) **Saved at**: `2026-06-06T12:29:40.098669+00:00` ## Metrics | Metric | Value | |-----------|-----------| | Precision | **0.7742** | | Recall | **0.8745** | | F1 | **0.8213** | ## Labels - `` - `B-CITY` - `B-DISTRICT` - `B-HOUSE_NUMBER` - `B-PLACE_NAME` - `B-STREET` - `B-WARD` - `I-CITY` - `I-DISTRICT` - `I-HOUSE_NUMBER` - `I-PLACE_NAME` - `I-STREET` - `I-WARD` - `O` ## Quickstart ```python from transformers import pipeline ner = pipeline("token-classification", model="open-thienhang-com/bert_all", aggregation_strategy="simple") ner("123 Nguyễn Huệ, Phường Bến Nghé, Quận 1, TP Hồ Chí Minh") # → [ # {'entity_group': 'HOUSE_NUMBER', 'word': '123', ...}, # {'entity_group': 'STREET', 'word': 'Nguyễn Huệ', ...}, # {'entity_group': 'WARD', 'word': 'Phường Bến Nghé', ...}, # {'entity_group': 'DISTRICT', 'word': 'Quận 1', ...}, # {'entity_group': 'CITY', 'word': 'TP Hồ Chí Minh', ...}, # ] ``` Or manual: ```python from transformers import AutoTokenizer, AutoModelForTokenClassification import torch tokenizer = AutoTokenizer.from_pretrained("open-thienhang-com/bert_all") model = AutoModelForTokenClassification.from_pretrained("open-thienhang-com/bert_all").eval() inputs = tokenizer("123 Nguyễn Huệ, Phường Bến Nghé, Quận 1, TP HCM", return_tensors="pt", truncation=True, max_length=256) with torch.no_grad(): out = model(**inputs).logits pred_ids = out.argmax(-1)[0].tolist() labels = [model.config.id2label[i] for i in pred_ids] tokens = tokenizer.convert_ids_to_tokens(inputs.input_ids[0]) for t, l in zip(tokens, labels): if l != "O" and l != "": print(f" {t:20s} → {l}") ``` ## Limitations - Trained on Vietnamese addresses ONLY — won't generalise to free-form Vietnamese text or addresses from other countries. - Uses syllable-level input (no `vncorenlp` word segmentation required). - Class imbalance: `PLACE_NAME` is the rarest label, so its precision is lower than CITY / WARD. ## Citation If you use this model, please credit the base model and dataset sources: ```bibtex @misc{phobert, title = {PhoBERT: Pre-trained language models for Vietnamese}, author = {Dat Quoc Nguyen and Anh Tuan Nguyen}, year = {2020} } ```