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
Update README.md
Browse files
README.md
CHANGED
|
@@ -60,7 +60,7 @@ model = AutoModelForCausalLM.from_pretrained(model_id)
|
|
| 60 |
|
| 61 |
messages = [
|
| 62 |
{"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."},
|
| 63 |
-
{"role": "user", "content": "John has 22 apples, he eats 10 of them,
|
| 64 |
]
|
| 65 |
prompt = tokenizer.apply_chat_template(
|
| 66 |
messages,
|
|
@@ -70,11 +70,8 @@ prompt = tokenizer.apply_chat_template(
|
|
| 70 |
inputs = tokenizer(prompt, return_tensors="pt")
|
| 71 |
outputs = model.generate(
|
| 72 |
**inputs,
|
| 73 |
-
max_new_tokens=
|
| 74 |
-
do_sample=
|
| 75 |
-
temperature=0.7,
|
| 76 |
-
top_k=40,
|
| 77 |
-
top_p=0.95,
|
| 78 |
repetition_penalty=1.1,
|
| 79 |
pad_token_id=tokenizer.pad_token_id,
|
| 80 |
eos_token_id=tokenizer.eos_token_id,
|
|
|
|
| 60 |
|
| 61 |
messages = [
|
| 62 |
{"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."},
|
| 63 |
+
{"role": "user", "content": "John has 22 apples, he eats 10 of them, how many apples does john have now?"},
|
| 64 |
]
|
| 65 |
prompt = tokenizer.apply_chat_template(
|
| 66 |
messages,
|
|
|
|
| 70 |
inputs = tokenizer(prompt, return_tensors="pt")
|
| 71 |
outputs = model.generate(
|
| 72 |
**inputs,
|
| 73 |
+
max_new_tokens=512,
|
| 74 |
+
do_sample=False,
|
|
|
|
|
|
|
|
|
|
| 75 |
repetition_penalty=1.1,
|
| 76 |
pad_token_id=tokenizer.pad_token_id,
|
| 77 |
eos_token_id=tokenizer.eos_token_id,
|