This model is deprecated. Use LFM2.5-1.2B-Instruct for structured extraction with current LFM2.5 prompting and tool-use behavior.
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.
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-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.name: Person's full nameemail: Email addresscompany: 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, 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-1.2B-Extract-GGUF/LFM2-1.2B-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\nname: Person\'s full name\nemail: Email address\ncompany: Company name' \ -p 'Contact John Smith at john.smith@acme.com. He works at Acme Corp.' \ --temp 0