From 92de95c336e33c4029b9d71fbe2e50c2ae8c945e Mon Sep 17 00:00:00 2001 From: ModelHub XC Date: Thu, 22 Oct 2026 00:46:16 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=EF=BC=8C=E7=94=B1ModelHub=20XC=E7=A4=BE=E5=8C=BA=E6=8F=90?= =?UTF-8?q?=E4=BE=9B=E6=A8=A1=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Model: gabriellarson/LFM2-2.6B-GGUF Source: Original Platform --- .gitattributes | 56 +++++++++ LFM2-2.6B-F16.gguf | 3 + LFM2-2.6B-IQ2_M.gguf | 3 + LFM2-2.6B-IQ2_S.gguf | 3 + LFM2-2.6B-IQ2_XXS.gguf | 3 + LFM2-2.6B-IQ3_M.gguf | 3 + LFM2-2.6B-IQ3_S.gguf | 3 + LFM2-2.6B-IQ3_XXS.gguf | 3 + LFM2-2.6B-IQ4_NL.gguf | 3 + LFM2-2.6B-IQ4_XS.gguf | 3 + LFM2-2.6B-Q2_K.gguf | 3 + LFM2-2.6B-Q3_K_L.gguf | 3 + LFM2-2.6B-Q3_K_M.gguf | 3 + LFM2-2.6B-Q3_K_S.gguf | 3 + LFM2-2.6B-Q4_0.gguf | 3 + LFM2-2.6B-Q4_K_M.gguf | 3 + LFM2-2.6B-Q4_K_S.gguf | 3 + LFM2-2.6B-Q5_0.gguf | 3 + LFM2-2.6B-Q5_K_M.gguf | 3 + LFM2-2.6B-Q5_K_S.gguf | 3 + LFM2-2.6B-Q6_K.gguf | 3 + LFM2-2.6B-Q8_0.gguf | 3 + README.md | 258 +++++++++++++++++++++++++++++++++++++++++ 23 files changed, 377 insertions(+) create mode 100644 .gitattributes create mode 100644 LFM2-2.6B-F16.gguf create mode 100644 LFM2-2.6B-IQ2_M.gguf create mode 100644 LFM2-2.6B-IQ2_S.gguf create mode 100644 LFM2-2.6B-IQ2_XXS.gguf create mode 100644 LFM2-2.6B-IQ3_M.gguf create mode 100644 LFM2-2.6B-IQ3_S.gguf create mode 100644 LFM2-2.6B-IQ3_XXS.gguf create mode 100644 LFM2-2.6B-IQ4_NL.gguf create mode 100644 LFM2-2.6B-IQ4_XS.gguf create mode 100644 LFM2-2.6B-Q2_K.gguf create mode 100644 LFM2-2.6B-Q3_K_L.gguf create mode 100644 LFM2-2.6B-Q3_K_M.gguf create mode 100644 LFM2-2.6B-Q3_K_S.gguf create mode 100644 LFM2-2.6B-Q4_0.gguf create mode 100644 LFM2-2.6B-Q4_K_M.gguf create mode 100644 LFM2-2.6B-Q4_K_S.gguf create mode 100644 LFM2-2.6B-Q5_0.gguf create mode 100644 LFM2-2.6B-Q5_K_M.gguf create mode 100644 LFM2-2.6B-Q5_K_S.gguf create mode 100644 LFM2-2.6B-Q6_K.gguf create mode 100644 LFM2-2.6B-Q8_0.gguf create mode 100644 README.md diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..c45a14f --- /dev/null +++ b/.gitattributes @@ -0,0 +1,56 @@ +*.7z filter=lfs diff=lfs merge=lfs -text +*.arrow filter=lfs diff=lfs merge=lfs -text +*.bin filter=lfs diff=lfs merge=lfs -text +*.bz2 filter=lfs diff=lfs merge=lfs -text +*.ckpt filter=lfs diff=lfs merge=lfs -text +*.ftz filter=lfs diff=lfs merge=lfs -text +*.gz filter=lfs diff=lfs merge=lfs -text +*.h5 filter=lfs diff=lfs merge=lfs -text +*.joblib filter=lfs diff=lfs merge=lfs -text +*.lfs.* filter=lfs diff=lfs merge=lfs -text +*.mlmodel filter=lfs diff=lfs merge=lfs -text +*.model filter=lfs diff=lfs merge=lfs -text +*.msgpack filter=lfs diff=lfs merge=lfs -text +*.npy filter=lfs diff=lfs merge=lfs -text +*.npz filter=lfs diff=lfs merge=lfs -text +*.onnx filter=lfs diff=lfs merge=lfs -text +*.ot filter=lfs diff=lfs merge=lfs -text +*.parquet filter=lfs diff=lfs merge=lfs -text +*.pb filter=lfs diff=lfs merge=lfs -text +*.pickle filter=lfs diff=lfs merge=lfs -text +*.pkl filter=lfs diff=lfs merge=lfs -text +*.pt filter=lfs diff=lfs merge=lfs -text +*.pth filter=lfs diff=lfs merge=lfs -text +*.rar filter=lfs diff=lfs merge=lfs -text +*.safetensors filter=lfs diff=lfs merge=lfs -text +saved_model/**/* filter=lfs diff=lfs merge=lfs -text +*.tar.* filter=lfs diff=lfs merge=lfs -text +*.tar filter=lfs diff=lfs merge=lfs -text +*.tflite filter=lfs diff=lfs merge=lfs -text +*.tgz filter=lfs diff=lfs merge=lfs -text +*.wasm filter=lfs diff=lfs merge=lfs -text +*.xz filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text +*.zst filter=lfs diff=lfs merge=lfs -text +*tfevents* filter=lfs diff=lfs merge=lfs -text +LFM2-2.6B-F16.gguf filter=lfs diff=lfs merge=lfs -text +LFM2-2.6B-IQ2_M.gguf filter=lfs diff=lfs merge=lfs -text +LFM2-2.6B-IQ2_S.gguf filter=lfs diff=lfs merge=lfs -text +LFM2-2.6B-IQ2_XXS.gguf filter=lfs diff=lfs merge=lfs -text +LFM2-2.6B-IQ3_M.gguf filter=lfs diff=lfs merge=lfs -text +LFM2-2.6B-IQ3_S.gguf filter=lfs diff=lfs merge=lfs -text +LFM2-2.6B-IQ3_XXS.gguf filter=lfs diff=lfs merge=lfs -text +LFM2-2.6B-IQ4_NL.gguf filter=lfs diff=lfs merge=lfs -text +LFM2-2.6B-IQ4_XS.gguf filter=lfs diff=lfs merge=lfs -text +LFM2-2.6B-Q2_K.gguf filter=lfs diff=lfs merge=lfs -text +LFM2-2.6B-Q3_K_L.gguf filter=lfs diff=lfs merge=lfs -text +LFM2-2.6B-Q3_K_M.gguf filter=lfs diff=lfs merge=lfs -text +LFM2-2.6B-Q3_K_S.gguf filter=lfs diff=lfs merge=lfs -text +LFM2-2.6B-Q4_0.gguf filter=lfs diff=lfs merge=lfs -text +LFM2-2.6B-Q4_K_M.gguf filter=lfs diff=lfs merge=lfs -text +LFM2-2.6B-Q4_K_S.gguf filter=lfs diff=lfs merge=lfs -text +LFM2-2.6B-Q5_0.gguf filter=lfs diff=lfs merge=lfs -text +LFM2-2.6B-Q5_K_M.gguf filter=lfs diff=lfs merge=lfs -text +LFM2-2.6B-Q5_K_S.gguf filter=lfs diff=lfs merge=lfs -text +LFM2-2.6B-Q6_K.gguf filter=lfs diff=lfs merge=lfs -text +LFM2-2.6B-Q8_0.gguf filter=lfs diff=lfs merge=lfs -text diff --git a/LFM2-2.6B-F16.gguf b/LFM2-2.6B-F16.gguf new file mode 100644 index 0000000..7accb8b --- /dev/null +++ b/LFM2-2.6B-F16.gguf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:863b3876e55b661c7c740e2f58f0899789fb6ed2b4cc93625db1e9572643a17b +size 5141459168 diff --git a/LFM2-2.6B-IQ2_M.gguf b/LFM2-2.6B-IQ2_M.gguf new file mode 100644 index 0000000..29455b3 --- /dev/null +++ b/LFM2-2.6B-IQ2_M.gguf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:faa44c15d042ee0f3f748da5ff02d88af3041324c5ee3354d442f481520630e6 +size 887419328 diff --git a/LFM2-2.6B-IQ2_S.gguf b/LFM2-2.6B-IQ2_S.gguf new file mode 100644 index 0000000..4bdceb8 --- /dev/null +++ b/LFM2-2.6B-IQ2_S.gguf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:14dac5c121484d968b658a543c12c9403c6a336ee55ad0a867785be2afec5ee2 +size 814707136 diff --git a/LFM2-2.6B-IQ2_XXS.gguf b/LFM2-2.6B-IQ2_XXS.gguf new file mode 100644 index 0000000..63b9227 --- /dev/null +++ b/LFM2-2.6B-IQ2_XXS.gguf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9748dbcf5642b584bf162b3357ad0dbe21fede7ea76233c84d6747fd44bc38fa +size 728666560 diff --git a/LFM2-2.6B-IQ3_M.gguf b/LFM2-2.6B-IQ3_M.gguf new file mode 100644 index 0000000..cf32bc5 --- /dev/null +++ b/LFM2-2.6B-IQ3_M.gguf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:573ddd534c1180cf907c33ad9ec9b02da8d1f9087f1bb9ec004bcdf0a67ffefa +size 1174081984 diff --git a/LFM2-2.6B-IQ3_S.gguf b/LFM2-2.6B-IQ3_S.gguf new file mode 100644 index 0000000..30138d9 --- /dev/null +++ b/LFM2-2.6B-IQ3_S.gguf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:869a1111f6c1bba68e111b3de8c5723f675363281d6380a146d361bded45b96b +size 1159737792 diff --git a/LFM2-2.6B-IQ3_XXS.gguf b/LFM2-2.6B-IQ3_XXS.gguf new file mode 100644 index 0000000..26cff98 --- /dev/null +++ b/LFM2-2.6B-IQ3_XXS.gguf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:76343427e963f7e000210baa46372c7ef1e95cf9d1185450a53242a7bf2ff478 +size 1026732480 diff --git a/LFM2-2.6B-IQ4_NL.gguf b/LFM2-2.6B-IQ4_NL.gguf new file mode 100644 index 0000000..8ca4c3a --- /dev/null +++ b/LFM2-2.6B-IQ4_NL.gguf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1c0da2ccd1d4e434d69e80d3f59bc8f23c2120854a652b6785d010b441b8f2e8 +size 1483108800 diff --git a/LFM2-2.6B-IQ4_XS.gguf b/LFM2-2.6B-IQ4_XS.gguf new file mode 100644 index 0000000..2aeb001 --- /dev/null +++ b/LFM2-2.6B-IQ4_XS.gguf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:90be4c58626bf3b53cc8ced35a0040cb4854e50a0fc5e487fb1fe6f131d87286 +size 1407021504 diff --git a/LFM2-2.6B-Q2_K.gguf b/LFM2-2.6B-Q2_K.gguf new file mode 100644 index 0000000..dfe5f41 --- /dev/null +++ b/LFM2-2.6B-Q2_K.gguf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f4bfaf7a02c86104844fa1edb809c44a734ea57e8328f98911feb37c0a01c678 +size 983806400 diff --git a/LFM2-2.6B-Q3_K_L.gguf b/LFM2-2.6B-Q3_K_L.gguf new file mode 100644 index 0000000..3a99fd9 --- /dev/null +++ b/LFM2-2.6B-Q3_K_L.gguf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ace1bbf29ea128300c4291db32ea4246a73270fe1e44333ad3a04e63af4f5a75 +size 1340862912 diff --git a/LFM2-2.6B-Q3_K_M.gguf b/LFM2-2.6B-Q3_K_M.gguf new file mode 100644 index 0000000..85f8c71 --- /dev/null +++ b/LFM2-2.6B-Q3_K_M.gguf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4941d38888e1d40b0b8d3399431d253adacfe06692a786ae8f24da323c5ed054 +size 1256059328 diff --git a/LFM2-2.6B-Q3_K_S.gguf b/LFM2-2.6B-Q3_K_S.gguf new file mode 100644 index 0000000..7a28c46 --- /dev/null +++ b/LFM2-2.6B-Q3_K_S.gguf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c2337d863eeb43cdb476668fb9137f48e8bcf805d0698865af0cbbcce186629a +size 1159737792 diff --git a/LFM2-2.6B-Q4_0.gguf b/LFM2-2.6B-Q4_0.gguf new file mode 100644 index 0000000..642ad99 --- /dev/null +++ b/LFM2-2.6B-Q4_0.gguf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:18d6f052ed73221d77c8d29030db754c3cc92d11a17c95af0f207ceb6b485cf9 +size 1487237568 diff --git a/LFM2-2.6B-Q4_K_M.gguf b/LFM2-2.6B-Q4_K_M.gguf new file mode 100644 index 0000000..396f909 --- /dev/null +++ b/LFM2-2.6B-Q4_K_M.gguf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4b1fcb301e8905ed183ba6df04cf7fa8753b9b6e5f6e148fcc7ac11c65beb6da +size 1563668928 diff --git a/LFM2-2.6B-Q4_K_S.gguf b/LFM2-2.6B-Q4_K_S.gguf new file mode 100644 index 0000000..a9e5554 --- /dev/null +++ b/LFM2-2.6B-Q4_K_S.gguf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:43fc96311a04b4968e2ba0f8e1b141fa80070c662be18191b81599052ac86b27 +size 1491890624 diff --git a/LFM2-2.6B-Q5_0.gguf b/LFM2-2.6B-Q5_0.gguf new file mode 100644 index 0000000..ffadb20 --- /dev/null +++ b/LFM2-2.6B-Q5_0.gguf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:17c45fa73d46edd7017872607d866be98997581213825546dbb8eb416321a86d +size 1791586752 diff --git a/LFM2-2.6B-Q5_K_M.gguf b/LFM2-2.6B-Q5_K_M.gguf new file mode 100644 index 0000000..f00eb99 --- /dev/null +++ b/LFM2-2.6B-Q5_K_M.gguf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1f4dab463927302dcb834d9a732d83ab2021511c29056a732b42c2ade0e0ee00 +size 1828958656 diff --git a/LFM2-2.6B-Q5_K_S.gguf b/LFM2-2.6B-Q5_K_S.gguf new file mode 100644 index 0000000..92f01ec --- /dev/null +++ b/LFM2-2.6B-Q5_K_S.gguf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3290a36989a17f06a36c044fefe7c770452c13dc6b9eca42965993f05f4d2b68 +size 1787457984 diff --git a/LFM2-2.6B-Q6_K.gguf b/LFM2-2.6B-Q6_K.gguf new file mode 100644 index 0000000..3769a1d --- /dev/null +++ b/LFM2-2.6B-Q6_K.gguf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f13fc6693fdaf1b8d75dbfcdc11ddec9e5f59dd239c50d176c1d615f71892dd4 +size 2110828992 diff --git a/LFM2-2.6B-Q8_0.gguf b/LFM2-2.6B-Q8_0.gguf new file mode 100644 index 0000000..acb65cd --- /dev/null +++ b/LFM2-2.6B-Q8_0.gguf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:36f640ad4e1ca77f97a3efce90e891cfaba5319e2359d7119c3c3520e4c2d8e0 +size 2733011392 diff --git a/README.md b/README.md new file mode 100644 index 0000000..e11afaf --- /dev/null +++ b/README.md @@ -0,0 +1,258 @@ +--- +library_name: transformers +license: other +license_name: lfm1.0 +license_link: LICENSE +language: +- en +- ar +- zh +- fr +- de +- ja +- ko +- es +pipeline_tag: text-generation +tags: +- liquid +- lfm2 +- edge +base_model: +- LiquidAI/LFM2-2.6B +--- +
+
+ Liquid AI +
+
+ + + Playground + + + + + + + + + + + + + + + + + + + Leap + + + + + + + + + + + + + + +
+
+# LFM2-2.6B + +LFM2 is a new generation of hybrid models developed by [Liquid AI](https://www.liquid.ai/), specifically designed for edge AI and on-device deployment. It sets a new standard in terms of quality, speed, and memory efficiency. + +We're releasing the weights of four post-trained checkpoints with 350M, 700M, 1.2B, and 2.6 parameters. They provide the following key features to create AI-powered edge applications: + +* **Fast training & inference** – LFM2 achieves 3x faster training compared to its previous generation. It also benefits from 2x faster decode and prefill speed on CPU compared to Qwen3. +* **Best performance** – LFM2 outperforms similarly-sized models across multiple benchmark categories, including knowledge, mathematics, instruction following, and multilingual capabilities. +* **New architecture** – LFM2 is a new hybrid Liquid model with multiplicative gates and short convolutions. +* **Flexible deployment** – LFM2 runs efficiently on CPU, GPU, and NPU hardware for flexible deployment on smartphones, laptops, or vehicles. + +Find more information about LFM2 in our [blog post](https://www.liquid.ai/blog/liquid-foundation-models-v2-our-second-series-of-generative-ai-models). + +## 📄 Model details + +Due to their small size, **we recommend fine-tuning LFM2 models on narrow use cases** to maximize performance. +They are particularly suited for agentic tasks, data extraction, RAG, creative writing, and multi-turn conversations. +However, we do not recommend using them for tasks that are knowledge-intensive or require programming skills. + +| Property | [**LFM2-350M**](https://huggingface.co/LiquidAI/LFM2-350M) | [**LFM2-700M**](https://huggingface.co/LiquidAI/LFM2-700M) | [**LFM2-1.2B**](https://huggingface.co/LiquidAI/LFM2-1.2B) | [**LFM2-2.6B**](https://huggingface.co/LiquidAI/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 + +**Supported languages**: English, Arabic, Chinese, French, German, Japanese, Korean, and Spanish. + +**Generation parameters**: We recommend the following parameters: +* `temperature=0.3` +* `min_p=0.15` +* `repetition_penalty=1.05` + +**Chat template**: LFM2 uses a ChatML-like chat template as follows: + +``` +<|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|> +``` + +You can automatically apply it using the dedicated [`.apply_chat_template()`](https://huggingface.co/docs/transformers/en/chat_templating#applychattemplate) function from Hugging Face transformers. + +**Tool use**: It consists of four main steps: +1. **Function definition**: LFM2 takes JSON function definitions as input (JSON objects between `<|tool_list_start|>` and `<|tool_list_end|>` special tokens), usually in the system prompt +2. **Function call**: LFM2 writes Pythonic function calls (a Python list between `<|tool_call_start|>` and `<|tool_call_end|>` special tokens), as the assistant answer. +3. **Function execution**: The function call is executed and the result is returned (string between `<|tool_response_start|>` and `<|tool_response_end|>` special tokens), as a "tool" role. +4. **Final answer**: LFM2 interprets the outcome of the function call to address the original user prompt in plain text. + +Here is a simple example of a conversation using tool use: + +``` +<|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|> +``` + +**Architecture**: Hybrid model with multiplicative gates and short convolutions: 10 double-gated short-range LIV convolution blocks and 6 grouped query attention (GQA) blocks. + +**Pre-training mixture**: Approximately 75% English, 20% multilingual, and 5% code data sourced from the web and licensed materials. + +**Training approach**: +* Very large-scale SFT on 50% downstream tasks, 50% general domains +* Custom DPO with length normalization and semi-online datasets +* Iterative model merging + +## 🏃 How to run LFM2 + +### 1. Transformers + +To run LFM2, you need to install Hugging Face [`transformers`](https://github.com/huggingface/transformers) v4.55 or a more recent version as follows: + +```bash +pip install -U transformers +``` + +Here is an example of how to generate an answer with transformers in Python: + +```python +from transformers import AutoModelForCausalLM, AutoTokenizer +# Load model and tokenizer +model_id = "LiquidAI/LFM2-2.6B" +model = AutoModelForCausalLM.from_pretrained( + model_id, + device_map="auto", + torch_dtype="bfloat16", +# attn_implementation="flash_attention_2" <- uncomment on compatible GPU +) +tokenizer = AutoTokenizer.from_pretrained(model_id) +# Generate answer +prompt = "What is C. elegans?" +input_ids = tokenizer.apply_chat_template( + [{"role": "user", "content": prompt}], + add_generation_prompt=True, + return_tensors="pt", + tokenize=True, +).to(model.device) +output = model.generate( + input_ids, + do_sample=True, + temperature=0.3, + min_p=0.15, + repetition_penalty=1.05, + max_new_tokens=512, +) +print(tokenizer.decode(output[0], skip_special_tokens=False)) +# <|startoftext|><|im_start|>user +# What is C. elegans?<|im_end|> +# <|im_start|>assistant +# C. elegans, also known as Caenorhabditis elegans, is a small, free-living +# nematode worm (roundworm) that belongs to the phylum Nematoda. +``` + +You can directly run and test the model with this [Colab notebook](https://colab.research.google.com/drive/1_q3jQ6LtyiuPzFZv7Vw8xSfPU5FwkKZY?usp=sharing). + +### 2. vLLM + +You need to install [`vLLM`](https://github.com/vllm-project/vllm) v0.10.2 or a more recent version as follows: + +```bash +uv pip install vllm==0.10.2 --extra-index-url https://wheels.vllm.ai/0.10.2/ --torch-backend=auto +``` + +Here is an example of how to use it for inference: + +```python +from vllm import LLM, SamplingParams +prompts = [ + "What is C. elegans?", + "Say hi in JSON format", + "Define AI in Spanish" +] +sampling_params = SamplingParams(temperature=0.3, min_p=0.15, repetition_penalty=1.05) +llm = LLM(model="LiquidAI/LFM2-2.6B") +outputs = llm.generate(prompts, sampling_params) +for output in outputs: + prompt = output.prompt + generated_text = output.outputs[0].text + print(f"Prompt: {prompt!r}, Generated text: {generated_text!r}") +``` + +### 3. llama.cpp + +You can run LFM2 with llama.cpp using its [GGUF checkpoint](https://huggingface.co/LiquidAI/LFM2-2.6B-GGUF). Find more information in the model card. + +## 🔧 How to fine-tune LFM2 + +We recommend fine-tuning LFM2 models on your use cases to maximize performance. + +| Notebook | Description | Link | +|-------|------|------| +| SFT (Unsloth) | Supervised Fine-Tuning (SFT) notebook with a LoRA adapter using Unsloth. | Colab link | +| SFT (Axolotl) | Supervised Fine-Tuning (SFT) notebook with a LoRA adapter using Axolotl. | Colab link | +| SFT (TRL) | Supervised Fine-Tuning (SFT) notebook with a LoRA adapter using TRL. | Colab link | +| DPO (TRL) | Preference alignment with Direct Preference Optimization (DPO) using TRL. | Colab link | + +## 📈 Performance + +LFM2 outperforms similar-sized models across different evaluation categories. We only report scores using instruct variants and non-thinking modes for consistency. + +![image/png](https://cdn-uploads.huggingface.co/production/uploads/61b8e2ba285851687028d395/xQNi_QoqAWBB1vg2XR3Rh.png) + +| 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 | + +## 📬 Contact + +If you are interested in custom solutions with edge deployment, please contact [our sales team](https://www.liquid.ai/contact). \ No newline at end of file