Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Index isn't ready #519

Open
thepowerfulwoz opened this issue Jan 21, 2025 · 2 comments
Open

Error: Index isn't ready #519

thepowerfulwoz opened this issue Jan 21, 2025 · 2 comments

Comments

@thepowerfulwoz
Copy link

When constructing a basic hybrid router, and then calling it the error "Index is not ready" is thrown. My initial code was as follows:

encoder = HuggingFaceEncoder()
sparse_encoder = BM25Encoder()
index = HybridLocalIndex()
rl = HybridRouter(encoder=encoder, sparse_encoder=sparse_encoder, routes=routes, index=index)

print(rl("Get me an image of ships in the bay"))

After reading through the code and finding the is_ready() function, as well as looking through the index.add() function, I then attempted:

for route in routes:
    index.add(embeddings=encoder(route.utterances), routes=[route.name], utterances=route.utterances, sparse_embeddings=sparse_encoder(route.utterances))
    print(route.utterances)
print(index.get_routes())

This, however, both threw IndexError: index 41 is out of bounds for axis 0 with size 4, and only added the first utterance to the list of utterances.

It is very possible that I am missing something obvious, but I would appreciate some guidance on how to move forward.

Thanks in advance!

@thepowerfulwoz thepowerfulwoz changed the title Index isn't ready Error: Index isn't ready Jan 21, 2025
@jjovalle99
Copy link

router = SemanticRouter(
    encoder=encoder,
    routes=routes,
    auto_sync="local" # <---- This is missing 
)

or

router = SemanticRouter(
    encoder=dense_encoder,
    routes=routes,
)
router.sync(sync_mode="local")

Once you add that line it will work. Have not investigated the reason in depth tho.

@ahmadumar020
Copy link

Can you confirm whether adding the "sync" setting worked? @thepowerfulwoz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants