Skip to content

IndexError: index 4 is out of bounds for axis 0 with size 4 #643

Answered by RafaelJohn9
RafaelJohn9 asked this question in Q&A
Discussion options

You must be logged in to vote

There are two reasons why this issue showed up:

Adding more doc inside a vectorstore with new vocab

  • In the Doc2VecVectorStore , when the vector store was initialized and added documents, it does it with no errors, however if you add more documents after that have new vocabs in the vector store again it causes the IndexError

Potential solution

  • genism's build_vocab method has the parameter update= which is usually False as the default though if changed to True after build it fixes the problem. Below is an example
# Check if the model already has a vocabulary built
        if len(self._model.wv) == 0:
            self._model.build_vocab(
                tagged_data
            )  # Build…

Replies: 4 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@RafaelJohn9
Comment options

RafaelJohn9 Oct 17, 2024
Collaborator Author

Comment options

You must be logged in to vote
0 replies
Comment options

RafaelJohn9
Oct 17, 2024
Collaborator Author

You must be logged in to vote
0 replies
Comment options

RafaelJohn9
Oct 22, 2024
Collaborator Author

You must be logged in to vote
0 replies
Answer selected by RafaelJohn9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants