[Performance]: 🐢 Sparse Embedding with SPLADE is Very Slow + OOM For larger batches - Expected Behavior?
Los mantenedores suelen responder en 4 días
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 20/100
- Tipo de issue
- Error
- Claridad
- Necesita aclaración
- Estado de actividad
- Estancado
- Stack tecnológico
- python
- Área
- machine-learning, performance
Línea de trabajo
Comienza con la función mostrada process_sparse_embeddings_by_batch, especialmente con las dos llamadas a model.embed, y perfila el tiempo de CPU y el uso de memoria de SPLADE con distintos tamaños de batch. Se consideraría terminado si se confirma si el comportamiento de rendimiento y OOM informado es el esperado y se documenta una optimización probada, una recomendación sobre el batching o una opción de modelo más ligero.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Context
I’m experimenting with the [FastEmbed](https://github.com/qdrant/fastembed) package to generate sparse embeddings for ~100K candidate profiles, each consisting of 2–10 lines of text. These embeddings are being stored in Qdrant.
Initially, I tested dense embeddings on 1000 profiles:
all-MiniLM-L6-v2via FastEmbed: ~40 seconds- Switched to
sentence-transformers: ~6s on GPU, ~10s on CPU
Now, I'm trying sparse embeddings with SPLADE (prithivida/Splade_PP_en_v1*). Processing 2,340 profiles took ~100 minutes (~3s/profile). At this rate, 100K profiles will take 8+ hours.
Questions
- Is ~3s/profile expected for SPLADE on CPU?
- Is there any way to optimize this (code, hardware, batch size)?
- Are there lighter-weight sparse models or best practices I should consider?
Hardware & Env
- Machine: Intel Core i7 (11th Gen), 16 GB RAM
- Platform: WSL2 (Ubuntu)
- FastEmbed: Latest
- Model:
prithivida/Splade_PP_en_v1 - Qdrant: Local instance with
prefer_grpc=True - Batch size: 8 (OOMs at 16) [Note I am not specifiying batch size in fastembed model.embed]
Initialization Code
client = QdrantClient(
url="http://localhost:6333",
prefer_grpc=True,
)
FASTEMBED_CACHE_DIR = "/home/saad/.cache/fastembed"
model = SparseTextEmbedding(
model_name="prithivida/Splade_PP_en_v1",
cache_dir=FASTEMBED_CACHE_DIR
)
process_sparse_embeddings_by_batch(
client=client,
collection_name="candidate_profiles_mvp_v1",
data_path="indexing/test_data.jsonl",
model=model,
jsonl_batch_size=8,
)
Batch Embedding Function
def process_sparse_embeddings_by_batch(
client: QdrantClient,
collection_name: str,
data_path: str,
model: SparseTextEmbedding,
jsonl_batch_size: int = 8,
):
total_records = sum(1 for _ in open(data_path))
total_batches = (total_records + jsonl_batch_size - 1) // jsonl_batch_size
logger.info(f"Total records: {total_records}, Total batches: {total_batches}")
jsonl_batches = load_jsonl(data_path, batch_size=jsonl_batch_size)
total_processed = 0
for batch_idx, raw_batch in enumerate(tqdm(jsonl_batches, total=total_batches, desc="Processing JSONL batches")):
try:
extracted_batch = extract_profile_data(raw_batch)
if not extracted_batch:
logger.warning(f"Batch {batch_idx + 1} had no valid profiles, skipping")
continue
batch_df = create_profile_dataframe(extracted_batch)
instance_ids = batch_df["instance_id"].tolist()
full_profile_docs = batch_df["full_profile"].tolist()
inferred_skills_docs = [doc if doc else "" for doc in batch_df["inferred_skills"].tolist()]
# ❗ Sparse embeddings via SPLADE
fp_gen = list(model.embed(full_profile_docs)) # Slow part
is_gen = list(model.embed(inferred_skills_docs))
batch_points = []
for instance_id, fp_emb, is_emb in zip(instance_ids, fp_gen, is_gen):
batch_points.append(
models.PointVectors(
id=instance_id,
vector={
"full_profile_sparse": models.SparseVector(
indices=fp_emb.indices,
values=fp_emb.values,
),
"inferred_skills": models.SparseVector(
indices=is_emb.indices,
values=is_emb.values,
),
},
)
)
if len(batch_points) >= 256:
client.update_vectors(collection_name=collection_name, points=batch_points, wait=False)
batch_points = []
if batch_points:
client.update_vectors(collection_name=collection_name, points=batch_points, wait=False)
total_processed += len(instance_ids)
except Exception as e:
logger.error(f"Error processing batch {batch_idx + 1}: {e}")
continue
logger.info(f"Completed processing. Total profiles processed: {total_processed}")
Sample Output
Processing JSONL batches: 19%|█▉ | 2340/12285 [1:39:38<8:24:04, 3.04s/it]
OOM starts happening when I increase the jsonl_batch_size beyond 8. That means SPLADE doesn’t scale well on my CPU-based setup.
Would appreciate any help to improve this or confirm if this is the expected behavior.
- Lenguaje dominante
- Python
- Estrellas
- 3.3k
- Forks
- 314
- Merge medio
- 5 d 7 h
- PR fusionados (30 d)
- 23
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de qdrant/fastembed
-
[Bug]: Bm25 splits Tamil, Hindi, Sinhala and other words on their combining marksPosiblemente ocupada @Nipuna-Lakruwan la tomó hace 12 días. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 30/100
qdrant/fastembed#886 · 2 comentarios ·
Los mantenedores suelen responder en 4 días
-
miniCOIL clean_words mutates input and loses counts when normalized words collidePosiblemente ocupada @pear1-pea la tomó hace 20 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 1/100
Los mantenedores suelen responder en 4 días
-
[Bug]: Revision-pinned HF downloads can falsely report intact files as corruptedPosiblemente ocupada @N7766 la tomó hace 24 días. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 82/100
Los mantenedores suelen responder en 4 días
-
[Bug]: URL-backed custom models with the same basename reuse the wrong cached modelPosiblemente ocupada @rtmalikian la tomó hace 24 días. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 25/100
Los mantenedores suelen responder en 4 días
-
[Bug]: rerank_pairs raises TypeError when pairs are passed as a tuple of pairsPosiblemente ocupada @michaelkillgta la tomó hace 54 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 22/100
Los mantenedores suelen responder en 4 días
Todos los issues de qdrant/fastembed
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
TigreGotico/orthography2ipa#2950 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Unstructured-IO/unstructured#4876 ·
Los mantenedores suelen responder en 6 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
openfoodfacts/openfoodfacts-python#579 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 90/100
fairagro/m4.2_sql_to_arc#388 ·
Los mantenedores suelen responder en 1 día