ViExtract-EC 0.5B

A small Vietnamese model that fills a caller-supplied JSON frame from a raw chat log. It is middleware for a larger agent: no explanation, no reasoning, one JSON object out.

{"customer": {"name": null, "phone": null},
 "items": [{"name": null, "qty": null, "price": null}],
 "notes": null}

becomes

{"customer": {"name": "Trang", "phone": "0987 654 321"},
 "items": [{"name": "รกo sฦก mi trแบฏng size L", "qty": "1 cรกi", "price": "250k"}],
 "notes": "giao trฦฐแป›c 5h chiแปu"}

The point is schema-agnostic extraction: the same fact must be found whether the caller names the key customer_name, ten_khach_hang, tรชn_khรกch_hร ng, customerName or buyer_info, and whether the value sits at the top level, inside an object, or inside an array.

Contract

The frame itself declares the shape, so no type wrappers are needed:

frame node meaning when absent
null scalar string return null
{...} nested object fill each leaf independently
[{...}] array of objects (one prototype element) return []
  • Values are verbatim substrings of the chat. No normalisation: "50k" stays "50k", "chiรน" stays "chiรน" even though it is a typo.
  • Missing information is null (or [] for arrays), never "".
  • No type coercion, no date resolution. "nฤƒm chแปฅc" is a valid value; converting it is the caller's job.
  • Arrays keep chat order, one element per distinct item. Duplicates are not allowed.
  • When a value is corrected mid-conversation, the latest agreed value is returned.

This makes every output verifiable: if a returned string is not in the chat, it is wrong. Enable the serving-side check (VIEXT_VERBATIM_GUARD=1 in scripts/serve.py of the project repo) and any such value becomes null.

Prompt format

The literal ### Instruction: / ### Response: block is part of the model. Do not wrap it in a chat template.

INSTRUCTION_TEMPLATE = """### Instruction:
Bแบกn lร  mแป™t cรดng cแปฅ trรญch xuแบฅt thรดng tin. Dแปฑa trรชn ฤ‘oแบกn chat sau vร  khung JSON (schema) ฤ‘ฦฐแปฃc cung cแบฅp, hรฃy ฤ‘iแปn thรดng tin chรญnh xรกc vร o khung JSON. Nแบฟu khรดng tรฌm thแบฅy thรดng tin, giแปฏ nguyรชn null.

Khung JSON:
{schema_frame}

ฤoแบกn chat:
{chat_log}

### Response:
"""

schema_frame is json.dumps(frame, ensure_ascii=False, indent=2); chat_log is one turn per line, Khรกch: ... / Shop: ... (buyer-buyer and group chats use participant names). Greedy decoding only.

Quick start

import json, torch
from transformers import AutoModelForCausalLM, AutoTokenizer

model_id = "YOUR_ORG/vietextract-0.5b"
tok = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
    model_id, torch_dtype=torch.float16, attn_implementation="sdpa", device_map={"": 0}
)
model.eval()

frame = {"customer": {"name": None, "phone": None},
         "items": [{"name": None, "qty": None, "price": None}],
         "notes": None}
chat = ("Khรกch: shop ฦกi cรฒn รกo sฦก mi trแบฏng size L k\n"
        "Shop: dแบก cรฒn 2 cรกi\n"
        "Khรกch: lแบฅy 1 cรกi, giao vแป 22 Hai Bร  Trฦฐng, tรชn Trang, sฤ‘t 0987 654 321")

prompt = f"""### Instruction:
Bแบกn lร  mแป™t cรดng cแปฅ trรญch xuแบฅt thรดng tin. Dแปฑa trรชn ฤ‘oแบกn chat sau vร  khung JSON (schema) ฤ‘ฦฐแปฃc cung cแบฅp, hรฃy ฤ‘iแปn thรดng tin chรญnh xรกc vร o khung JSON. Nแบฟu khรดng tรฌm thแบฅy thรดng tin, giแปฏ nguyรชn null.

Khung JSON:
{json.dumps(frame, ensure_ascii=False, indent=2)}

ฤoแบกn chat:
{chat}

### Response:
"""
inputs = tok(prompt, return_tensors="pt").to(model.device)
with torch.no_grad():
    out = model.generate(**inputs, max_new_tokens=512, do_sample=False,
                         pad_token_id=tok.pad_token_id or tok.eos_token_id)
print(json.loads(tok.decode(out[0, inputs["input_ids"].shape[1]:], skip_special_tokens=True)))

Evaluation

1,054 held-out conversations (synthetic, in-domain, split by conversation), greedy decoding, no guided JSON. Difficulty is a property of the data:

  • D1 flat scalar frames, 5โ€“9 fields, 50โ€“70% filled
  • D2 flat + one nested object, 30โ€“50% filled
  • D3 arrays of objects, 12โ€“20 fields, 15โ€“35% filled, multi-item / multi-party
  • D4 adversarial: near-empty information, off-topic, conflicting statements
metric value
JSON validity 99.9%
Shape validity (structure preserved) 99.8%
Leaf F1 โ€” strict 0.805
Leaf F1 โ€” boundary-tolerant 0.869
Precision / recall (tolerant) 0.857 / 0.881
Item F1 (arrays, order-insensitive) 0.817
Exact item count 67.3%
Fabrication (value not in chat) 0.6%

Per difficulty (boundary-tolerant leaf F1): D1 0.923 ยท D2 0.812 ยท D3 0.882 ยท D4 0.920.

Per domain (strict leaf F1): repair 0.842 ยท ecommerce 0.837 ยท fnb 0.817 ยท events 0.808 ยท beauty 0.805 ยท cleaning 0.804 ยท rental 0.801 ยท recruitment 0.760 ยท motorbike 0.757.

How to read these

  • Strict vs tolerant: strict requires the exact span; tolerant allows one string to contain the other ("12 Lรช Lแปฃi" vs "sแป‘ 12 Lรช Lแปฃi, Q1"). Tolerant is the number that reflects usable extraction; strict is what an exact-match caller sees.
  • Exact item count is separate from item F1 on purpose: returning 2 of 3 items still scores ~0.8 item F1 but the order is wrong.
  • Fabrication counts only values that do not appear in the chat. A non-null value where the reference label is null but the text does say it is label under-fill, not invention; our labels carry ~10% of that. So this model's true fabrication rate is well under 1%.

Training data

15,319 synthetic Vietnamese conversations across nine transaction domains (F&B/delivery, beauty/spa, e-commerce/retail, home repair, rental, part-time recruitment, motorbike & EV repair, cleaning/laundry/moving, events), generated with a fact-sheet-first pipeline: plan the facts, write the conversation to express them while omitting the rest, inject four layers of realistic noise (formatting, syntax, persona-gated teencode/Viet-glish, orthographic typos), extract labels from the noisy text, then re-anchor every leaf to a verbatim span.

20 schema variants across four naming styles; 25% of samples are nested frames, 25% arrays, 25% adversarial; 71% buyerโ†”seller, 16% buyerโ†”buyer, 13% group chats where the agent is a member of the buying group.

Training: LoRA r=16 (q,k,v,o,gate,up,down), fp32, 1536 context, 1 epoch on 8,920 samples, 4.81 s/step on a GTX 1070 (1.5 h), peak 4.67 GiB.

Limitations

  • Synthetic, in-domain. All nine domains are e-commerce/service transactions; there is no medical, legal, financial or out-of-domain guarantee. Real-world evaluation is planned.
  • Two weak field families. Roughly 70% of remaining errors are time expressions ("chiแปu nay", "thแปฉ Bแบฃy tuแบงn sau") and free-text notes, where the exact span is genuinely ambiguous.
  • Arrays are the weakest shape. Exact item count is 67.3%; getting 2 of 3 items right is common. Not a capacity issue โ€” see the 1.5B card for the same effect.
  • Context: trained at โ‰ค1536 tokens (prompt + answer), p95 953. Longer threads must be windowed by the caller (chunk at turn boundaries and merge: union for items, latest mention for mutable fields).
  • No normalisation by design. Numbers, dates and currency stay as written.
  • Not a chat model. It fills frames; it will produce nonsense if asked questions.

Family

A 1.5B sibling trained on the same data is published separately and is measurably better on arrays and adversarial chats; use this 0.5B for high-volume flat/single-nested extraction.

Licence

Base: Qwen2.5-0.5B-Instruct (Apache-2.0). Fine-tune and synthetic data: Apache-2.0.

Downloads last month
45
Safetensors
Model size
0.5B params
Tensor type
F16
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for cbc-528a/vietextract-0.5b

Adapter
(1,120)
this model

Collection including cbc-528a/vietextract-0.5b