Run this model with HF Jobs
Run Sayansantra/LFM3-2.0B-WSP-V4 on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs and TRL to fine-tune https://huggingface.co/Sayansantra/LFM3-2.0B-WSP-V4. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/Sayansantra/LFM3-2.0B-WSP-V4 on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Evaluate on a benchmark
Use HF Jobs to evaluate https://huggingface.co/Sayansantra/LFM3-2.0B-WSP-V4. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
Quantize for lower memory use
Use HF Jobs to create a 4-bit version of https://huggingface.co/Sayansantra/LFM3-2.0B-WSP-V4. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
Instructions to use Sayansantra/LFM3-2.0B-WSP-V4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Sayansantra/LFM3-2.0B-WSP-V4 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Sayansantra/LFM3-2.0B-WSP-V4", trust_remote_code=True) 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("Sayansantra/LFM3-2.0B-WSP-V4", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("Sayansantra/LFM3-2.0B-WSP-V4", trust_remote_code=True, 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 Sayansantra/LFM3-2.0B-WSP-V4 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Sayansantra/LFM3-2.0B-WSP-V4" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Sayansantra/LFM3-2.0B-WSP-V4", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Sayansantra/LFM3-2.0B-WSP-V4
- SGLang
How to use Sayansantra/LFM3-2.0B-WSP-V4 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 "Sayansantra/LFM3-2.0B-WSP-V4" \ --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": "Sayansantra/LFM3-2.0B-WSP-V4", "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 "Sayansantra/LFM3-2.0B-WSP-V4" \ --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": "Sayansantra/LFM3-2.0B-WSP-V4", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Sayansantra/LFM3-2.0B-WSP-V4 with Docker Model Runner:
docker model run hf.co/Sayansantra/LFM3-2.0B-WSP-V4
Sayansantra/LFM3-2.0B-WSP-V4 (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.
Highlights & Frontier Standing
- Beats
Qwen3.8-27B(27B, 13.4× larger) on multi-call splits: 88.00% vs. 82.50% (+5.50 pts) onparalleland 84.50% vs. 83.50% (+1.00 pt) onparallel_multiple. - Matches / exceeds
gpt-4.1-mini-2025-04-14onmultiple(91.50% vs. 91.50%) andlive_simple(74.42% vs. 73.30%,+1.12 pts). - Within 0.25 pts of
Gemma 4 26B-A4B-it(26B, 13× larger) on Official Non-Live Python AST (88.88% vs. 89.13%) and within 2.50 pts ofGemini 3.8 Flashonsimple_python(91.50% vs. 94.00%). - Strong Single-Turn AST standing: 88.88% Non-Live Python AST and 74.42% Live Simple AST vs.
#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).
Official UC Berkeley BFCL Benchmark Results (1,498 Tasks)
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).
1. Frontier & Large-Model Comparison
| 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.
2. Development Progression
| 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% |
Architecture & Construction Recipe
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) |
3-Stage Build Pipeline
- Contrastive Layer Expansion (
24 → 29layers): Inserted 5full_attentionlayers after original layers[12, 14, 16, 18, 20], initialized via0.70 / 0.30neighbor interpolation combined with rank-1 contrastive agentic subspace projection (ε = 1e-3,bg = 0.20 * ε) extracted ono_projandfeed_forward.w2. - New-Layer-Only SFT + Task-Vector Fusion (
TV_lam25): Froze all 24 base backbone layers and fine-tuned only the 5 inserted layers (lr = 2.5e-5,max_seq_len = 1280,1epoch DDP) on2,400masked assistant-response trajectories curated fromdeepseek-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}}$$ - Surgical
IrrGuardWSP (α = 0.05): Extracted normalized contrastive abstention-vs-tool-call vectors on the 5 new layers' FFNw2matrices and selectedα = 0.05via a 240-task Pareto screen balancingparallel,parallel_multiple, andirrelevance.
Failure Analysis & Known Limitations
An automated 0-GPU audit (eval_results/bfcl_failure_analysis.json) of all 316 baseline (768-token) misses identified:
irrelevanceabstention (48.75%): Passed irrelevance tasks averaged193.5generated tokens (explicit<think>reasoning before abstaining), whereas all123failures emitted reflexive tool calls (122single calls,13-call) averaging just57.7tokens. Dedicated irrelevance-abstention DPO/GRPO is recommended for production deployments where irrelevant tool sets are common.- Token budget for multi-call generation: Set
max_new_tokens >= 1280(ideally1536) when calling multiple parallel tools with<think>reasoning traces. - System prompt hygiene: Avoid dummy placeholder syntax like
<parameter=KEY>VAL</parameter>in system instructions so zero-argument functions do not echo literal keys.
Usage (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))
Repository Contents
- Model Weights & Modeling Code:
model.safetensors,config.json,configuration_lfm3.py,modeling_lfm3.py,lfm3_conv.py,generation_config.json,tokenizer.json,tokenizer_config.json,chat_template.jinja,LICENSE - Audited Evaluation Artifacts (
eval_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-pass768-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 tasks
License
Released under the LFM Open License v1.0 (LICENSE), inherited from LiquidAI/LFM3-1.7B.
- Downloads last month
- 200
Model tree for Sayansantra/LFM3-2.0B-WSP-V4
Base model
LiquidAI/LFM3-1.7B-BaseDatasets used to train Sayansantra/LFM3-2.0B-WSP-V4
Motif-Technologies/agenttracer-tooluse
saidutta69/fable-5-premium
Collection including Sayansantra/LFM3-2.0B-WSP-V4
Evaluation results
- BFCL Non-Live Python AST Avg (1,000 tasks, 1536t + Prompt Fix) on Berkeley Function Calling Leaderboard (BFCL v3 Official Splits, 1,498 Tasks)self-reported88.880
- BFCL simple_python (400 tasks) on Berkeley Function Calling Leaderboard (BFCL v3 Official Splits, 1,498 Tasks)self-reported91.500
- BFCL multiple (200 tasks) on Berkeley Function Calling Leaderboard (BFCL v3 Official Splits, 1,498 Tasks)self-reported91.500
- BFCL parallel (200 tasks) on Berkeley Function Calling Leaderboard (BFCL v3 Official Splits, 1,498 Tasks)self-reported88.000
- BFCL parallel_multiple (200 tasks) on Berkeley Function Calling Leaderboard (BFCL v3 Official Splits, 1,498 Tasks)self-reported84.500
- BFCL live_simple (258 tasks) on Berkeley Function Calling Leaderboard (BFCL v3 Official Splits, 1,498 Tasks)self-reported74.420
- BFCL irrelevance (240 tasks) on Berkeley Function Calling Leaderboard (BFCL v3 Official Splits, 1,498 Tasks)self-reported48.750
- BFCL 6-Split Single-Turn Macro Avg (1,498 tasks) on Berkeley Function Calling Leaderboard (BFCL v3 Official Splits, 1,498 Tasks)self-reported79.780