Views
No views yet
LiquidAI/LFM2.5-350M (SSM hybrid, ideal for edge/CPU deployment)| Metric | Score |
|---|---|
| Overall score (v2 training benchmark) | 97.7% |
| JSON validity | 100% |
| Schema conformance | 100% |
| Field extraction accuracy | 97.6% |
| Internal benchmark cases | 96.2% |
| Domain | Avg Accuracy |
|---|---|
| Software Projects | ~74% |
| Governance / Compliance | ~75% |
| HR | ~85% |
| Education | ~81% |
| Sales | ~55% |
| Healthcare | ~53% |
| Support (phone) | ~61% |
1from transformers import AutoModelForCausalLM, AutoTokenizer
2import torch, json
3
4model_id = "senthil090/schemalm-v2-lfm2-350m"
5tokenizer = AutoTokenizer.from_pretrained(model_id)
6model = AutoModelForCausalLM.from_pretrained(
7 model_id, torch_dtype=torch.bfloat16, device_map="auto"
8)
9model.eval()
10
11def extract(schema: dict, text: str, max_new_tokens: int = 256) -> dict:
12 messages = [
13 {"role": "system", "content": json.dumps(schema)},
14 {"role": "user", "content": text},
15 ]
16 prompt = tokenizer.apply_chat_template(
17 messages, tokenize=False, add_generation_prompt=True
18 )
19 inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
20 with torch.no_grad():
21 out = model.generate(
22 **inputs,
23 max_new_tokens=max_new_tokens,
24 do_sample=False,
25 repetition_penalty=1.08,
26 )
27 raw = tokenizer.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True)
28 return json.loads(raw.strip())1schema = {
2 "type": "object",
3 "properties": {
4 "task_title": {"type": "string"},
5 "assignee": {"type": "string"},
6 "priority": {"type": "string", "enum": ["critical", "high", "medium", "low"]},
7 "story_points": {"type": "integer"},
8 "status": {"type": "string", "enum": ["todo", "in_progress", "done"]},
9 "epic": {"type": "string"},
10 },
11 "required": ["task_title", "assignee", "priority"],
12}
13
14text = (
15 "Assign the Redis caching implementation to Priya for Sprint 14. "
16 "It's high priority under the Performance epic, estimated 5 story points. "
17 "Mark it as in progress since she already started."
18)
19
20result = extract(schema, text)
21# → {
22# "task_title": "Redis caching implementation",
23# "assignee": "Priya",
24# "priority": "high",
25# "story_points": 5,
26# "status": "in_progress",
27# "epic": "Performance"
28# }1schema = {
2 "type": "object",
3 "properties": {
4 "customer": {
5 "type": "object",
6 "properties": {
7 "name": {"type": "string"},
8 "company": {"type": "string"},
9 "email": {"type": "string", "format": "email"},
10 },
11 "required": ["name", "company"],
12 },
13 "issue": {
14 "type": "object",
15 "properties": {
16 "summary": {"type": "string"},
17 "severity": {"type": "string", "enum": ["low", "medium", "high", "critical"]},
18 },
19 "required": ["summary", "severity"],
20 },
21 "actions": {
22 "type": "array",
23 "items": {
24 "type": "object",
25 "properties": {
26 "owner": {"type": "string"},
27 "task": {"type": "string"},
28 },
29 "required": ["owner", "task"],
30 },
31 },
32 },
33 "required": ["customer", "issue"],
34}
35
36text = (
37 "Support note: customer Priya Shah from Velocity Corp, email priya@velocity.io. "
38 "Dashboard charts won't load — severity high. "
39 "Action: Sarah to open an engineering ticket. Marcus to send ETA to customer."
40)
41
42result = extract(schema, text)
43# → {
44# "customer": {"name": "Priya Shah", "company": "Velocity Corp", "email": "priya@velocity.io"},
45# "issue": {"summary": "Dashboard charts won't load", "severity": "high"},
46# "actions": [
47# {"owner": "Sarah", "task": "open an engineering ticket"},
48# {"owner": "Marcus", "task": "send ETA to customer"}
49# ]
50# }1schema = {
2 "type": "object",
3 "properties": {
4 "finding_id": {"type": "string"},
5 "standard": {"type": "string", "enum": ["ISO27001", "SOC2", "HIPAA", "GDPR", "PCI-DSS"]},
6 "clause": {"type": "string"},
7 "severity": {"type": "string", "enum": ["critical", "major", "minor", "observation"]},
8 "description": {"type": "string"},
9 "due_date": {"type": "string", "format": "date"},
10 "owner": {"type": "string"},
11 "status": {"type": "string", "enum": ["open", "in_remediation", "closed"]},
12 },
13 "required": ["standard", "severity", "description", "due_date"],
14}
15
16text = (
17 "Audit finding AF-2024-089: ISO27001 clause A.9.4.2 violation — "
18 "privileged accounts are not protected with MFA. Severity: major. "
19 "Remediation owner: Chen, due by 2024-09-30. Status: in_remediation."
20)
21
22result = extract(schema, text)
23# → {
24# "finding_id": "AF-2024-089",
25# "standard": "ISO27001",
26# "clause": "A.9.4.2",
27# "severity": "major",
28# "description": "Privileged accounts are not protected with MFA",
29# "due_date": "2024-09-30",
30# "owner": "Chen",
31# "status": "in_remediation"
32# }1model = AutoModelForCausalLM.from_pretrained(
2 "senthil090/schemalm-v2-lfm2-350m",
3 torch_dtype=torch.float32, # fp32 for CPU
4)
5model.eval()
6# Same extract() function as above — just slower (~5–15s per call on a modern CPU)pattern/format constraints@misc{schemalm-v2,
title = {SchemaLM v2 — JSON Schema-Conditioned Information Extraction},
author = {Senthil},
year = {2025},
url = {https://huggingface.co/senthil090/schemalm-v2-lfm2-350m}
}