This model is deprecated. Use LFM2.5-350M for compact structured extraction with the latest 350M checkpoint.
LFM2-350M-Extract is the fastest extraction model, optimized for edge deployment with strict memory and compute constraints. It delivers structured data extraction with minimal latency.
Use temperature=0 (greedy decoding) for best results. This model is intended for single-turn conversations only.
System Prompt Format:
Identify and extract information matching the following schema.Return data as a JSON object. Missing data should be omitted.field_name: Description of what to extractnested_object: nested_field: Description
The system prompt is recommended but optional: without one, the model defaults to JSON output. Specify the format (JSON, XML, or YAML) and the schema to improve accuracy.Supported languages: English, Arabic, Chinese, French, German, Japanese, Korean, Portuguese, and Spanish.
from transformers import AutoTokenizer, AutoModelForCausalLMmodel_id = "LiquidAI/LFM2-350M-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.product: Product nameprice: Price in dollarsquantity: Number of items"""user_input = "Order: 5 units of Widget Pro at $29.99 each"messages = [ {"role": "system", "content": system_prompt}, {"role": "user", "content": user_input}]inputs = tokenizer.apply_chat_template(messages, add_generation_prompt=True, 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][inputs["input_ids"].shape[-1]:], skip_special_tokens=True)print(response)
llama-cli -m ./LFM2-350M-Extract-GGUF/LFM2-350M-Extract-Q4_K_M.gguf \ -sys $'Identify and extract information matching the following schema.\nReturn data as a JSON object. Missing data should be omitted.\n\nproduct: Product name\nprice: Price in dollars\nquantity: Number of items' \ -p 'Order: 5 units of Widget Pro at $29.99 each' \ --temp 0