ViExtract-EC 0.5B
A specialized model for JSON data extraction
3 min readupdated
ViExtract-EC 0.5B is a specialized language model based on Qwen/Qwen2.5-0.5B-Instruct, designed to extract information from Vietnamese dialogues and populate predefined JSON frames (data structures). The model works as a connector for large agents: it provides no extra explanations or reasoning, returning strictly a single JSON object. The model's main feature is that it searches for keys regardless of their naming in the schema (schema-agnostic) and extracts values as exact substrings from the text without normalization. The tool targets developers building automation for chats in e-commerce, beauty services, and food delivery.
Key features
- Schema agnostic: The model finds information equally well regardless of how a field is named in the schema (for example,
customer_nameorten_khach_hang). - Strict substring contract: All extracted values are literal substrings from the chat without normalization or data type changes.
- High processing speed: The compact size (0.49 billion parameters) ensures fast inference (about 2.5 seconds per extraction on a GTX 1070).
- Structural accuracy: The model was trained on synthetic data using a noise pipeline and demonstrates 100% validity of the generated JSON.
What you can do
- Online store integration: Automatically populate orders from customer chats (product, size, delivery address).
- Service request processing: Extract contact details and booking specifics from support service dialogues.
- Agent creation: Use the model as an intermediate filter to structure raw text logs in order processing pipelines.
Example
An example of model inference using the transformers library and an exact instruction template:
import json, torch
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "cbc-528a/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 = {"ten_khach_hang": None, "so_dien_thoai": None, "dia_chi_giao": 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=320, 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)))Read more
DetailsMetrics (on a holdout set): Schema adherence — 100%, Field F1 (boundary-tolerant) — 0.933, Exact whole-object match — 34%.
Requirements and limitations: The model contains 490 million parameters, was trained on contexts up to 1024 tokens, and requires greedy decoding without sampling to prevent the model from drifting outside the schema.
Training: 12,492 synthetic Vietnamese dialogues across four domains with an artificial text noise pipeline. Base model — Qwen/Qwen2.5-0.5B-Instruct, Apache-2.0 license.










Comments