Instructions to use LiraNuna/LFM3-1.7B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use LiraNuna/LFM3-1.7B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="LiraNuna/LFM3-1.7B", 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("LiraNuna/LFM3-1.7B", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("LiraNuna/LFM3-1.7B", 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 LiraNuna/LFM3-1.7B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "LiraNuna/LFM3-1.7B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "LiraNuna/LFM3-1.7B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/LiraNuna/LFM3-1.7B
- SGLang
How to use LiraNuna/LFM3-1.7B 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 "LiraNuna/LFM3-1.7B" \ --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": "LiraNuna/LFM3-1.7B", "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 "LiraNuna/LFM3-1.7B" \ --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": "LiraNuna/LFM3-1.7B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use LiraNuna/LFM3-1.7B with Docker Model Runner:
docker model run hf.co/LiraNuna/LFM3-1.7B
- LiraNuna/LFM3-1.7B
- The Problem: Compulsive
<think>Loops & Non-Thinking Leaks - How We Fixed It (Zero Eval-Set Overlap)
- Before vs. After โ Scores & Loop Reduction (
~43,000Items)- 1. High-Budget Reasoning, Coding, STEM & Instruction Following (
4K / 8KToken Caps) - 2. Strict-Budget Latency & Conciseness Stress Test (
1K / 2KToken Caps) - 3. Multi-Step Logic โ ALL 13 BBH Tasks (
n = 3,146,2KCap) - 4. Tool Calling โ ALL 12 BFCL v4 Splits (
n = 3,625,enable_thinking=False) - 5. Long-Context & Zero-Forgetting General Suite (
~31,700Items)
- 1. High-Budget Reasoning, Coding, STEM & Instruction Following (
- Recommended Decoding Settings
- Limitations & Trade-Offs
- License, Attribution & Modification Notice
- The Problem: Compulsive
LiraNuna/LFM3-1.7B
A loop-fixed, reasoning-uplifted drop-in successor to LiquidAI/LFM3-1.7B, verified across ~43,000 benchmark items with zero benchmark contamination.
- GGUF Quantizations (
BF16,Q8_0,Q6_K,Q5_K_M,Q4_K_M):LiraNuna/LFM3-1.7B-GGUF
The Problem: Compulsive <think> Loops & Non-Thinking Leaks
LiquidAI/LFM3-1.7B is a remarkably strong 1.7B tri-hybrid reasoning model, but in real-world deployment and deterministic evaluation (do_sample=False), it suffers from three recurring failure modes:
- Compulsive
<think>Re-Checking Loops: On multi-step logic, STEM, coding, and constrained-writing tasks, the model frequently enters endless self-doubt cycles inside<think>("Wait, let me double-check... Alternatively, what if..."), burning through2Kโ8K+tokens without ever emitting</think>or producing a final answerโlooping on97%of logic-grid puzzles,29.5%ofMMLU-Pro STEM(@ 4K),15.2%ofHumanEval(@ 4K), and50.8%ofIFEval(@ 2K). <think>Leakage Whenenable_thinking=False: On long-context retrieval tasks (RULER 4K/16K), the base model ignoresenable_thinking=Falseand opens<think>anyway, exhausting short answer budgets (67.7%accuracy).- Tool Over-Calling on Irrelevant Queries: On real-world irrelevant tool prompts (
BFCL live_irrelevance), the base model invokes functions when no matching tool applies (68.6%).
How We Fixed It (Zero Eval-Set Overlap)
Rather than heavy SFTโwhich typically degrades small models' knowledge and tool precisionโwe used a lightweight two-stage surgical pipeline:
- Weight-Space Programming (WSP): Inspired by Sparks of Weight-Space Programming (Takehi et al., MIT CSAIL), we probed
feed_forward.w2MLP activations at the exact token positions preceding compulsive re-check triggers (Wait,Let,Alternatively,Check,Hmm) versus clean</think>closures across layers14, 20, 22, 23. Editing only the topk=64loop-driving neurons per layer (0.0303%of parameters, zero gradient steps) while protecting tool-abstention and safety circuits immediately broke the vast majority of thinking loops. - Multi-Teacher Top-64 KL Self-Distillation (
r=8LoRA, merged tobf16): Starting from the WSP model, we ran tight Top-64 KL self-distillation (lr โ 5e-5, 2 epochs) combining:- Strictly cleanly-closed (
single </think>,0 <tool_call>) reasoning/coding traces from officialtrainsplits (GSM8K train,MBPP train,ARC-Challenge train) and synthetic constrained-writing prompts. - Zero-overlap synthetic REST API abstention prompts (lifting
BFCL live_irrelevancewithout hurting valid calls). - Zero-overlap synthetic long-context MK-NIAH/VT prompts (
enable_thinking=False) with token-0<think>hinge suppression (eliminating non-thinking<think>leaks onRULER). - Hard-mined synthetic 3-shot no-tool boundary suppression (eliminating hallucinated
<tool_call>emissions when no<tools>schema is provided). - Zero-overlap synthetic factual passages anchored to Raw Base raw
yes/nolog-odds (preserving unprompted reading-comprehension calibration without touchingBoolQ).
- Strictly cleanly-closed (
Zero Contamination: No validation or test items from any benchmark reported below were ever seen during training.
Before vs. After โ Scores & Loop Reduction (~43,000 Items)
All evaluations were run identically in bfloat16 (attn_implementation="sdpa", deterministic greedy decoding do_sample=False, </think>-stripped final-answer scoring). no_close counts responses that hit the token cap without ever emitting </think>.
1. High-Budget Reasoning, Coding, STEM & Instruction Following (4K / 8K Token Caps)
| Benchmark | n |
Max Tokens | Base Score | LiraNuna Score |
Score Delta | Base Loops (no_close) |
LiraNuna Loops |
Loop Reduction |
|---|---|---|---|---|---|---|---|---|
| HumanEval FULL (unseen) | 164 |
4,096 |
85.37% (140) |
89.63% (147) |
+4.26% |
25 (15.2%) |
2 (1.2%) |
-92.0% |
| MMLU-Pro STEM CoT (unseen) | 400 |
4,096 |
66.00% (264) |
70.75% (283) |
+4.75% |
118 (29.5%) |
1 (0.25%) |
-99.2% |
| โโ Chemistry | 80 |
4,096 |
67.5% |
77.5% |
+10.0% |
19 |
0 |
-100% |
| โโ Math | 80 |
4,096 |
87.5% |
93.8% |
+6.3% |
11 |
0 |
-100% |
| โโ Computer Science | 80 |
4,096 |
62.5% |
67.5% |
+5.0% |
22 |
1 |
-95.5% |
| โโ Engineering | 80 |
4,096 |
36.2% |
40.0% |
+3.8% |
51 |
0 |
-100% |
| โโ Physics | 80 |
4,096 |
76.2% |
75.0% |
-1.2% |
15 |
0 |
-100% |
| IFEval FULL (p-strict / p-loose) | 541 |
8,192 |
88.91% / 90.94% |
88.72% / 91.68% |
-0.19% / +0.74% |
37 (6.8%) |
3 (0.55%) |
-91.9% |
| โโ IFEval inst-strict / inst-loose | 541 |
8,192 |
91.49% / 92.81% |
92.57% / 94.48% |
+1.08% / +1.67% |
12,249 chars | 6,356 chars | -48.1% length |
| MATH-500 FULL (unseen) | 500 |
8,192 |
85.80% (429) |
83.20% (416) |
-2.60% |
31 (6.2%) |
2 (0.4%) |
-93.5% |
| MBPP FULL | 500 |
4,096 |
72.40% (362) |
66.00% (330) |
-6.40% |
76 (15.2%) |
0 (0.0%) |
-100.0% |
Combined 4K/8K Total |
2,105 |
โ | โ | โ | โ | 287 (13.63%) |
8 (0.38%) |
-97.2% |
2. Strict-Budget Latency & Conciseness Stress Test (1K / 2K Token Caps)
| Benchmark | n |
Max Tokens | Base Score | LiraNuna Score |
Score Delta | Base Loops (no_close) |
LiraNuna Loops |
Loop Reduction |
|---|---|---|---|---|---|---|---|---|
| GSM8K FULL (flex / strict) | 1,319 |
2,048 |
90.67% / 27.29% |
92.57% / 48.60% |
+1.90% / +21.31% |
55 (4.2%) |
6 (0.45%) |
-89.1% |
| IFEval FULL (p-strict / i-strict) | 541 |
2,048 |
57.49% / 64.87% |
75.42% / 80.94% |
+17.93% / +16.07% |
275 (92 rep) |
88 (19 rep) |
-68.0% (-79% rep) |
| MATH-500 FULL (unseen) | 500 |
2,048 |
67.40% (337) |
73.40% (367) |
+6.00% |
124 (24.8%) |
58 (11.6%) |
-53.2% |
| HumanEval FULL (unseen) | 164 |
1,024 |
42.07% (69) |
53.66% (88) |
+11.59% |
115 (70.1%) |
67 (40.9%) |
-41.7% |
| MBPP FULL | 500 |
1,024 |
41.00% (205) |
48.20% (241) |
+7.20% |
287 (57.4%) |
105 (21.0%) |
-63.4% |
| Logic-Grid Puzzles (2 splits) | 106 |
4,096 |
20.8% parse (1.1% cell) |
84.0% parse (7.9% cell) |
+63.2% parse |
103 (97.2%) |
7 (6.6%) |
-93.2% |
3. Multi-Step Logic โ ALL 13 BBH Tasks (n = 3,146, 2K Cap)
| BBH Suite / Task | n |
Base Score | LiraNuna Score |
Score Delta | Base Loops | LiraNuna Loops |
|---|---|---|---|---|---|---|
| 7-Task Core BBH Combined | 1,750 |
81.03% (1,418) |
84.00% (1,470) |
+2.97% (+52) |
284 (81 rep) |
36 (7 rep, -91%!) |
| 6 Unseen BBH Combined | 1,396 |
74.93% (1,046) |
82.59% (1,153) |
+7.66% (+107) |
260 |
39 (-85.0%) |
โโ web_of_lies (unseen) |
250 |
98.40% |
100.00% |
+1.60% |
1 |
0 |
โโ navigate (unseen) |
250 |
74.40% |
94.80% |
+20.40% |
50 |
4 |
โโ tracking_shuffled_objects_7 (unseen) |
250 |
42.00% |
62.00% |
+20.00% |
78 |
12 |
โโ geometric_shapes (unseen) |
250 |
60.00% |
61.20% |
+1.20% |
125 |
22 (0 <tool_call>) |
โโ penguins_in_a_table (unseen) |
146 |
78.77% |
78.77% |
0.00% |
3 |
0 |
โโ reasoning_about_colored_objects (unseen) |
250 |
97.60% |
97.20% |
-0.40% |
3 |
1 |
| ALL 13 BBH TASKS COMBINED | 3,146 |
78.32% (2,464) |
83.38% (2,623) |
+5.06% (+159) |
544 |
75 (-86.2%) |
4. Tool Calling โ ALL 12 BFCL v4 Splits (n = 3,625, enable_thinking=False)
| BFCL v4 Split | n |
Base Score | LiraNuna Score |
Score Delta |
|---|---|---|---|---|
Main 7 Splits (simple_python, multiple, parallel, irrelevance, live_multiple, live_parallel, live_irrelevance) |
2,993 |
77.45% (2,318) |
79.89% (2,391) |
+2.44% (+73) |
โโ Highlight: live_irrelevance |
884 |
68.60% (606) |
76.02% (672) |
+7.42% (+66) |
Unseen 5 Splits (live_simple, simple_java, simple_javascript, parallel_multiple, live_parallel_multiple) |
632 |
71.68% (453) |
72.47% (458) |
+0.79% (+5) |
| ALL 12 BFCL v4 SPLITS | 3,625 |
76.44% (2,771) |
78.59% (2,849) |
+2.15% (+78) |
5. Long-Context & Zero-Forgetting General Suite (~31,700 Items)
| Benchmark | n |
Base Score | LiraNuna Score |
Delta |
|---|---|---|---|---|
RULER 4K + 16K (S-NIAH, MK-NIAH, VT) |
96 |
67.71% (65/96) |
98.96% (95/96) |
+31.25% (+30) |
AA-LCR 100K-tok (lexical proxy) |
30 |
12/30 (1,529s) |
13/30 (1,258s) |
+1 (18% faster) |
| TruthfulQA MC2 FULL | 817 |
52.56% |
64.58% |
+12.02% |
| ARC-Challenge FULL (acc / acc_norm) | 1,172 |
24.06% / 26.28% |
26.45% / 28.84% |
+2.39% / +2.56% |
| MMLU FULL (57 subjects) | 14,042 |
49.59% |
49.73% |
+0.14% |
| MMLU-Pro (5-shot direct LL, no CoT) | 1,000 |
20.90% |
21.10% |
+0.20% |
| HellaSwag FULL (acc / acc_norm) | 10,042 |
41.09% / 53.68% |
41.67% / 54.19% |
+0.58% / +0.51% |
| BoolQ FULL | 3,270 |
75.57% |
75.02% |
-0.55% |
| WinoGrande FULL | 1,267 |
54.93% |
54.46% |
-0.47% |
| WikiText-2 Word PPL (lower = better) | 62 docs |
16.78 (0.7609 bpb) |
16.87 (0.7623 bpb) |
+0.09 (flat) |
Recommended Decoding Settings
- Deterministic Math / Code / Logic / Tool Calling:
do_sample=False,max_new_tokens=4096(or8192for competition math / complex multi-constraint writing). - General Chat:
temperature=0.1,top_k=50,repetition_penalty=1.1(defaultgeneration_config.json).
Limitations & Trade-Offs
- Because
LiraNuna/LFM3-1.7Bterminates<think>much more decisively (cutting unclosed runs by-97.2%and halving IFEval output length), at very high token budgets (4Kโ8K) it trades a small margin onMATH-500 @ 8K(83.2%vs.85.8%,-2.6%) andMBPP @ 4K(66.0%vs.72.4%,-6.4%,0/500loops), while substantially outperforming the base model onHumanEval @ 4K(+4.26%),MMLU-Pro STEM @ 4K(+4.75%),IFEval @ 8K(loose/inst),GSM8K(+1.90%),13-Task BBH(+5.06%),BFCL(+2.15%),RULER(+31.25%), and every1Kโ2Klatency-bounded benchmark. - Inherits the 1.7B parameter capacity of
LiquidAI/LFM3-1.7Bon long-tail factual trivia.
License, Attribution & Modification Notice
- Base Model & Copyright: This model is a community derivative work of
LiquidAI/LFM3-1.7B(Copyright ยฉ Liquid AI, Inc.), independently fine-tuned and not endorsed by Liquid AI. - License: Distributed under the LFM Open License v1.0 (
lfm1.0). A verbatim copy is included in the repository root (LICENSE). Please review Section 5 (the$10MUSD annual revenue threshold for free commercial use) before commercial deployment. - Modified Files Notice (Section 4):
- Modified:
model.safetensors(weights updated via Weight-Space Programming and mergedr=8LoRA Top-64 KL self-distillation) andREADME.md(this model card). - Unmodified from
LiquidAI/LFM3-1.7B:config.json,configuration_lfm3.py,modeling_lfm3.py,lfm3_conv.py,generation_config.json,chat_template.jinja,tokenizer.json,tokenizer_config.json,special_tokens_map.json, andLICENSE.
- Modified:
- Downloads last month
- -