Instructions to use cbc-528a/vietextract-1.5b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use cbc-528a/vietextract-1.5b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="cbc-528a/vietextract-1.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-1.5b") model = AutoModelForCausalLM.from_pretrained("cbc-528a/vietextract-1.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-1.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-1.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-1.5b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/cbc-528a/vietextract-1.5b
- SGLang
How to use cbc-528a/vietextract-1.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-1.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-1.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-1.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-1.5b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use cbc-528a/vietextract-1.5b with Docker Model Runner:
docker model run hf.co/cbc-528a/vietextract-1.5b
ViExtract-EC 1.5B
A Vietnamese extraction model that fills a caller-supplied JSON frame from a raw chat log. Same contract and prompt as the 0.5B sibling, more capacity โ measurably better on arrays and adversarial chats.
{"customer": {"name": null, "phone": null},
"items": [{"name": null, "qty": null, "price": null}],
"notes": null}
Contract
The frame declares the shape; no type wrappers:
| frame node | meaning | when absent |
|---|---|---|
null |
scalar string | null |
{...} |
nested object | fill each leaf independently |
[{...}] |
array of objects (one prototype element) | [] |
- Values are verbatim substrings of the chat โ no normalisation, no type coercion.
- Missing information is
null(arrays:[]), never"". - Arrays keep chat order, one element per distinct item, no duplicates.
- When a value is corrected mid-conversation, the latest agreed value wins.
Prompt format
The literal block is part of the model. Do not use 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:
"""
Greedy decoding only. chat_log is one turn per line.
Quick start
import json, torch
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "YOUR_ORG/vietextract-1.5b"
tok = AutoTokenizer.from_pretrained(model_id)
dtype = torch.float32 if "Pascal" in torch.cuda.get_device_name(0) else torch.float16
model = AutoModelForCausalLM.from_pretrained(
model_id, torch_dtype=dtype, attn_implementation="sdpa", device_map={"": 0}
)
model.eval()
frame = {"customer": {"name": None}, "items": [{"name": None, "qty": None, "price": None}]}
chat = "Khรกch: shop ฦกi cรฒn รกo sฦก mi trแบฏng size L k\nShop: dแบก cรฒn 2 cรกi\nKhรกch: lแบฅy 1 cรกi, tรชn Trang"
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)))
Precision note: on Pascal GPUs (GTX 10-series) FP16 runs at 1/64 rate, so fp32 is ~3ร faster than fp16 for this model (6.2 GiB vs 3.1 GiB VRAM). On Turing/Ampere/Hopper use fp16 โ it is faster and halves memory.
Evaluation
1,054 held-out conversations, greedy decoding, no guided JSON, identical records to the 0.5B sibling so the two are directly comparable.
| metric | 0.5B | 1.5B |
|---|---|---|
| JSON validity | 99.9% | 99.9% |
| Shape validity | 99.8% | 99.6% |
| Leaf F1 โ strict | 0.805 | 0.833 |
| Leaf F1 โ boundary-tolerant | 0.869 | 0.892 |
| Precision / recall (tolerant) | 0.857 / 0.881 | 0.883 / 0.902 |
| Item F1 (arrays) | 0.817 | 0.851 |
| Exact item count | 67.3% | 72.9% |
| Fabrication (value not in chat) | 0.6% | 0.4% |
| Latency (GTX 1070, fp32) | 2.2 s | 4.4 s |
Per difficulty (boundary-tolerant leaf F1):
| D1 easy | D2 nested | D3 arrays | D4 adversarial | |
|---|---|---|---|---|
| 0.5B | 0.923 | 0.812 | 0.882 | 0.920 |
| 1.5B | 0.944 | 0.831 | 0.912 | 0.925 |
Per domain (strict leaf F1): repair 0.863 ยท ecommerce 0.864 ยท fnb 0.848 ยท beauty 0.841 ยท events 0.841 ยท cleaning 0.814 ยท rental 0.809 ยท recruitment 0.804 ยท motorbike 0.803.
The capacity gain is concentrated where it should be: +0.030 tolerant and +0.034 item F1 on arrays, and exact item count 67.3% โ 72.9%. D1/D2 barely move (+0.006/+0.007), which is why the 0.5B remains the right choice for high-volume simple frames.
Training data
15,319 synthetic Vietnamese conversations across nine transaction domains (F&B/delivery, beauty/spa, e-commerce, home repair, rental, part-time recruitment, motorbike & EV repair, cleaning/laundry/moving, events). Fact-sheet-first generation: plan the facts, write the chat to express them and omit the rest, inject four noise layers, extract labels from the noisy text, re-anchor every leaf to a verbatim span.
Difficulty mix 25/25/25/25 (D1โD4); 71% buyerโseller, 16% buyerโbuyer, 13% group chats with the agent inside the buying group.
Training: LoRA r=16, fp16, 1536 context, 1 epoch on 8,920 samples, 23.6 s/step on a GTX 1070 (7.3 h), peak 6.31 GiB.
Limitations
- Synthetic, in-domain. No medical, legal, financial or out-of-domain guarantee. Real-world evaluation is planned.
- Arrays are still the weakest shape: exact item count 72.9% โ one order in four has the wrong number of line items. That is a labelling-definition problem, not capacity.
- Time and notes fields carry most of the remaining span errors.
- Context: trained at โค1536 tokens, p95 953. Window longer threads (chunk at turn boundaries; union for items, latest mention for mutable fields).
- No normalisation by design โ numbers, dates and currency stay as written.
- Not a chat model.
- 1.5B fp32 needs ~6.2 GiB VRAM; fp16 ~3.1 GiB (but slow on Pascal).
Licence
Base: Qwen2.5-1.5B-Instruct (Apache-2.0). Fine-tune and synthetic data: Apache-2.0.
- Downloads last month
- 19