Skip to content

[FAQ] #289

Description

@sameena83

Course

llm-zoomcamp

Question

Why do I get IndexError: list index out of range when accessing the best chunk?

Answer

This usually happens when the number of embeddings does not match the number of document chunks.

Make sure you create embeddings directly from the chunk list:

contents = [chunk["content"] for chunk in chunks]
X = embedder.encode_batch(contents)

The number of rows in X should be equal to len(chunks).

Checklist

  • I have searched existing FAQs and this question is not already answered
  • The answer provides accurate, helpful information
  • I have included any relevant code examples or links

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions