Instructions to use cbc-528a/vietextract-0.5b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use cbc-528a/vietextract-0.5b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="cbc-528a/vietextract-0.5b") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("cbc-528a/vietextract-0.5b") model = AutoModelForCausalLM.from_pretrained("cbc-528a/vietextract-0.5b", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use cbc-528a/vietextract-0.5b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "cbc-528a/vietextract-0.5b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "cbc-528a/vietextract-0.5b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/cbc-528a/vietextract-0.5b
- SGLang
How to use cbc-528a/vietextract-0.5b with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "cbc-528a/vietextract-0.5b" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "cbc-528a/vietextract-0.5b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "cbc-528a/vietextract-0.5b" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "cbc-528a/vietextract-0.5b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use cbc-528a/vietextract-0.5b with Docker Model Runner:
docker model run hf.co/cbc-528a/vietextract-0.5b
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
timeexpressions ("chiแปu nay", "thแปฉ Bแบฃy tuแบงn sau") and free-textnotes, 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