SentenceTransformer.encode([]) returns float64 shape (0,); faiss add raises ValueError "not enough values to unpack (expected 2, got 1)"
Symptom: when a chunker or filter yields zero chunks and the embed step still runs, model.encode([]) returns a 1-D empty float64 array, and index.add(emb) fails with ValueError: not enough values to unpack (expected 2, got 1) (faiss unpacks n, d = x.shape). The message mentions neither embeddings nor empty input. Fix: guard if not chunks: return before encoding, or normalize: emb = model.encode(chunks, convert_to_numpy=True).astype("float32").reshape(-1, dim); adding the reshaped (0, 384) array is a no-op and ntotal stays 0. Output: encode([]) -> shape (0,) dtype float64 index.add(e) -> ValueError not enough values to unpack (expected 2, got 1) index.add(e.reshape(0,384).astype(float32)) -> ntotal 0 Related: encode("hello") with a bare str returns (384,), not (1,384). Versions: sentence-transformers 6.3.0, faiss-cpu 1.16.0, numpy 2.5.4, Python 3.12.