Instructions to use mkurman/lfm2-350M-med with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use mkurman/lfm2-350M-med with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="mkurman/lfm2-350M-med") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("mkurman/lfm2-350M-med") model = AutoModelForCausalLM.from_pretrained("mkurman/lfm2-350M-med") 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=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - llama-cpp-python
How to use mkurman/lfm2-350M-med with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="mkurman/lfm2-350M-med", filename="lfm2-350M-med-q8_0.gguf", )
llm.create_chat_completion( messages = [ { "role": "user", "content": "What is the capital of France?" } ] ) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- llama.cpp
How to use mkurman/lfm2-350M-med with llama.cpp:
Install from brew
brew install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf mkurman/lfm2-350M-med:Q8_0 # Run inference directly in the terminal: llama-cli -hf mkurman/lfm2-350M-med:Q8_0
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf mkurman/lfm2-350M-med:Q8_0 # Run inference directly in the terminal: llama-cli -hf mkurman/lfm2-350M-med:Q8_0
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf mkurman/lfm2-350M-med:Q8_0 # Run inference directly in the terminal: ./llama-cli -hf mkurman/lfm2-350M-med:Q8_0
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf mkurman/lfm2-350M-med:Q8_0 # Run inference directly in the terminal: ./build/bin/llama-cli -hf mkurman/lfm2-350M-med:Q8_0
Use Docker
docker model run hf.co/mkurman/lfm2-350M-med:Q8_0
- LM Studio
- Jan
- vLLM
How to use mkurman/lfm2-350M-med with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "mkurman/lfm2-350M-med" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mkurman/lfm2-350M-med", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/mkurman/lfm2-350M-med:Q8_0
- SGLang
How to use mkurman/lfm2-350M-med 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 "mkurman/lfm2-350M-med" \ --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": "mkurman/lfm2-350M-med", "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 "mkurman/lfm2-350M-med" \ --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": "mkurman/lfm2-350M-med", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Ollama
How to use mkurman/lfm2-350M-med with Ollama:
ollama run hf.co/mkurman/lfm2-350M-med:Q8_0
- Unsloth Studio new
How to use mkurman/lfm2-350M-med with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for mkurman/lfm2-350M-med to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for mkurman/lfm2-350M-med to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for mkurman/lfm2-350M-med to start chatting
- Pi new
How to use mkurman/lfm2-350M-med with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama-server -hf mkurman/lfm2-350M-med:Q8_0
Configure the model in Pi
# Install Pi: npm install -g @mariozechner/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "mkurman/lfm2-350M-med:Q8_0" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Hermes Agent new
How to use mkurman/lfm2-350M-med with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama-server -hf mkurman/lfm2-350M-med:Q8_0
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 mkurman/lfm2-350M-med:Q8_0
Run Hermes
hermes
- Docker Model Runner
How to use mkurman/lfm2-350M-med with Docker Model Runner:
docker model run hf.co/mkurman/lfm2-350M-med:Q8_0
- Lemonade
How to use mkurman/lfm2-350M-med with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull mkurman/lfm2-350M-med:Q8_0
Run and chat with the model
lemonade run user.lfm2-350M-med-Q8_0
List all available models
lemonade list
lfm2-350M-med
Small medical fine-tune on top of LiquidAI’s LFM2-350M.
This checkpoint specializes the 350M LFM2 base for medical Q&A and tool-augmented search, using a light-weight recipe designed for laptops/edge boxes.
⚠️ Medical safety: This model is not a clinician. It may hallucinate and should not be used for diagnosis or treatment. Always seek qualified medical supervision.
TL;DR
- Base: LiquidAI/LFM2-350M.
- Training:
- SFT on open-source medical data + tool-calling (search) traces
- DPO preference alignment using MedMCQA as a preference signal
- Post-merge with the base via Arcee Fusion (MergeKit) for controlled weight fusion
- Eval (author’s harness)
- MMLU-Pro: 19.46 (vs 18.76 base in same harness)
- IFEVAL: 52.595 (vs 61.72 base in same harness)
Note: LFM2’s official IFEVAL uses a different internal harness and reports ~65 on IFEVAL for the base; numbers are not directly comparable across harnesses.
What’s inside
Base model: LFM2-350M
- Designed for on-device inference, with strong CPU latency and a ChatML-like template.
- Supports tool use with dedicated special tokens (
<tool_call>,</tool_call>, etc.).
See the base card for the full template and examples.
Specialization steps
Domain SFT (medical + tools)
- Instruction-style Q&A from open medical sources and synthetic conversions.
- Tool-use (search) supervised traces to teach function calling patterns.
Preference alignment (DPO)
- Direct Preference Optimization with MedMCQA-derived preferences to bias toward clinically reasonable short answers.
- Rationale: DPO is simple, stable at a small scale, and works well for short-form medical responses.
Model fusion (Arcee Fusion)
- Final merge uses Arcee Fusion in MergeKit, which selectively fuses parameters to avoid over-averaging and can be configured via
merge_method: arcee_fusion.
- Final merge uses Arcee Fusion in MergeKit, which selectively fuses parameters to avoid over-averaging and can be configured via
Intended use & limitations
Use: education, research.
Don’t use: any medical advice.
Evaluation
All results below were run with the author’s harness; they will differ from LiquidAI’s internal suite and Open LLM Leaderboard settings.
| Benchmark | lfm2-350M-med | LFM2-350M (same harness) |
|---|---|---|
| MMLU-Pro | 19.46 | 18.76 |
| IFEVAL | 52.595 | 61.72 |
- MMLU-Pro raises difficulty with 10 choices and more reasoning-heavy items—small models typically drop vs standard MMLU, so small absolute movements are meaningful.
- IFEVAL measures verifiable instruction-following; scores depend heavily on prompt templates and verification scripts.
Quickstart (Transformers)
from transformers import AutoTokenizer, AutoModelForCausalLM
model_id = "mkurman/lfm2-350M-med"
tok = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype="bfloat16")
messages = [
{"role": "system", "content": "You are a careful medical assistant. Cite sources and warn that outputs are not medical advice."},
{"role": "user", "content": "Briefly explain the difference between cellulitis and erysipelas."}
]
prompt = tok.apply_chat_template(messages, add_generation_prompt=True, tokenize=False)
out = model.generate(**tok(prompt, return_tensors="pt"), max_new_tokens=256)
print(tok.decode(out[0], skip_special_tokens=True))
- Downloads last month
- 50
Model tree for mkurman/lfm2-350M-med
Base model
LiquidAI/LFM2-350M