LFM3-2.0B-TV25-IrrGuard)A 2.02B-parameter (29-layer, 262,144 context window, bfloat16) agentic and function-calling language model built from Sayansantra/LFM3-1.7B-WSP-V3 (derived from LiquidAI/LFM3-1.7B) through Selective Depth Expansion, New-Layer Agentic SFT with Task-Vector Fusion (λ = 0.25), and Surgical IrrGuard Weight-Space Programming (α = 0.05).
Despite having only 2.02B parameters (4.03 GB in bfloat16), this checkpoint achieves 88.88% Official Non-Live Python AST and 74.42% Live Simple AST on the UC Berkeley Gorilla Berkeley Function Calling Leaderboard (BFCL) (1,498 official tasks), outperforming models 13× its size (Qwen3.8-27B) on multi-call tool execution while matching or exceeding gpt-4.1-mini-2025-04-14 on multiple and live_simple.
Qwen3.8-27B (27B, 13.4× larger) on multi-call splits: 88.00% vs. 82.50% (+5.50 pts) on parallel and 84.50% vs. 83.50% (+1.00 pt) on parallel_multiple.gpt-4.1-mini-2025-04-14 on multiple (91.50% vs. 91.50%) and live_simple (74.42% vs. 73.30%, +1.12 pts).Gemma 4 26B-A4B-it (26B, 13× larger) on Official Non-Live Python AST (88.88% vs. 89.13%) and within 2.50 pts of Gemini 3.8 Flash on simple_python (91.50% vs. 94.00%).#1 Claude-Opus-4-5-20251101 (FC) on the BFCL V4 Live Leaderboard (73.76% Non-Live AST across all languages / 70.97% Live AST).All evaluations were run deterministically (do_sample=False, BFCL official AST grader) directly against gorilla-llm/Berkeley-Function-Calling-Leaderboard (BFCL_v3_simple.json, BFCL_v3_multiple.json, BFCL_v3_parallel.json, BFCL_v3_parallel_multiple.json, BFCL_v3_live_simple.json, BFCL_v3_irrelevance.json).
| Model | Active Size | simple_python (400) |
multiple (200) |
parallel (200) |
parallel_multiple (200) |
Non-Live Python AST | live_simple (258) |
irrelevance (240) |
6-Split Macro Avg |
|---|---|---|---|---|---|---|---|---|---|
LFM3-2.0B-WSP-V4 (Patched 1536t + Prompt Fix) |
2.02B | 91.50% | 91.50% | 88.00% | 84.50% | 88.88% | 74.42% | 48.75% | 79.78% |
LFM3-2.0B-WSP-V4 (Single-Pass 768t Baseline) |
2.02B | 90.00% | 91.00% | 85.00% | 83.00% | 87.25% | 72.48% | 48.75% | 78.37% |
Qwen3.8-27B (BF16) |
27B | — | 97.00% | 82.50% | 83.50% | — | 87.98% | — | — |
gpt-4.1-mini-2025-04-14 |
Cloud Mini | — | 91.50% | 91.50% | 87.00% | — | 73.30% | — | — |
Gemma 4 26B-A4B-it |
26B (3.8B act.) | — | 93.00% | 93.00% | 92.50% | 89.13% | 86.82% | 91.25% | — |
Gemini 3.8 Flash |
Cloud Flash | 94.00% | — | — | — | — | — | — | — |
Claude-Opus-4-5-20251101 (FC) |
Frontier | — | — | — | — | 73.76%* | 70.97%* | — | — |
Notes on methodology & transparency:
- Single-Pass (
768t) vs. Patched (1536t+ Prompt Fix): In the single-pass768-token evaluation (official_bfcl_ast_report_768tok.json),38 / 1,498(2.54%) generations hit the token ceiling and6zero-argumentsimple_pythontasks echoed a literalKEYparameter placeholder shown in the eval system prompt. Re-evaluating those exact45targeted failed tasks withmax_new_tokens=1536and a clean prompt placeholder recovered21 / 45tasks (official_bfcl_ast_report_patched.json), cutting remaining truncations to10 / 1,498(0.67%). Both raw audited JSONL prediction files (eval_results/bfcl_raw_predictions_768tok.jsonlandeval_results/bfcl_raw_predictions_patched.jsonl) are included in this repository.- Leaderboard scope: Official BFCL V4 Non-Live/Live leaderboard columns (
*) also include Java, JavaScript, and Multi-Turn/Agentic splits. The scores reported here cover the 6 Python Single-Turn splits (1,498tasks);multi_turnandagenticsplits remain open for subsequent evaluation.
| Iteration | simple_python |
multiple |
parallel |
parallel_multiple |
Non-Live AST | live_simple |
irrelevance |
6-Split Avg |
|---|---|---|---|---|---|---|---|---|
TV_lam20 (256t) |
80.50% | 84.00% | 34.00% | 18.50% | 54.25% | 55.04% | 81.67% | 58.95% |
TV_lam25 (768t) |
90.00% | 91.00% | 84.50% | 83.00% | 87.12% | 72.48% | 49.58% | 78.43% |
TV25 + IrrGuard (α=0.05) (768t) |
90.00% | 91.00% | 85.00% | 83.00% | 87.25% | 72.48% | 48.75% | 78.37% |
TV25 + IrrGuard (α=0.05) (1536t + Prompt Fix) |
91.50% | 91.50% | 88.00% | 84.50% | 88.88% | 74.42% | 48.75% | 79.78% |
LFM3-2.0B-WSP-V4 preserves all 24 original layers from Sayansantra/LFM3-1.7B-WSP-V3 untouched during training and injects 5 specialized full_attention reasoning/agentic blocks, yielding a 29-layer hybrid short-convolution + GQA Transformer:
| Parameter | Specification |
|---|---|
| Architecture | Lfm3ForCausalLM (trust_remote_code=True) |
| Parameters / Size | ~2.02B (4.03 GB model.safetensors, bfloat16) |
| Layers | 29 (conv, sliding_attention, full_attention; new full_attention layers at indices [13, 16, 19, 22, 25]) |
| Hidden / FFN Size | 2048 / 7680 SwiGLU |
| Attention | 16 query heads, 4 KV heads (GQA), head_dim=128, sliding_window=256, conv_L_cache=7 |
| Context Length | 262,144 tokens (max_position_embeddings) |
| Vocabulary | 128,000 (bos=124894, eos=124900, pad=124893) |
24 → 29 layers): Inserted 5 full_attention layers after original layers [12, 14, 16, 18, 20], initialized via 0.70 / 0.30 neighbor interpolation combined with rank-1 contrastive agentic subspace projection (ε = 1e-3, bg = 0.20 * ε) extracted on o_proj and feed_forward.w2.TV_lam25): Froze all 24 base backbone layers and fine-tuned only the 5 inserted layers (lr = 2.5e-5, max_seq_len = 1280, 1 epoch DDP) on 2,400 masked assistant-response trajectories curated from deepseek-v4-pro-agent-tool-calling-trajectory, agenttracer-bfcl, fable-5-premium, and BFCL irrelevance examples, then fused at λ = 0.25:
$$W_{\text{TV25}} = 0.75 , W_{\text{Step0}} + 0.25 , W_{\text{Stage1}}$$IrrGuard WSP (α = 0.05): Extracted normalized contrastive abstention-vs-tool-call vectors on the 5 new layers' FFN w2 matrices and selected α = 0.05 via a 240-task Pareto screen balancing parallel, parallel_multiple, and irrelevance.An automated 0-GPU audit (eval_results/bfcl_failure_analysis.json) of all 316 baseline (768-token) misses identified:
irrelevance abstention (48.75%): Passed irrelevance tasks averaged 193.5 generated tokens (explicit <think> reasoning before abstaining), whereas all 123 failures emitted reflexive tool calls (122 single calls, 1 3-call) averaging just 57.7 tokens. Dedicated irrelevance-abstention DPO/GRPO is recommended for production deployments where irrelevant tool sets are common.max_new_tokens >= 1280 (ideally 1536) when calling multiple parallel tools with <think> reasoning traces.<parameter=KEY>VAL</parameter> in system instructions so zero-argument functions do not echo literal keys.transformers)import json
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "Sayansantra/LFM3-2.0B-WSP-V4"
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
model_id,
torch_dtype=torch.bfloat16,
device_map="auto",
trust_remote_code=True,
)
tools = [
{
"name": "get_weather",
"description": "Fetch current weather for a city.",
"parameters": {
"type": "object",
"properties": {"city": {"type": "string"}},
"required": ["city"],
},
}
]
messages = [
{
"role": "system",
"content": (
"You are a precise agentic assistant.
"
f"Available tools JSON:\n{json.dumps(tools)}\n"
"Only call a tool when directly required by the user; wrap calls in "
"<tool_call><function=NAME><parameter=ARG>VALUE</parameter></function></tool_call>."
),
},
{"role": "user", "content": "Check the weather in Tokyo and Osaka."},
]
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
with torch.no_grad():
out = model.generate(**inputs, max_new_tokens=1536, do_sample=False)
print(tokenizer.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
model.safetensors, config.json, configuration_lfm3.py, modeling_lfm3.py, lfm3_conv.py, generation_config.json, tokenizer.json, tokenizer_config.json, chat_template.jinja, LICENSEeval_results/):eval_results/official_bfcl_ast_report_patched.json — 1536-token + prompt-fix BFCL report (88.88% Non-Live Python AST)eval_results/official_bfcl_ast_report_768tok.json — Single-pass 768-token baseline BFCL report (87.25% Non-Live Python AST)eval_results/bfcl_failure_analysis.json — Full 1,498-task error taxonomy auditeval_results/bfcl_raw_predictions_patched.jsonl — Patched predictions across all 1,498 BFCL taskseval_results/bfcl_raw_predictions_768tok.jsonl — Baseline single-pass predictions across all 1,498 BFCL tasksReleased under the LFM Open License v1.0 (LICENSE), inherited from LiquidAI/LFM3-1.7B.
Sayansantra/LFM3-1.7B-WSP-V3