[Performance]: 🐢 Sparse Embedding with SPLADE is Very Slow + OOM For larger batches - Expected Behavior?
Maintainer thường phản hồi trong vòng 4 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 20/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Cần làm rõ
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- python
- Lĩnh vực
- machine-learning, performance
Hướng nghiên cứu
Bắt đầu với hàm process_sparse_embeddings_by_batch được hiển thị, đặc biệt là hai lệnh gọi model.embed, và profile thời gian CPU cũng như mức sử dụng bộ nhớ của SPLADE ở các kích thước batch khác nhau. Công việc được xem là hoàn tất khi xác nhận được liệu hành vi về hiệu năng và OOM đã được báo cáo có đúng như dự kiến hay không, đồng thời ghi lại một tối ưu hóa đã được kiểm thử, một khuyến nghị về batching hoặc một tùy chọn mô hình nhẹ hơn.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Python
- Star
- 3.3k
- Fork
- 314
- Merge trung bình
- 5 ngày 7 giờ
- Pull request đã merge (30 ngày)
- 23
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của qdrant/fastembed
-
[Bug]: Bm25 splits Tamil, Hindi, Sinhala and other words on their combining marksCó thể đã có người làm @Nipuna-Lakruwan đã nhận 13 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 30/100
qdrant/fastembed#886 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 4 ngày
-
miniCOIL clean_words mutates input and loses counts when normalized words collideCó thể đã có người làm @pear1-pea đã nhận 21 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 1/100
Maintainer thường phản hồi trong vòng 4 ngày
-
[Bug]: Revision-pinned HF downloads can falsely report intact files as corruptedCó thể đã có người làm @N7766 đã nhận 24 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 4 ngày
-
[Bug]: URL-backed custom models with the same basename reuse the wrong cached modelCó thể đã có người làm @rtmalikian đã nhận 25 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 25/100
Maintainer thường phản hồi trong vòng 4 ngày
-
[Bug]: rerank_pairs raises TypeError when pairs are passed as a tuple of pairsCó thể đã có người làm @michaelkillgta đã nhận 54 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 22/100
Maintainer thường phản hồi trong vòng 4 ngày
Tất cả issue của qdrant/fastembed
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 69/100
anderspitman/awesome-tunneling#330 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
521xueweihan/HelloGitHub#4676 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
Maintainer thường phản hồi trong vòng 18 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
pandas-dev/pandas-stubs#2155 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
essreduce
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 69/100
Maintainer thường phản hồi trong vòng 1 ngày