Collection.embed_multi silently accepts an incorrect number of embeddings
On commit 764dc386c58b625f3ad9d203e699715ad208455f (0.36), Collection.embed_multi_with_metadata() combines the model's output and the filtered input with zip(). If a plugin returns fewer embeddings, some entries are silently omitted. Extra embeddings are silently discarded. No error is reported in either case.
Reproduction with a deliberately incomplete local embedding plugin, requiring no remote service:
import llm
class IncompleteModel(llm.EmbeddingModel):
model_id = "incomplete-demo"
def embed_batch(self, items, *, key=None):
for item in list(items)[:1]:
yield [float(len(item))]
collection = llm.Collection("demo", model=IncompleteModel())
collection.embed_multi([("1", "hello"), ("2", "world")], store=True)
print(collection.count()) # 1, no exceptionExpected: detect the mismatch before writing the current batch and report the expected and actual counts. Previously completed batches can remain committed, matching the existing batch transaction boundary.
This is defensive validation of the plugin contract, not a claim that a particular hosted provider currently returns incomplete responses. It checks result counts, not vector order or semantic correctness.
Source: simonw/llm