> ## Documentation Index
> Fetch the complete documentation index at: https://liquidai-example-leonie-demo.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# LFM2-350M-Math

> 350M parameter model for math problem solving

<a href="/lfm/models/liquid-nanos" className="back-button">← Back to Liquid Nanos</a>

LFM2-350M-Math is a tiny reasoning model optimized for mathematical problem solving. It provides step-by-step solutions while maintaining a small footprint for edge deployment.

<div style={{display: 'flex', gap: '0.5rem', margin: '0.5rem 0 1.5rem 0'}}>
  <a href="https://huggingface.co/LiquidAI/LFM2-350M-Math" style={{padding: '0.35rem 0.7rem', borderRadius: '4px', fontSize: '0.85rem', fontWeight: 600, textDecoration: 'none', backgroundColor: '#fbbf24'}}><span style={{color: '#000'}}>HF</span></a>
  <a href="https://huggingface.co/LiquidAI/LFM2-350M-Math-GGUF" style={{padding: '0.35rem 0.7rem', borderRadius: '4px', fontSize: '0.85rem', fontWeight: 600, textDecoration: 'none', backgroundColor: '#60a5fa'}}><span style={{color: '#000'}}>GGUF</span></a>
  <a href="https://huggingface.co/onnx-community/LFM2-350M-Math-ONNX" style={{padding: '0.35rem 0.7rem', borderRadius: '4px', fontSize: '0.85rem', fontWeight: 600, textDecoration: 'none', backgroundColor: '#86efac'}}><span style={{color: '#000'}}>ONNX</span></a>
</div>

## Specifications

| Property       | Value                  |
| -------------- | ---------------------- |
| Parameters     | 350M                   |
| Context Length | 32K tokens             |
| Task           | Mathematical Reasoning |

<div className="use-cases">
  <CardGroup cols={3}>
    <Card title="Problem Solving" icon="calculator">
      Step-by-step math
    </Card>

    <Card title="Edge Deployment" icon="microchip">
      Tiny model footprint
    </Card>

    <Card title="Education" icon="graduation-cap">
      Tutoring and explanations
    </Card>
  </CardGroup>
</div>

## Quick Start

<Tabs>
  <Tab title="Transformers">
    **Install:**

    ```bash theme={null}
    pip install "transformers>=5.2.0" torch accelerate
    ```

    **Run:**

    ```python theme={null}
    from transformers import AutoTokenizer, AutoModelForCausalLM

    model_id = "LiquidAI/LFM2-350M-Math"
    tokenizer = AutoTokenizer.from_pretrained(model_id)
    model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto")

    messages = [
        {"role": "user", "content": "If a train travels at 60 mph for 2.5 hours, how far does it travel?"}
    ]

    inputs = tokenizer.apply_chat_template(messages, return_tensors="pt", return_dict=True).to(model.device)
    outputs = model.generate(**inputs, max_new_tokens=256)
    response = tokenizer.decode(outputs[0], skip_special_tokens=True)
    print(response)
    ```
  </Tab>

  <Tab title="llama.cpp">
    **Download GGUF:**

    ```bash theme={null}
    hf download LiquidAI/LFM2-350M-Math-GGUF \
      --local-dir ./LFM2-350M-Math-GGUF
    ```

    **Run:**

    ```bash theme={null}
    llama-cli -m ./LFM2-350M-Math-GGUF/LFM2-350M-Math-Q4_K_M.gguf \
      -p "Solve: 2x + 5 = 15"
    ```
  </Tab>
</Tabs>
