Instructions to use shuff57/lfm2-24b-phase1-reasoning with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use shuff57/lfm2-24b-phase1-reasoning with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="shuff57/lfm2-24b-phase1-reasoning") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("shuff57/lfm2-24b-phase1-reasoning") model = AutoModelForCausalLM.from_pretrained("shuff57/lfm2-24b-phase1-reasoning") 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]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use shuff57/lfm2-24b-phase1-reasoning with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "shuff57/lfm2-24b-phase1-reasoning" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "shuff57/lfm2-24b-phase1-reasoning", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/shuff57/lfm2-24b-phase1-reasoning
- SGLang
How to use shuff57/lfm2-24b-phase1-reasoning 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 "shuff57/lfm2-24b-phase1-reasoning" \ --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": "shuff57/lfm2-24b-phase1-reasoning", "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 "shuff57/lfm2-24b-phase1-reasoning" \ --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": "shuff57/lfm2-24b-phase1-reasoning", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Unsloth Studio
How to use shuff57/lfm2-24b-phase1-reasoning 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 shuff57/lfm2-24b-phase1-reasoning 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 shuff57/lfm2-24b-phase1-reasoning to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for shuff57/lfm2-24b-phase1-reasoning to start chatting
Load model with FastModel
pip install unsloth from unsloth import FastModel model, tokenizer = FastModel.from_pretrained( model_name="shuff57/lfm2-24b-phase1-reasoning", max_seq_length=2048, ) - Docker Model Runner
How to use shuff57/lfm2-24b-phase1-reasoning with Docker Model Runner:
docker model run hf.co/shuff57/lfm2-24b-phase1-reasoning
LFM2-24B-A2B — Phase 1 Reasoning (OGRE)
This is Phase 1 of the OGRE (OllamaGradingRubricEvaluator) fine-tuning pipeline.
LFM2-24B-A2B fine-tuned on 13,201 synthetic chain-of-thought reasoning examples to improve structured analytical reasoning before domain-specific grading fine-tuning in Phase 2.
Model Details
| Field | Value |
|---|---|
| Base model | LiquidAI/LFM2-24B-A2B |
| Architecture | LFM2 MoE (Mixture of Experts), 24B total / ~2.3B active params per token |
| Fine-tune method | LoRA (rank 16, alpha 16) via Unsloth |
| Training data | shuff57/ogre-phase1-synth — 13,201 synthetic reasoning examples |
| Training steps | 1,568 steps (1 epoch) |
| Hardware | Google Colab A100 40GB + High-RAM (80GB system RAM) |
| Export format | Merged 16-bit safetensors |
| Phase | Phase 1 of 2 — reasoning pre-training before OGRE grading fine-tune |
Training Configuration
# LoRA config
LORA_RANK = 16
LORA_ALPHA = 16
LORA_DROPOUT = 0.0
LORA_TARGET_MODULES = [
"q_proj", "k_proj", "v_proj",
"out_proj", "in_proj", # LFM2 attention projections
"w1", "w2", "w3", # MoE expert MLP layers
]
# SFTConfig
per_device_train_batch_size = 1
gradient_accumulation_steps = 8 # effective batch size = 8
num_train_epochs = 1
learning_rate = 2e-5
lr_scheduler_type = "cosine"
warmup_ratio = 0.1
optim = "adamw_8bit"
bf16 = True
packing = False # disabled for MoE routing stability
Training Data
- Dataset: shuff57/ogre-phase1-synth
- Size: 13,201 synthetic chain-of-thought reasoning examples
- Format: ChatML (system / user / assistant turns)
- Split: 95% train (12,540 examples) / 5% validation (661 examples)
- Loss masking: Response-only (assistant turns only) via
train_on_responses_only
Installation Notes
LFM2-24B-A2B requires specific package versions:
pip install unsloth_zoo unsloth
pip install transformers==5.3.0 # >=5.0.0 required for lfm2_moe arch
pip install trl==0.22.2 datasets==4.3.0
Important: device_map="cpu" required during loading to avoid VRAM OOM during MoE expert weight conversion. Use a runtime with ≥50GB system RAM.
Usage
from unsloth import FastLanguageModel
import torch
model, tokenizer = FastLanguageModel.from_pretrained(
model_name = "shuff57/lfm2-24b-phase1-reasoning",
max_seq_length = 8192,
load_in_4bit = True,
dtype = torch.bfloat16,
device_map = "cpu",
)
FastLanguageModel.for_inference(model)
messages = [
{"role": "system", "content": "You are a careful analytical reasoner."},
{"role": "user", "content": "Your question here."},
]
inputs = tokenizer.apply_chat_template(
messages,
tokenize=True,
add_generation_prompt=True,
return_tensors="pt",
).to(model.device)
outputs = model.generate(
input_ids = inputs,
max_new_tokens = 1024,
temperature = 0.1,
top_k = 50,
repetition_penalty = 1.05,
)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
OGRE Pipeline
This model is Phase 1 of a two-phase fine-tuning pipeline:
| Phase | Model | Dataset | Purpose |
|---|---|---|---|
| Phase 1 | This model | 13,201 synthetic reasoning examples | Reasoning capability |
| Phase 2 | shuff57/lfm2-24b-grader (coming soon) | 239 OGRE grading examples | Domain-specific grading |
Phase 2 loads this model and fine-tunes further on OGRE statistics grading data, then exports as GGUF Q4_K_M for local Ollama deployment as lfm2-stat-grader.
Framework
Trained with Unsloth and HuggingFace TRL.
- Downloads last month
- 6
