diff --git a/_questions/llm-zoomcamp/module-2-vector-search/010_1a7b27c4df_idxerror-best-chunk-vector-search.md b/_questions/llm-zoomcamp/module-2-vector-search/010_1a7b27c4df_idxerror-best-chunk-vector-search.md new file mode 100644 index 00000000..6b10dec0 --- /dev/null +++ b/_questions/llm-zoomcamp/module-2-vector-search/010_1a7b27c4df_idxerror-best-chunk-vector-search.md @@ -0,0 +1,15 @@ +--- +id: 1a7b27c4df +question: 'Why do I get IndexError: list index out of range when accessing the best + chunk?' +sort_order: 10 +--- + +The error typically happens when the number of embeddings you generate does not match the number of document chunks. Make sure you create embeddings directly from the chunk list: + +```python +contents = [chunk["content"] for chunk in chunks] +X = embedder.encode_batch(contents) +``` + +The number of rows in `X` should be equal to `len(chunks)`.