Safetensors
GGUF
English
Russian
lfm3
reasoning
test-time-compute
inference-time-scaling
code-generation
llama.cpp
negative-results
conversational
Instructions to use HelioAI/LFM3-1.7B-inference-modules-experiments with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use HelioAI/LFM3-1.7B-inference-modules-experiments with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf HelioAI/LFM3-1.7B-inference-modules-experiments:Q5_K_M # Run inference directly in the terminal: llama cli -hf HelioAI/LFM3-1.7B-inference-modules-experiments:Q5_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf HelioAI/LFM3-1.7B-inference-modules-experiments:Q5_K_M # Run inference directly in the terminal: llama cli -hf HelioAI/LFM3-1.7B-inference-modules-experiments:Q5_K_M
Build from source code
git clone https://github.com/ggml-org/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-app # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama serve -hf HelioAI/LFM3-1.7B-inference-modules-experiments:Q5_K_M # Run inference directly in the terminal: ./build/bin/llama cli -hf HelioAI/LFM3-1.7B-inference-modules-experiments:Q5_K_M
Use Docker
docker model run hf.co/HelioAI/LFM3-1.7B-inference-modules-experiments:Q5_K_M
- Llama new
- LM Studio
- Jan
- Ollama
How to use HelioAI/LFM3-1.7B-inference-modules-experiments with Ollama:
ollama run hf.co/HelioAI/LFM3-1.7B-inference-modules-experiments:Q5_K_M
- Unsloth Desktop
- Pi
How to use HelioAI/LFM3-1.7B-inference-modules-experiments with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf HelioAI/LFM3-1.7B-inference-modules-experiments:Q5_K_M
Configure the model in Pi
# Install Pi: npm install -g @earendil-works/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "HelioAI/LFM3-1.7B-inference-modules-experiments:Q5_K_M" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Docker Model Runner
How to use HelioAI/LFM3-1.7B-inference-modules-experiments with Docker Model Runner:
docker model run hf.co/HelioAI/LFM3-1.7B-inference-modules-experiments:Q5_K_M
- Lemonade
How to use HelioAI/LFM3-1.7B-inference-modules-experiments with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull HelioAI/LFM3-1.7B-inference-modules-experiments:Q5_K_M
Run and chat with the model
lemonade run user.LFM3-1.7B-inference-modules-experiments-Q5_K_M
List all available models
lemonade list
- Hermes Agent
How to use HelioAI/LFM3-1.7B-inference-modules-experiments with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf HelioAI/LFM3-1.7B-inference-modules-experiments:Q5_K_M
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default HelioAI/LFM3-1.7B-inference-modules-experiments:Q5_K_M
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use HelioAI/LFM3-1.7B-inference-modules-experiments with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf HelioAI/LFM3-1.7B-inference-modules-experiments:Q5_K_M
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:8080/v1 \ --custom-model-id "HelioAI/LFM3-1.7B-inference-modules-experiments:Q5_K_M" \ --custom-provider-id llama-cpp \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
File size: 3,809 Bytes
67ebcef | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | """'Correct-reasoning' direction from discordant pairs: problems where one of the model's two samples is right and
the other wrong. Difficulty is controlled (same problem), length is controlled (both responses are averaged over the
same number of leading tokens, at most --n-tok). direction[layer] = mean over pairs of (h_correct - h_wrong).
usage: extract_dir_correct.py --gen results/dev_orig/dev.jsonl --graded results/dev_orig/graded.jsonl
--items data/train/dev.jsonl --out results/cvec/cor.pt"""
import argparse, json, collections, torch
from transformers import AutoModelForCausalLM, AutoTokenizer
import transformers.integrations.sdpa_attention as _sdpa
# Windows torch has no flash kernel: masked/GQA SDPA would fall back to the O(L^2)-memory math kernel.
# Expanding K/V instead keeps it on the memory-efficient kernel.
_sdpa.use_gqa_in_sdpa = lambda *a, **k: False
ap = argparse.ArgumentParser()
for a in ["--gen", "--graded", "--items", "--out"]:
ap.add_argument(a, required=True)
ap.add_argument("--model", default="models/LFM3-1.7B")
ap.add_argument("--n-tok", type=int, default=2048)
args = ap.parse_args()
tok = AutoTokenizer.from_pretrained(args.model)
model = AutoModelForCausalLM.from_pretrained(args.model, dtype=torch.bfloat16, attn_implementation="sdpa",
trust_remote_code=True).cuda().eval()
L, H = model.config.num_hidden_layers, model.config.hidden_size
items = {json.loads(l)["id"]: json.loads(l) for l in open(args.items, encoding="utf-8")}
ok = {(g["id"], g["sample"]): g["correct"] for g in map(json.loads, open(args.graded, encoding="utf-8"))}
recs = collections.defaultdict(dict)
for l in open(args.gen, encoding="utf-8"):
r = json.loads(l)
if "tokens" in r and (r["id"], r["sample"]) in ok:
recs[r["id"]][r["sample"]] = r
pairs = []
for pid, s in recs.items():
if len(s) == 2 and ok[(pid, 0)] != ok[(pid, 1)]:
c, w = (s[0], s[1]) if ok[(pid, 0)] else (s[1], s[0])
pairs.append((pid, c, w))
print(len(pairs), "discordant pairs", collections.Counter(items[p]["task"] for p, _, _ in pairs), flush=True)
cap = {}
for k, layer in enumerate(model.model.layers):
layer.register_forward_hook(lambda m, i, o, k=k: cap.__setitem__(k, (o[0] if isinstance(o, tuple) else o)[0]))
def mean_states(prompt_ids, resp, n):
ids = prompt_ids + resp[:n]
with torch.no_grad():
model(input_ids=torch.tensor([ids], device="cuda"), use_cache=False)
return torch.stack([cap[k][len(prompt_ids):].float().mean(0) for k in range(L)]).double().cpu()
diff = torch.zeros(L, H, dtype=torch.float64)
norm = torch.zeros(L, dtype=torch.float64)
per_pair = []
for i, (pid, c, w) in enumerate(pairs):
p = tok.apply_chat_template([{"role": "user", "content": items[pid]["prompt"]}], tokenize=True,
add_generation_prompt=True, return_dict=False)
n = min(len(c["tokens"]), len(w["tokens"]), args.n_tok)
hc, hw = mean_states(p, c["tokens"], n), mean_states(p, w["tokens"], n)
diff += hc - hw
norm += 0.5 * (hc.norm(dim=-1) + hw.norm(dim=-1))
per_pair.append((hc - hw).float())
if i % 10 == 0:
print(i, flush=True)
d = (diff / len(pairs)).float()
avg_norm = (norm / len(pairs)).float()
P = torch.stack(per_pair) # pairs x L x H
for k in range(L):
loo = (P[:, k].sum(0, keepdim=True) - P[:, k]) / (len(P) - 1) # mean of the OTHER pairs (leave-one-out)
agree = ((P[:, k] * loo).sum(-1) > 0).float().mean() # held-out agreement; 0.5 = no consistent direction
print(f"layer {k:2d} |dir| {d[k].norm():6.3f} |h| {avg_norm[k]:6.2f} ratio {d[k].norm() / avg_norm[k]:.3f} pair-agreement {agree:.2f}")
torch.save({"dir": d, "avg_norm": avg_norm, "count": len(pairs)}, args.out)
print("saved", args.out)
|