LiquidAI/LFM2-350M-Math
661.4k
1---2library_name: transformers3license: other4license_name: lfm1.05license_link: LICENSE6language:7- en8pipeline_tag: text-generation9tags:10- liquid11- lfm212- edge13base_model: LiquidAI/LFM2-350M14---15 16<center>17<div style="text-align: center;">18 <img 19 src="https://cdn-uploads.huggingface.co/production/uploads/61b8e2ba285851687028d395/2b08LKpev0DNEk6DlnWkY.png" 20 alt="Liquid AI"21 style="width: 100%; max-width: 100%; height: auto; display: inline-block; margin-bottom: 0.5em; margin-top: 0.5em;"22 />23</div>24<div style="display: flex; justify-content: center; gap: 0.5em;">25<a href="https://playground.liquid.ai/"><strong>Try LFM</strong></a> โข <a href="https://docs.liquid.ai/lfm/getting-started/welcome"><strong>Docs</strong></a> โข <a href="https://leap.liquid.ai/"><strong>LEAP</strong></a> โข <a href="https://discord.com/invite/liquid-ai"><strong>Discord</strong></a>26</div>27</center>28 29<br>30 31# LFM2-350M-Math32 33Based on [LFM2-350M](https://huggingface.co/LiquidAI/LFM2-350M), LFM2-350M-Math is a tiny reasoning model designed for tackling tricky math problems. 34 35You can find more information about other task-specific models in this [blog post](https://www.liquid.ai/blog/introducing-liquid-nanos-frontier-grade-performance-on-everyday-devices).36 37## ๐ Model details38 39**Generation parameters**: We strongly recommend using greedy decoding with a `temperature=0.6`, `top_p=0.95`, `min_p=0.1`, `repetition_penalty=1.05`.40 41**System prompt**: We recommend not using any system prompt.42 43**Supported languages**: English only.44 45**Chat template**: LFM2 uses a ChatML-like chat template as follows:46 47```48<|startoftext|><|im_start|>user49Find the sum of all integer bases $b>9$ for which $17_{b}$ is a divisor of $97_{b}$.<|im_end|>50<|im_start|>assistant51<|cot_start|>First, we need to convert $17_{b}$ and $97_{b}$ into base 10. [...]<|im_end|>52```53 54You can automatically apply it using the dedicated [`.apply_chat_template()`](https://huggingface.co/docs/transformers/en/chat_templating#applychattemplate) function from Hugging Face transformers.55 56> [!WARNING]57> โ ๏ธ The model is intended for single-turn conversations.58 59## ๐ Performance60 61Reasoning enables models to better structure their thought process, explore multiple solution strategies, and self-verify their final responses. Augmenting tiny models with extensive test-time compute in this way allows them to even solve challenging competition-level math problems. Our benchmark evaluations demonstrate that LFM2-350M-Math is highly capable for its size.62 6364 65As we are excited about edge deployment, our goal is to limit memory consumption and latency. Our post-training recipe leverages reinforcement learning to explicitly bring down response verbosity where it is not desirable. To this end, we combine explicit reasoning budgets with difficulty-aware advantage re-weighting. Please refer to our separate [blog post](https://www.liquid.ai/research/lfm-1b-math-can-small-models-be-concise-reasoners) for a detailed post-training recipe.66 6768 69## ๐ How to run70 71- Hugging Face: [LFM2-350M](https://huggingface.co/LiquidAI/LFM2-350M)72- llama.cpp: [LFM2-350M-Math-GGUF](https://huggingface.co/LiquidAI/LFM2-350M-Math-GGUF)73- LEAP: [LEAP model library](https://leap.liquid.ai/models?model=lfm2-350M-math)74 75You can use the following Colab notebooks for easy inference and fine-tuning:76 77| Notebook | Description | Link |78|-------|------|------|79| Inference | Run the model with Hugging Face's transformers library. | <a href="https://colab.research.google.com/drive/1TfLUH1vpIiJE6TdZTlMxhbp95f3BNKaD?usp=sharing"><img src="https://cdn-uploads.huggingface.co/production/uploads/61b8e2ba285851687028d395/vlOyMEjwHa_b_LXysEu2E.png" width="110" alt="Colab link"></a> |80| SFT (TRL) | Supervised Fine-Tuning (SFT) notebook with a LoRA adapter using TRL. | <a href="https://colab.research.google.com/drive/1j5Hk_SyBb2soUsuhU0eIEA9GwLNRnElF?usp=sharing"><img src="https://cdn-uploads.huggingface.co/production/uploads/61b8e2ba285851687028d395/vlOyMEjwHa_b_LXysEu2E.png" width="110" alt="Colab link"></a> |81| DPO (TRL) | Preference alignment with Direct Preference Optimization (DPO) using TRL. | <a href="https://colab.research.google.com/drive/1MQdsPxFHeZweGsNx4RH7Ia8lG8PiGE1t?usp=sharing"><img src="https://cdn-uploads.huggingface.co/production/uploads/61b8e2ba285851687028d395/vlOyMEjwHa_b_LXysEu2E.png" width="110" alt="Colab link"></a> |82| SFT (Axolotl) | Supervised Fine-Tuning (SFT) notebook with a LoRA adapter using Axolotl. | <a href="https://colab.research.google.com/drive/155lr5-uYsOJmZfO6_QZPjbs8hA_v8S7t?usp=sharing"><img src="https://cdn-uploads.huggingface.co/production/uploads/61b8e2ba285851687028d395/vlOyMEjwHa_b_LXysEu2E.png" width="110" alt="Colab link"></a> |83| SFT (Unsloth) | Supervised Fine-Tuning (SFT) notebook with a LoRA adapter using Unsloth. | <a href="https://colab.research.google.com/drive/1HROdGaPFt1tATniBcos11-doVaH7kOI3?usp=sharing"><img src="https://cdn-uploads.huggingface.co/production/uploads/61b8e2ba285851687028d395/vlOyMEjwHa_b_LXysEu2E.png" width="110" alt="Colab link"></a> |84 85## ๐ฌ Contact86 87- Got questions or want to connect? [Join our Discord community](https://discord.com/invite/liquid-ai)88- If you are interested in custom solutions with edge deployment, please contact [our sales team](https://www.liquid.ai/contact).89 90## Citation91 92```93@article{liquidai2025lfm2,94 title={LFM2 Technical Report},95 author={Liquid AI},96 journal={arXiv preprint arXiv:2511.23404},97 year={2025}98}99```