LFM2.5-350M-IT-Extract: a fine-tuned version of liquid ai model for document key information extraction

Model details

Performance (on xfund-kie validation)

Model Avg. F1 Errors (JSON parse / total val docs)
LiquidAI/LFM2.5-350M (base) 0.2877 6 / 50
andreagemelli/LFM2.5-350M-IT-Extract (fine-tuned) 0.6639 10 / 50

How to use for inference

from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer
import torch, json
from datasets import load_dataset

model_id = "andreagemelli/LFM2.5-350M-IT-Extract"
device = "cuda" if torch.cuda.is_available() else "cpu"

model = AutoModelForCausalLM.from_pretrained(model_id, dtype=torch.bfloat16).to(device)
tokenizer = AutoTokenizer.from_pretrained(model_id)

# Load dataset from Hugging Face Hub (no local repo needed)
dataset = load_dataset("andreagemelli/xfund-kie-it", split="validation")
doc = dataset.filter(lambda x: x["source"] == "it_val_0")[0]

annotation = doc["annotation"]  # from dataset messages or annotation field
schema_text = "".join([f"{k}: {v}.\n" for k, v in REF_SCHEMA.items() if k in annotation]) # cognome: surname of the person.\nnome: ...

user_text = doc["text"] if "text" in doc else doc["messages"][1]["content"]

messages = [
    {"role": "system", "content": SYTEM_PROMPT_DEFAULT + schema_text},
    {"role": "user", "content": user_text},
]

inputs = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt").to(device)
streamer = TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
output = model.generate(inputs, max_new_tokens=1024, do_sample=False, streamer=streamer)

Expected snippet output (ref: it_val_0 from xfund-kie/it.val.json):

{
  "cognome": "VALLE",
  "nome": "LUISA",
  ...
}

Defaults I used in my experiments:

REF_SCHEMA = json.load('/path/to/schema/json') # https://huggingface.co/datasets/andreagemelli/xfund-kie-it/blob/main/schema.json
SYTEM_PROMPT_DEFAULT = f"""Identify and extract information matching the following schema.
Return data as a JSON object. Missing data should be omitted.
"""

Cite this project

@misc{gemelli2026LFM2.5-350M-IT-Extract 
  title        = {LFM2.5-350M-IT-Extract: A tiny model for italian document key information extraction},
  author       = {Gemelli, Andrea},
  year         = {2026},
  howpublished = {\url{https://huggingface.co/andreagemelli/LFM2.5-350M-IT-Extract}}
}
Downloads last month
-
Safetensors
Model size
0.4B params
Tensor type
BF16
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for andreagemelli/LFM2.5-350M-IT-Extract

Finetuned
(68)
this model
Quantizations
1 model

Dataset used to train andreagemelli/LFM2.5-350M-IT-Extract

Collection including andreagemelli/LFM2.5-350M-IT-Extract