350M dense bi-encoder model for multilingual retrieval and semantic search
← Back to Liquid NanosLFM2.5-Embedding-350M is a dense bi-encoder retrieval model that produces one 1024-dimensional vector per query or document. It is built for fast, compact multilingual and cross-lingual semantic search across 11 languages.
Use LFM2.5-Embedding-350M when you need a small, fast vector index or compatibility with standard dense-vector search. Use LFM2.5-ColBERT-350M when retrieval quality matters more than index size.
The model was trained with asymmetric prefixes: query: for queries and document: for passages. In sentence-transformers, pass prompt_name="query" or prompt_name="document". With other runtimes, add the prefix to the text yourself. Omitting them degrades retrieval quality.
from sentence_transformers import SentenceTransformermodel = 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.", "Tokyo is the capital of Japan.", "Berlin is the capital and largest city of Germany.",]query_embeddings = model.encode( queries, prompt_name="query", normalize_embeddings=True,)document_embeddings = model.encode( documents, prompt_name="document", normalize_embeddings=True,)scores = query_embeddings @ document_embeddings.Tprint(scores)
Embed and rank (in a separate shell, with the server running):
pip install numpy requests
import numpy as np, requestsQUERY_PREFIX, DOC_PREFIX = "query: ", "document: "def embed(text: str) -> np.ndarray: r = requests.post( "http://localhost:8080/v1/embeddings", json={"input": text}, ) v = np.array(r.json()["data"][0]["embedding"]) return v / np.linalg.norm(v)docs = [ "hi", "it is a bear", "The giant panda (Ailuropoda melanoleuca), sometimes called a panda bear or simply panda, is a bear species endemic to China.",]query = "What is panda?"q = embed(QUERY_PREFIX + query)for doc in docs: d = embed(DOC_PREFIX + doc) print(f"Score: {float(q @ d):.4f} | Q: {query} | D: {doc}")