[MLsys2026 Best Paper]: https://arxiv.org/abs/2506.08276. RAG on Everything with LEANN. Enjoy 97% storage savings while running a fast, accurate, and 100% private RAG application on your personal device.
Python aifaissgpt-osslangchainllama-indexllmlocalstorageoffline-firstollamaprivacypythonragretrieval-augmented-generationvector-databasevector-searchvectors
change wecaht app split logic& merge
yichuan52003091032083b7ea5a599b
diff --cc packages/leann-core/src/leann/api.pyindex 19546a6,529d817..832093d--- a/packages/leann-core/src/leann/api.py+++ b/packages/leann-core/src/leann/api.py@@@ -18,11 -18,10 +18,11 @@@ from .chat import get_lldef compute_embeddings(- chunks: List[str],- model_name: str,+ chunks: List[str],+ model_name: str,mode: str = "sentence-transformers",use_server: bool = True,- use_mlx: bool = False # Backward compatibility: if True, override mode to 'mlx'++ use_mlx: bool = False # Backward compatibility: if True, override mode to 'mlx',) -> np.ndarray:"""Computes embeddings using different backends.@@@ -46,9 -41,9 +46,9 @@@# Auto-detect mode based on model name if not explicitly setif mode == "sentence-transformers" and model_name.startswith("text-embedding-"):mode = "openai"-+if mode == "mlx":- return compute_embeddings_mlx(chunks, model_name)+ return compute_embeddings_mlx(chunks, model_name, batch_size=16)elif mode == "openai":return compute_embeddings_openai(chunks, model_name)elif mode == "sentence-transformers":@@@ -177,24 -188,15 +193,21 @@@ def compute_embeddings_openai(chunks: L# OpenAI has a limit on batch size and input lengthmax_batch_size = 100 # Conservative batch sizeall_embeddings = []-- for i in range(0, len(chunks), max_batch_size):- batch_chunks = chunks[i : i + max_batch_size]- print(- f"INFO: Processing batch {i // max_batch_size + 1}/{(len(chunks) + max_batch_size - 1) // max_batch_size}"- )-++ try:+ from tqdm import tqdm+ total_batches = (len(chunks) + max_batch_size - 1) // max_batch_size+ batch_range = range(0, len(chunks), max_batch_size)+ batch_iterator = tqdm(batch_range, desc="Computing embeddings", unit="batch", total=total_batches)+ except ImportError:+ # Fallback without progress bar+ batch_iterator = range(0, len(chunks), max_batch_size)++ for i in batch_iterator:+ batch_chunks = chunks[i:i + max_batch_size]+try:- response = client.embeddings.create(- model=model_name,- input=batch_chunks- )+ response = client.embeddings.create(model=model_name, input=batch_chunks)batch_embeddings = [embedding.embedding for embedding in response.data]all_embeddings.extend(batch_embeddings)except Exception as e: