ghostai-lfm3-1.7b-appcontract-v3c
SFT checkpoint on the v3 app-contract dataset. Fine-tuned from LiquidAI/LFM3-1.7B as a compact on-device tool caller for a Solana wallet assistant (198 tools). The model emits Hermes-style tool calls and must stay silent on chat/answer turns.
What changed from v2
- Prompt format matches the app. v2 trained against full JSON-schema tool
catalogs. The on-device path sends the compact catalog built by
LocalToolCatalog.ts({"format":"params: type or enum choices; ! means required", ...}). v3 rebuilds every system prompt from the real app strings inContextManager.tsplus that compact builder, so training and inference see the same bytes. - Eval contamination removed. 511 v2 train rows were exact or near-exact copies of prompts in the two external questionnaires. v3 drops them and replaces the behavior with paraphrases generated by a local 33B teacher (Nanbeige4.3-33B, Q4_K_M, three A100-40GB instances). No external/cloud API was used for any data or eval.
- Hard-case mining. The same local teacher added thin-tool, multi-turn and
refusal cases validated against
app-tool-defs.json.
Training
- 3 epochs, lr 1e-5, cosine, bf16, FlashAttention-2, fused AdamW, DeepSpeed ZeRO-2 across 3x A100-40GB, assistant-only loss, max length 2048.
- Dataset
ghost-ai-app-contract-lfm3-v3.parquet: 818 rows scored - Split by utterance skeleton, so the test set holds unseen phrasings.
Held-out app-contract eval
Compact runtime prompts, greedy decoding, repo parser/validator
(scripts/eval_app_contract_hf.py).
| Metric | Value |
|---|---|
| Rows scored | 818 |
| Tool-call turns: parseable call | 96.67% |
| Tool-call turns: correct tool | 94.00% |
| Tool-call turns: arguments valid | 96.00% |
| Tool-call turns: exact call | 0.00% |
| Answer/chat turns: no tool call emitted | 0.00% (no calls emitted) |
External questionnaire eval (offline, compact prompts)
| suite | n | any-tool | primary | route | args valid | gate |
|---|---|---|---|---|---|---|
| agentic-eval-3 | 2000 | 95.37% | 90.76% | 91.69% | 81.65% | 87.12% |
| grpo-2000-eval | 2000 | 89.57% | 79.73% | 83.55% | 79.20% | 74.80% |
Catalogs for these runs are synthetic (expected tools plus distractors) because the retrieval step is not exercised.
Usage
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "immortaltatsu/ghostai-lfm3-1.7b-appcontract-v3c"
tok = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(model_id, trust_remote_code=True, dtype="bfloat16")
msgs = [{"role": "user", "content": "send 2 SOL to alice.sol"}]
prompt = tok.apply_chat_template(msgs, tokenize=False, add_generation_prompt=True,
enable_thinking=False)
inputs = tok(prompt, return_tensors="pt").to(model.device)
out = model.generate(**inputs, max_new_tokens=128, do_sample=False)
print(tok.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
Always pass enable_thinking=False — LFM3 otherwise emits reasoning delimiters
(</think>) that the app's format check flags as markup leakage.
Limitations
- Trained and evaluated against fixture tool services; real protocol correctness, signing and transaction economics are out of scope.
- Value-moving tools must never sign or broadcast from chat; the app's confirmation gate is the authority, not the model.
- The offline questionnaire eval scores tool choice, restraint, argument validity and refusal text. It does not measure retrieval quality: the catalogs are assembled synthetically (expected tools plus distractors) rather than by the app's real tool-retrieval step.
- Keyword-based oracles do not measure general truthfulness or explanation quality.
- No blinded human review has been performed.