Instructions to use User01110/LFM-2.5-350M-MathMini with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use User01110/LFM-2.5-350M-MathMini with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="User01110/LFM-2.5-350M-MathMini") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForMultimodalLM tokenizer = AutoTokenizer.from_pretrained("User01110/LFM-2.5-350M-MathMini") model = AutoModelForMultimodalLM.from_pretrained("User01110/LFM-2.5-350M-MathMini") 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 User01110/LFM-2.5-350M-MathMini with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "User01110/LFM-2.5-350M-MathMini" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "User01110/LFM-2.5-350M-MathMini", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/User01110/LFM-2.5-350M-MathMini
- SGLang
How to use User01110/LFM-2.5-350M-MathMini 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 "User01110/LFM-2.5-350M-MathMini" \ --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": "User01110/LFM-2.5-350M-MathMini", "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 "User01110/LFM-2.5-350M-MathMini" \ --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": "User01110/LFM-2.5-350M-MathMini", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use User01110/LFM-2.5-350M-MathMini with Docker Model Runner:
docker model run hf.co/User01110/LFM-2.5-350M-MathMini
| library_name: transformers | |
| pipeline_tag: text-generation | |
| base_model: LiquidAI/LFM2.5-350M | |
| tags: | |
| - causal-lm | |
| - sft | |
| - math | |
| - chatml | |
| - transformers | |
| # Math Curated SFT | |
| This is a full-model SFT checkpoint trained from `LiquidAI/LFM2.5-350M` on | |
| `User01110/math-curated-dataset`. | |
| ## Training | |
| - Method: TRL `SFTTrainer` | |
| - Dataset split: `train` | |
| - Training rows: 39040 | |
| - Epochs: 1 | |
| - Max sequence length: 1024 | |
| - Target style: full generated response | |
| - Format: the base tokenizer chat template via `tokenizer.apply_chat_template` | |
| - System prompt: `You are a math-focused assistant. Solve the user's math problem and follow the training format: Understanding Query, Drafting Answer, Refining The Answer, and Final Response.` | |
| ## Format | |
| Each row is formatted with: | |
| ```python | |
| messages = [ | |
| {"role": "system", "content": SYSTEM_PROMPT}, | |
| {"role": "user", "content": prompt}, | |
| ] | |
| prompt_text = tokenizer.apply_chat_template( | |
| messages, | |
| tokenize=False, | |
| add_generation_prompt=True, | |
| ) | |
| training_text = prompt_text + response + (tokenizer.eos_token or "") | |
| ``` | |
| ## Important limitation | |
| This model is trained on generated math-style data. Responses may contain | |
| incorrect arithmetic or flawed reasoning, and should not be treated as reliable | |
| mathematical answers without independent verification. | |
| ## Usage | |
| ```python | |
| from transformers import AutoModelForCausalLM, AutoTokenizer | |
| model_id = "User01110/LFM-2.5-350M-MathMini" | |
| tokenizer = AutoTokenizer.from_pretrained(model_id) | |
| model = AutoModelForCausalLM.from_pretrained(model_id) | |
| messages = [ | |
| {"role": "system", "content": "You are a math-focused assistant. Solve the user's math problem and follow the training format: Understanding Query, Drafting Answer, Refining The Answer, and Final Response."}, | |
| {"role": "user", "content": "John has 22 apples, he eats 10 of them, how many apples does john have now?"}, | |
| ] | |
| prompt = tokenizer.apply_chat_template( | |
| messages, | |
| tokenize=False, | |
| add_generation_prompt=True, | |
| ) | |
| inputs = tokenizer(prompt, return_tensors="pt") | |
| outputs = model.generate( | |
| **inputs, | |
| max_new_tokens=512, | |
| do_sample=False, | |
| repetition_penalty=1.1, | |
| pad_token_id=tokenizer.pad_token_id, | |
| eos_token_id=tokenizer.eos_token_id, | |
| ) | |
| print(tokenizer.decode(outputs[0], skip_special_tokens=False)) | |
| ``` | |