LiquidAI/LFM2.5-Embedding-350M

Hugging Face Models Trending 模型

摘要

Liquid AI 发布了 LFM2.5-Embedding-350M,这是一种密集双编码器,用于多语言检索,支持11种语言,可作为 RAG 流水线的直接替代方案。

任务:句子相似度 标签:sentence-transformers, safetensors, lfm2, liquid, lfm2.5, edge, 句子相似度, 特征提取, 自定义代码, en, es, de, fr, it, pt, ar, sv, no, ja, ko, arxiv:2511.23404, base_model:LiquidAI/LFM2.5-350M-Base, base_model:finetune:LiquidAI/LFM2.5-350M-Base, 许可证:其他, 端点兼容, 区域:us
查看原文
查看缓存全文

缓存时间: 2026/06/20 14:21

LiquidAI/LFM2.5-Embedding-350M · Hugging Face

来源:https://huggingface.co/LiquidAI/LFM2.5-Embedding-350M Liquid AI

我们发布了两个新的同类最佳多语言检索模型:

  • LFM2.5-Embedding-350M — 一个密集双编码器,每个文档一个向量。索引最小、速度最快。
  • LFM2.5-ColBERT-350M (https://huggingface.co/LiquidAI/LFM2.5-ColBERT-350M) — 一个延迟交互模型。每个token一个向量,通过 MaxSim 匹配。准确率更高、泛化能力更强,但索引规模更大。

两个模型均为 3.5 亿参数,是 LFM 家族首批双向成员,基于 LFM2.5-350M-Base (https://huggingface.co/LiquidAI/LFM2.5-350M-Base) 构建。它们可作为您现有 RAG 管道的即插即用替代,面向 11 种语言实现快速、低成本且可靠的多语言/跨语言搜索。

关于双向架构和训练方法的更多细节,请参见我们的博文 (https://www.liquid.ai/blog/lfm2-5-retrievers)。

bienc (https://cdn-uploads.huggingface.co/production/uploads/63f389fda096536aeaae0a66/LjpFnq59BbuhKLVTExtcU.png)

https://huggingface.co/LiquidAI/LFM2.5-Embedding-350M#%F0%9F%93%84-model-details📄 模型详情

属性LFM2.5-Embedding-350MLFM2.5-ColBERT-350M (https://huggingface.co/LiquidAI/LFM2.5-ColBERT-350M)
类型密集双编码器(单向量)延迟交互(逐 token 向量)
总参数量~354M~353M
骨干网络LFM2.5-350M-Base (https://huggingface.co/LiquidAI/LFM2.5-350M-Base) + 双向补丁LFM2.5-350M-Base (https://huggingface.co/LiquidAI/LFM2.5-350M-Base) + 双向补丁
层数17(10 卷积 + 6 注意力 + 1 池化)17(10 卷积 + 6 注意力 + 1 密集)
词表大小65,53664,402
输出1024 维 CLS 向量每 token 128 维
相似度余弦相似度MaxSim
训练精度BF16BF16
许可证LFM Open License v1.0LFM Open License v1.0

文档长度: 512 tokens

支持语言: 英语、西班牙语、德语、法语、意大利语、葡萄牙语、阿拉伯语、瑞典语、挪威语、日语、韩语。

架构:

SentenceTransformer(
  (0): Transformer({'max_seq_length': 512, 'do_lower_case': False}) with Transformer model: Lfm2BidirectionalModel
  (1): Pooling({'word_embedding_dimension': 1024, 'pooling_mode_cls_token': True, 'pooling_mode_mean_tokens': False})
)

非对称提示词: 查询用 query:,段落用 document:。它们存储在模型配置中,通过 prompt_name 自动应用。

我们推荐 LFM2.5-Embedding-350M 和 LFM2.5-ColBERT-350M 用于短上下文检索场景,例如:

  • 电子商务:通过大规模语义搜索,跨多种语言查找商品。
  • FAQ 和知识库支持:在面向客户的界面中可靠地检索正确答案。
  • 设备端语义搜索:在消费级硬件上本地搜索文件、邮件和笔记。
  • 企业知识助手:跨语言检索内部法律、金融和技术文档。

https://huggingface.co/LiquidAI/LFM2.5-Embedding-350M#%F0%9F%8F%83-how-to-run🏃 如何运行

首先,安装 sentence-transformers

pip install -U sentence-transformers

https://huggingface.co/LiquidAI/LFM2.5-Embedding-350M#encoding-queries-and-documents编码查询和文档

加载 LFM2.5-Embedding-350M,分别编码查询和文档,每侧使用匹配的提示词名称。余弦相似度(或归一化点积)对文档进行排序:

from sentence_transformers import SentenceTransformer

# 加载模型(trust_remote_code 应用双向补丁)
model = SentenceTransformer(
    "LiquidAI/LFM2.5-Embedding-350M",
    trust_remote_code=True,
)

queries = [
    "What is the capital of France?",
    "Which city is Japan's capital?",
]
documents = [
    "Paris is the capital and largest city of France. Located on the Seine River in northern France, it serves as the country's political, economic, and cultural center.",
    "Tokyo, officially the Tokyo Metropolis, is the capital of Japan. It is the most populous metropolitan area in the world and serves as Japan's administrative, financial, and commercial hub.",
    "Berlin is the capital and largest city of Germany. Reunified in 1990 after the fall of the Berlin Wall, it now serves as a major cultural and political center in Europe.",
]

# 使用匹配的提示词名称进行编码;归一化后点积等于余弦相似度
q_emb = model.encode(queries,   prompt_name="query",    normalize_embeddings=True)
d_emb = model.encode(documents, prompt_name="document", normalize_embeddings=True)

scores = q_emb @ d_emb.T  # 形状: (n_queries, n_documents)

始终为查询传递 prompt_name="query",为段落传递 prompt_name="document"——模型是用这些前缀训练的,省略它们会无声地降低检索质量。

https://huggingface.co/LiquidAI/LFM2.5-Embedding-350M#flash-attention-2-optionalFlash Attention 2(可选)

LFM2.5-Embedding-350M 可配合 FlashAttention-2 运行(需要安装 flash-attn):

import torch
from sentence_transformers import SentenceTransformer

model = SentenceTransformer(
    "LiquidAI/LFM2.5-Embedding-350M",
    trust_remote_code=True,
    model_kwargs={"attn_implementation": "flash_attention_2", "dtype": torch.bfloat16},
)

经验证,在 bf16 噪声范围内与默认实现等价(多语言 NanoBEIR ndcg@10 在 11 种语言间差异小于 0.002)。在模型 512 token 最大长度下,速度提升较小(约 5%);如果对骨干网络进行微调或运行更长上下文,FA2 主要有助于显存和吞吐量。

https://huggingface.co/LiquidAI/LFM2.5-Embedding-350M#fine-tuning微调

标准的 sentence-transformers 训练可直接使用。例如使用 MultipleNegativesRankingLoss

from datasets import Dataset
from sentence_transformers import (
    SentenceTransformer,
    SentenceTransformerTrainer,
    SentenceTransformerTrainingArguments,
)
from sentence_transformers.losses import MultipleNegativesRankingLoss

model = SentenceTransformer("LiquidAI/LFM2.5-Embedding-350M", trust_remote_code=True)
loss = MultipleNegativesRankingLoss(model)

train_ds = Dataset.from_dict({
    "query":    [...],
    "positive": [...],
    # 可选: "negative": [...],
})

args = SentenceTransformerTrainingArguments(
    output_dir="out",
    num_train_epochs=1,
    per_device_train_batch_size=64,
    learning_rate=2e-5,
    warmup_ratio=0.1,
    bf16=True,
    prompts={"query": "query: ", "positive": "document: "},
)

trainer = SentenceTransformerTrainer(model=model, args=args, train_dataset=train_ds, loss=loss)
trainer.train()

注意事项:

  • 训练时始终传递非对称提示词(模型是用它们训练的)。
  • 对于更大有效批量而不出现 OOM,可将 MultipleNegativesRankingLoss 替换为 CachedMultipleNegativesRankingLoss
  • 使用 model.save_pretrained(...) 保存;建模文件和 auto_map 会保留,使得补丁行为在重新加载后依然生效。

https://huggingface.co/LiquidAI/LFM2.5-Embedding-350M#%F0%9F%93%88-performance📈 性能

我们在每项指标上以粗体标示最佳的双编码器和最佳的延迟检索模型。

https://huggingface.co/LiquidAI/LFM2.5-Embedding-350M#nanobeir-multilingual-extended–ndcg10NanoBEIR Multilingual Extended — NDCG@10

LiquidAI/nanobeir-multilingual-extended (https://huggingface.co/datasets/LiquidAI/nanobeir-multilingual-extended)。多语言检索能力。

模型类型avgardeenesfritjakonoptsv
LiquidAI/LFM2.5-ColBERT-350Mlate0.6050.5510.6060.6870.6070.6220.6060.6140.5900.5700.6130.586
LiquidAI/LFM2.5-Embedding-350Mdense0.5770.5290.5810.6440.5810.5920.5830.5750.5630.5570.5810.566
Qwen/Qwen3-Embedding-0.6Bdense0.5560.5140.5600.6490.5680.5650.5650.5510.5300.5160.5710.525
LiquidAI/LFM2-ColBERT-350Mlate0.5400.4910.5630.6610.5630.5640.5430.5570.5270.4490.5470.480
Alibaba-NLP/gte-multilingual-basedense0.5280.4770.5230.6240.5370.5420.5280.5110.4940.5160.5340.526
lightonai/GTE-ModernColBERT-v1late0.4890.3090.4990.6800.5250.5460.5160.4590.3680.4650.5300.483
lightonai/LateOnlate0.4840.3070.5050.6900.5310.5370.5140.4420.3260.4650.5330.475
lightonai/DenseOndense0.4320.1780.4740.6760.4960.5200.4870.3780.1970.4220.4930.433
Alibaba-NLP/gte-modernbert-basedense0.3830.1120.4490.6660.4480.4750.4080.2750.1800.3760.4310.391
BAAI/bge-large-en-v1.5dense0.3590.0590.4190.6420.4450.4750.4310.1980.1320.3580.4340.353

https://huggingface.co/LiquidAI/LFM2.5-Embedding-350M#mkqa-11–recall20MKQA-11 — Recall@20

MKQA (https://github.com/apple/ml-mkqa)。跨语言能力(我们目标语言子集)。

模型类型avgardeenesfritjakonoptsv
LiquidAI/LFM2.5-ColBERT-350Mlate0.6940.6080.7090.7480.7110.7150.7070.7030.6400.6890.7030.700
LiquidAI/LFM2.5-Embedding-350Mdense0.6910.6100.7090.7380.7080.7150.7030.6850.6300.6910.7100.708
Alibaba-NLP/gte-multilingual-basedense0.6750.5670.6920.7410.7050.7030.6970.6550.5630.6980.7000.699
LiquidAI/LFM2-ColBERT-350Mlate0.6460.5540.6960.7540.7110.7100.6670.6580.5580.5410.6690.589
Qwen/Qwen3-Embedding-0.6Bdense0.6380.5200.6710.7230.6780.6720.6710.6350.5430.6200.6670.620
lightonai/GTE-ModernColBERT-v1late0.4590.0920.5320.7540.5520.6150.5100.2750.1660.5030.5240.524
lightonai/LateOnlate0.4540.1570.4920.7550.5370.5770.4810.3160.2090.4720.5020.501
lightonai/DenseOndense0.4350.1650.4820.7510.4910.5530.4570.3250.2220.4380.4430.453
BAAI/bge-large-en-v1.5dense0.4130.1330.4710.7480.4500.5310.4610.2080.1720.4560.4430.467
Alibaba-NLP/gte-modernbert-basedense0.2950.0600.3330.7360.2730.4170.2910.1000.0520.3320.3260.330

https://huggingface.co/LiquidAI/LFM2.5-Embedding-350M#inference-speed—llamacpp推理速度 — llama.cpp

MacBook Pro M4 Max上通过llama.cppfp16测量端到端延迟,32 token 查询256 token 文档Docs cached表示文档嵌入已预计算并从索引中查找。

模型阶段文档缓存p50p95
LFM2.5-Embedding-350M查询嵌入7.3 ms9.6 ms
LFM2.5-ColBERT-350M查询嵌入8.1 ms8.5 ms
LFM2.5-ColBERT-350M查询嵌入 + MaxSim8.2 ms15.2 ms
LFM2.5-ColBERT-350M查询嵌入 + 文档嵌入 + MaxSim34.3 ms36.3 ms

两个模型 LiquiAI/LFM2.5-ColBERT-350M-GGUF (https://huggingface.co/LiquidAI/LFM2.5-ColBERT-350M-GGUF/) 和 LiquidAI/LFM2.5-Embedding-350M-GGUF (https://huggingface.co/LiquidAI/LFM2.5-Embedding-350M-GGUF/) 均提供不同量化架构的 Hugging Face 版本,用于 llama.cpp。

https://huggingface.co/LiquidAI/LFM2.5-Embedding-350M#inference-speed—enterprise-gpu推理速度 — 企业级 GPU

对于大规模生产级企业部署,我们还使用内部 GPU 栈进行实验,以在高并发负载下实现极低延迟服务。我们观察到低至 1 ms 的延迟。

GPU 服务延迟 (https://cdn-uploads.huggingface.co/production/uploads/63f389fda096536aeaae0a66/WTdmKJ2LpG07-iAqXYGDe.png)

加载设置p50p95p99
LFM2.5-Embedding-350M查询嵌入1.5 ms1.6 ms1.7 ms
LFM2.5-ColBERT-350M查询嵌入1.3 ms1.4 ms1.5 ms
LFM2.5-ColBERT-350M查询嵌入 + MaxSim2.5 ms2.7 ms2.8 ms
LFM2.5-ColBERT-350M查询嵌入 + 文档嵌入 + MaxSim22.8 ms24.1 ms26.4 ms

https://huggingface.co/LiquidAI/LFM2.5-Embedding-350M#%F0%9F%93%AC-contact📬 联系方式

  • 有问题或想联系?加入我们的 Discord 社区 (https://discord.com/invite/liquid-ai)。
  • 如果您对边缘部署的定制解决方案感兴趣,请联系我们的销售团队 (https://www.liquid.ai/contact)。

https://huggingface.co/LiquidAI/LFM2.5-Embedding-350M#citation引用

@article{liquidai2025lfm2,
  title={LFM2 Technical Report},
  author={Liquid AI},
  journal={arXiv preprint arXiv:2511.23404},
  year={2025}
}

相似文章

LiquidAI/LFM2.5-ColBERT-350M

Hugging Face Models Trending

LiquidAI 发布 LFM2.5-ColBERT-350M,这是一种后期交互多语言检索模型,同时还有一个密集双编码器变体,两者均基于 LFM2.5-350M-Base,支持 11 种语言,并设计为 RAG 管道的即插即用替代品。

LiquidAI/LFM2.5-230M

Hugging Face Models Trending

Liquid AI发布了LFM2.5-230M,一款紧凑的230M参数混合模型,针对设备端部署进行了优化,边缘推理速度快(在Galaxy S25 Ultra上达到213 tok/s),并通过强化学习构建,适用于智能体任务。

LiquidAI/LFM2.5-8B-A1B-GGUF

Hugging Face Models Trending

LiquidAI 发布了其 LFM2.5-8B-A1B 模型的 GGUF 量化版本,并提供了在多个推理引擎上的使用说明。

Liquid AI 发布 LFM2.5-8B-A1B

Reddit r/LocalLLaMA

Liquid AI 发布了 LFM2.5-8B-A1B,这是一款边缘模型,拥有 128K 上下文窗口、38T 预训练 token 和大规模强化学习,支持工具调用和复杂任务,同时可运行于入门级笔记本电脑。