PoC Mini Trade NPC
PoC Mini Trade NPC is a merchant NPC model for a trading game, fine-tuned from Gemma 3 270M (instruction-tuned) on aotoki/poc-mini-trade-game-dataset. It reads a player's Traditional Chinese (zh-TW) line and phrases the merchant's reply; the game decides everything else.
This is a proof of concept. Small enough to run on CPU or in the browser with wllama.
| Released | 2026-11-26 |
| File | poc-mini-trade-npc.Q8_0.gguf |
| Base | google/gemma-3-270m-it, trained from the same weights in unsloth/gemma-3-270m-it |
| Language | Traditional Chinese (zh-TW) |
| License | Gemma Terms of Use |
This release changes the prompts and the reply format. A game built for the first release keeps working only if it stays pinned to revision
312fa26; see Updates.
How the game uses it
Each turn makes two model calls around the game's own rules. The model never decides an action, a price, or a friendship change, and never writes a number or a currency word.
| Step | Who | Does |
|---|---|---|
| Extract | Model | Reads what the player does: intent, attitude, offer |
| Resolve | Game | Decides the action, price, friendship, and emotion |
| Render | Model | Phrases the action, with slots for the game's values |
| Fill | Game | Writes {price}, {offer}, and {currency} into the line |
Both prompts start with the same # World and # NPC sections, so the game can reuse their KV cache. The full contract — fields, emotion table, and the game's duties — is docs/features/npc-calls.md.
Quick start
Serve with llama.cpp:
llama-server -m poc-mini-trade-npc.Q8_0.gguf --port 8080 --jinja
Extract
The system prompt carries the turn; the player's line is the user message.
# World
currency: 星幣
# NPC
role: merchant
# Task
extract
# Turn
item: 聖騎士盔甲
price: 19275
previous_player: 能不能算低點
previous_npc: 嫌貴就別買,19275星幣,這是我的底線。
The player says 拜託了,這套盔甲真的很棒,我誠心出12675星幣,請您考慮看看。 and the model replies:
{"intent":"offer","attitude":"polite","offer":12675}
Render
After the game resolves the turn, it asks for the line with its decision:
# World
currency: 星幣
# NPC
role: merchant
# Task
render
# Turn
item: 聖騎士盔甲
relationship: hostile
action: counter
price: 18398
player_offer: 12675
emotion: pleased
With the same user message, the model replies:
{"message":"哼,{price}{currency},這是我能給的底線。"}
The game shows 哼,18398星幣,這是我能給的底線。
Pass the reply schemas in lib/npc_schema.rb as response_format (EXTRACT and RENDER). The render schema allows only CJK ideographs, Chinese punctuation, and the three slots, so a reply cannot drift into other scripts or write a number itself.
Training
| Setting | Value |
|---|---|
| Run | 20261126-3 |
| Method | LoRA r16, α32, dropout 0, on all attention and MLP projections, merged into the base |
| Data | train split: 1,586 bargaining turns, rebalanced into 2,367 examples (1,160 extract, 1,207 render) |
| Currencies | Train prompts use 10 currencies; validation and test use 3 that training never sees |
| Schedule | 6 epochs, batch 8, lr 2e-4 linear, AdamW 8-bit, weight decay 0.001, seed 3407, max length 512 |
| Loss | Model turn only (train_on_responses_only) |
| Checkpoint selection | Epochs 4–6 scored on validation; epoch 6 exported |
| Export | Merged and converted to GGUF Q8_0 with llama.cpp |
| Hardware | Google Colab, NVIDIA T4 (8.4 minutes) |
Framework versions
- Unsloth: 2026.11.12
- Transformers: 5.17.0
- PyTorch: 2.14.1
- llama.cpp: build 12722 (73960d011)
Evaluation
Scored once on the test split (248 turns), never used for training or checkpoint selection, with currencies the model never saw. Brackets are 95% Wilson intervals.
| Call | Metric | Result |
|---|---|---|
| Extract | JSON valid | 248/248 |
| Extract | All three fields match | 0.899 [0.855, 0.931] |
| Extract | Intent / attitude / offer | 0.984 / 0.915 / 0.992 |
| Render | JSON valid | 248/248 |
| Render | {price} written on sell or counter | 0.988 [0.959, 0.997] |
| Render | {currency} written where the reference names one | 0.988 [0.959, 0.997] |
| Render | Currency word written instead of the slot | 0/248 |
| Render | No simplified characters | 0.996 |
The release gate requires no invalid JSON and lower bounds of 0.85 for all three extract fields matching and 0.90 for {price}. Render quality has no automatic measure; a read of 28 replies found most counters, sales, and leaves on point, and about a quarter flawed, mostly small talk.
When the currency word also names the item (這鎖鏈1214鎖鏈就好), extract read 52 of 53 offers correctly. Scored with llama.cpp build 12722 (Metal, greedy, replies constrained by the reply schemas), 0.18 s per turn.
Updates
Each update replaces the file in this repository. An update that changes prompts or the reply format names the revision that keeps the old contract; games pin a revision, so they choose when to move.
| Date | Run | Change | Previous version |
|---|---|---|---|
| 2026-11-26 | 20261126-3 | Incompatible. Two calls, extract and render, in Markdown sections; render writes slots; the game decides action, price, and friendship | 312fa26 |
| 2026-10-21 | 20261021-1 | First release | — |
Limitations
- Trained only on synthetic data written by Claude (Anthropic) and checked by rule validators; real players write shorter, looser lines than the training data.
- Small talk is the weakest reply: it can be incoherent or drift into simplified characters. The game should keep fallback lines.
- Attitude borders are fuzzy: restrained praise or politeness is labelled inconsistently in the data, so plain and polite are often swapped.
- Chinese numerals are occasionally misread (
一千二百四十as 1224); the game's offer check, which keeps an offer only when the player wrote that price, is required. - Traditional Chinese only, one merchant voice, one item per negotiation, and no memory beyond the previous turn.
License
This model is a Model Derivative of Gemma, distributed under the Gemma Terms of Use. A copy of the terms is in GEMMA_TERMS_OF_USE.md and the required notice in NOTICE.
Your use of this model is subject to the use restrictions of Section 3.2, including the Gemma Prohibited Use Policy (copy in GEMMA_PROHIBITED_USE_POLICY.md). If you redistribute this model or a derivative of it, you must pass these restrictions on to your recipients.
Modification notice: the weights in this repository were modified from Gemma 3 270M by fine-tuning with LoRA, merging the adapter, and converting to GGUF Q8_0.
The training dataset is licensed separately under Apache-2.0.
Gemma is a trademark of Google LLC. This project is not affiliated with or endorsed by Google.