Views
No views yet

| Property | LFM2-350M | LFM2-700M | LFM2-1.2B | LFM2-2.6B |
|---|---|---|---|---|
| Parameters | 354,483,968 | 742,489,344 | 1,170,340,608 | 2,569,272,320 |
| Layers | 16 (10 conv + 6 attn) | 16 (10 conv + 6 attn) | 16 (10 conv + 6 attn) | 30 (22 conv + 8 attn) |
| Context length | 32,768 tokens | 32,768 tokens | 32,768 tokens | 32,768 tokens |
| Vocabulary size | 65,536 | 65,536 | 65,536 | 65,536 |
| Precision | bfloat16 | bfloat16 | bfloat16 | bfloat16 |
| Training budget | 10 trillion tokens | 10 trillion tokens | 10 trillion tokens | 10 trillion tokens |
| License | LFM Open License v1.0 | LFM Open License v1.0 | LFM Open License v1.0 | LFM Open License v1.0 |
temperature=0.3min_p=0.15repetition_penalty=1.05<think> and </think> tokens) for complex or multilingual prompts.<|startoftext|><|im_start|>system
You are a helpful assistant trained by Liquid AI.<|im_end|>
<|im_start|>user
What is C. elegans?<|im_end|>
<|im_start|>assistant
It's a tiny nematode that lives in temperate soil environments.<|im_end|>.apply_chat_template() function from Hugging Face transformers.<|tool_list_start|> and <|tool_list_end|> special tokens), usually in the system prompt<|tool_call_start|> and <|tool_call_end|> special tokens), as the assistant answer.<|tool_response_start|> and <|tool_response_end|> special tokens), as a "tool" role.<|startoftext|><|im_start|>system
List of tools: <|tool_list_start|>[{"name": "get_candidate_status", "description": "Retrieves the current status of a candidate in the recruitment process", "parameters": {"type": "object", "properties": {"candidate_id": {"type": "string", "description": "Unique identifier for the candidate"}}, "required": ["candidate_id"]}}]<|tool_list_end|><|im_end|>
<|im_start|>user
What is the current status of candidate ID 12345?<|im_end|>
<|im_start|>assistant
<|tool_call_start|>[get_candidate_status(candidate_id="12345")]<|tool_call_end|>Checking the current status of candidate ID 12345.<|im_end|>
<|im_start|>tool
<|tool_response_start|>{"candidate_id": "12345", "status": "Interview Scheduled", "position": "Clinical Research Associate", "date": "2023-11-20"}<|tool_response_end|><|im_end|>
<|im_start|>assistant
The candidate with ID 12345 is currently in the "Interview Scheduled" stage for the position of Clinical Research Associate, with an interview date set for 2023-11-20.<|im_end|>npm i @huggingface/transformers1import { pipeline, TextStreamer } from "@huggingface/transformers";
2
3// Create a text generation pipeline
4const generator = await pipeline(
5 "text-generation",
6 "onnx-community/LFM2-2.6B-ONNX",
7 { dtype: "q4" },
8);
9
10// Define the list of messages
11const messages = [
12 { role: "system", content: "You are a helpful assistant." },
13 { role: "user", content: "What is the capital of France?" },
14];
15
16// Generate a response
17const output = await generator(messages, {
18 max_new_tokens: 512,
19 do_sample: false,
20 streamer: new TextStreamer(generator.tokenizer, { skip_prompt: true, skip_special_tokens: true }),
21});
22console.log(output[0].generated_text.at(-1).content);
23// The capital of France is Paris.1import { AutoModelForCausalLM, AutoTokenizer, TextStreamer } from "@huggingface/transformers";
2
3// Load tokenizer and model
4const model_id = "onnx-community/LFM2-2.6B-ONNX";
5const tokenizer = await AutoTokenizer.from_pretrained(model_id);
6const model = await AutoModelForCausalLM.from_pretrained(
7 model_id, { dtype: "q4", device: "webgpu" },
8);
9
10// Define tools and messages
11const tools = [
12 {
13 name: "get_weather",
14 description: "Get current weather information for a location",
15 parameters: {
16 type: "object",
17 properties: {
18 location: {
19 type: "string",
20 description: "The city and state, e.g. San Francisco, CA",
21 },
22 unit: {
23 type: "string",
24 enum: ["celsius", "fahrenheit"],
25 description: "The unit of temperature to use",
26 },
27 },
28 required: ["location"],
29 },
30 },
31];
32const messages = [
33 {
34 role: "user",
35 content: "What's the weather like in New York?"
36 },
37];
38
39// Prepare inputs
40const input = tokenizer.apply_chat_template(messages, {
41 tools,
42 add_generation_prompt: true,
43 return_dict: true,
44});
45
46// Generate output
47const sequences = await model.generate({
48 ...input,
49 max_new_tokens: 512,
50 do_sample: false,
51 streamer: new TextStreamer(tokenizer, { skip_prompt: true, skip_special_tokens: false }),
52});
53
54// Decode and print the generated text
55const response = tokenizer.batch_decode(
56 sequences.slice(null, [input.input_ids.dims[1], null]),
57 { skip_special_tokens: true },
58);
59console.log(response[0]); // [get_weather(location="New York", unit="fahrenheit")]1from transformers import AutoConfig, AutoTokenizer
2import onnxruntime
3import numpy as np
4from huggingface_hub import hf_hub_download
5
6# 1. Load config, processor, and model
7model_id = "onnx-community/LFM2-2.6B-ONNX"
8config = AutoConfig.from_pretrained(model_id)
9tokenizer = AutoTokenizer.from_pretrained(model_id)
10filename = "model_q4.onnx" # Options: "model.onnx", "model_fp16.onnx", "model_q4.onnx", "model_q4f16.onnx"
11model_path = hf_hub_download(repo_id=model_id, filename=f"onnx/{filename}") # Download the graph
12hf_hub_download(repo_id=model_id, filename=f"onnx/{filename}_data") # Download the weights
13session = onnxruntime.InferenceSession(model_path)
14
15## Set config values
16num_key_value_heads = config.num_key_value_heads
17head_dim = config.hidden_size // config.num_attention_heads
18num_hidden_layers = config.num_hidden_layers
19eos_token_id = config.eos_token_id
20hidden_size = config.hidden_size
21conv_L_cache = config.conv_L_cache
22layer_types = config.layer_types
23
24# 2. Prepare inputs
25prompt = "What is C. elegans?"
26messages = [{"role": "user", "content": prompt}]
27inputs = tokenizer.apply_chat_template(messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="np")
28input_ids = inputs['input_ids']
29attention_mask = inputs['attention_mask']
30batch_size = input_ids.shape[0]
31position_ids = np.tile(np.arange(0, input_ids.shape[-1]), (batch_size, 1))
32past_cache_values = {}
33for i in range(num_hidden_layers):
34 if layer_types[i] == 'full_attention':
35 for kv in ('key', 'value'):
36 past_cache_values[f'past_key_values.{i}.{kv}'] = np.zeros([batch_size, num_key_value_heads, 0, head_dim], dtype=np.float32)
37 elif layer_types[i] == 'conv':
38 past_cache_values[f'past_conv.{i}'] = np.zeros([batch_size, hidden_size, conv_L_cache], dtype=np.float32)
39 else:
40 raise ValueError(f"Unsupported layer type: {layer_types[i]}")
41
42# 3. Generation loop
43max_new_tokens = 1024
44generated_tokens = np.array([[]], dtype=np.int64)
45for i in range(max_new_tokens):
46 logits, *present_cache_values = session.run(None, dict(
47 input_ids=input_ids,
48 attention_mask=attention_mask,
49 position_ids=position_ids,
50 **past_cache_values,
51 ))
52
53 ## Update values for next generation loop
54 input_ids = logits[:, -1].argmax(-1, keepdims=True)
55 attention_mask = np.concatenate([attention_mask, np.ones_like(input_ids, dtype=np.int64)], axis=-1)
56 position_ids = position_ids[:, -1:] + 1
57 for j, key in enumerate(past_cache_values):
58 past_cache_values[key] = present_cache_values[j]
59 generated_tokens = np.concatenate([generated_tokens, input_ids], axis=-1)
60 if (input_ids == eos_token_id).all():
61 break
62
63 ## (Optional) Streaming
64 print(tokenizer.decode(input_ids[0]), end='', flush=True)
65print()
66
67# 4. Output result
68print(tokenizer.batch_decode(generated_tokens, skip_special_tokens=True)[0])
| Model | MMLU | GPQA | IFEval | IFBench | GSM8K | MGSM | MMMLU |
|---|---|---|---|---|---|---|---|
| LFM2-2.6B | 64.42 | 26.57 | 79.56 | 22.19 | 82.41 | 74.32 | 55.39 |
| Llama-3.2-3B-Instruct | 60.35 | 30.6 | 71.43 | 20.78 | 75.21 | 61.68 | 47.92 |
| SmolLM3-3B | 59.84 | 26.31 | 72.44 | 17.93 | 81.12 | 68.72 | 50.02 |
| gemma-3-4b-it | 58.35 | 29.51 | 76.85 | 23.53 | 89.92 | 87.28 | 50.14 |
| Qwen3-4B-Instruct-2507 | 72.25 | 34.85 | 85.62 | 30.28 | 68.46 | 81.76 | 60.67 |