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

Text Embeddings Inference update #419

Closed
wants to merge 5 commits into from

Conversation

joaomsimoes
Copy link

@joaomsimoes joaomsimoes commented Sep 11, 2024

Hi everyone.

I wanted to use the Text Embeddings Inference with the encoder but I noticed two small bugs in the code. I believe that the HFEndpointEncoder was intentionally created to be used with TEI (right?)

  1. The loop for max_retries in attempts, that is inside of the function query, has no break or any system to return the result when we have a success response. I added a break, similar to the OpenAI encoder.

  2. The response from TEI is [[[array]]]. The array is inside of a list of a list. I remove one list when receiving the response. Without this it will throw a dimension error when comparing all the vectors.

These are the main bugs, but I would also take some time to purpose a future update. With TEI we can send a batch of texts

curl 127.0.0.1:8080/embed \
    -X POST \
    -d '{"inputs":["Today is a nice day", "I like you"]}' \
    -H 'Content-Type: application/json'

To save time, we could batch the different sentences to the endpoint. This would be great for longer document. If it sounds interesting I can try to help to develop it.

By the way, should I use semantic router for splitting text, or the semantic chunkers?

@joaomsimoes
Copy link
Author

Okay, I added the batch to the encoder. The bug number 2 it is now solved.

It is also much faster to batch the requests. Before was taking around a minute for a small document. Now it takes few seconds. I took an arbitrary number for the batch. This can be studied.

@jamescalam
Copy link
Member

@joaomsimoes DM'd you on discord but not sure if you still use it - we continued your PR here, can you take a look and let us know if all is correct? Thanks! #423

@jamescalam jamescalam assigned Vits-99 and unassigned ashraq1455 Sep 21, 2024
@jamescalam jamescalam added bug Something isn't working enhancement Enhancement to existing features labels Sep 21, 2024
@joaomsimoes joaomsimoes closed this by deleting the head repository Sep 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement Enhancement to existing features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants