> ## 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-1.2B-Extract

> 1.2B parameter extraction model (deprecated - use LFM2.5-1.2B-Instruct instead)

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

<Warning>
  This model is deprecated. Use [LFM2.5-1.2B-Instruct](/lfm/models/lfm25-1.2b-instruct) for structured extraction with current LFM2.5 prompting and tool-use behavior.
</Warning>

LFM2-1.2B-Extract is optimized for extracting structured data (JSON, XML, YAML) from unstructured documents. It handles complex nested schemas and multi-field extraction with high accuracy.

<div style={{display: 'flex', gap: '0.5rem', margin: '0.5rem 0 1.5rem 0'}}>
  <a href="https://huggingface.co/LiquidAI/LFM2-1.2B-Extract" 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-1.2B-Extract-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-1.2B-Extract-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     | 1.2B                  |
| Context Length | 32K tokens            |
| Task           | Structured Extraction |
| Output Formats | JSON, XML, YAML       |

<div className="use-cases">
  <CardGroup cols={3}>
    <Card title="Document Parsing" icon="file-lines">
      Extract fields from documents
    </Card>

    <Card title="Data Entry" icon="keyboard">
      Automate form filling
    </Card>

    <Card title="Schema Mapping" icon="diagram-project">
      Complex nested structures
    </Card>
  </CardGroup>
</div>

## Prompting Recipe

<Warning>
  Use `temperature=0` (greedy decoding) for best results. This model is intended for single-turn conversations only.
</Warning>

**System Prompt Format:**

```
Identify and extract information matching the following schema.
Return data as a JSON object. Missing data should be omitted.

Schema:
- field_name: "Description of what to extract"
- nested_object:
  - nested_field: "Description"
```

If no system prompt is provided, defaults to JSON. Specify format (JSON, XML, or YAML) and schema for better accuracy.

## 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-1.2B-Extract"
    tokenizer = AutoTokenizer.from_pretrained(model_id)
    model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto")

    system_prompt = """Identify and extract information matching the following schema.
    Return data as a JSON object. Missing data should be omitted.

    Schema:
    - name: "Person's full name"
    - email: "Email address"
    - company: "Company name"
    """

    user_input = "Contact John Smith at john.smith@acme.com. He works at Acme Corp."

    messages = [
        {"role": "system", "content": system_prompt},
        {"role": "user", "content": user_input}
    ]

    inputs = tokenizer.apply_chat_template(messages, return_tensors="pt", return_dict=True).to(model.device)
    outputs = model.generate(**inputs, max_new_tokens=256, temperature=0, do_sample=False)
    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-1.2B-Extract-GGUF \
      --local-dir ./LFM2-1.2B-Extract-GGUF
    ```

    **Run:**

    ```bash theme={null}
    llama-cli -m ./LFM2-1.2B-Extract-GGUF/LFM2-1.2B-Extract-Q4_K_M.gguf \
      -p "Extract name and email from: Contact John at john@example.com" \
      --temp 0
    ```
  </Tab>
</Tabs>
