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
Safetensors
Model size
2B 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-1.5b

Adapter
(1,802)
this model
Adapters
1 model

Collection including cbc-528a/vietextract-1.5b