-
Notifications
You must be signed in to change notification settings - Fork 35
Build embeddings #506
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
base: main
Are you sure you want to change the base?
Build embeddings #506
Conversation
21084f4
to
d281834
Compare
d281834
to
3e218b9
Compare
src/doc_builder/build_embeddings.py
Outdated
if output_warmup["error"] == "503 Service Unavailable": | ||
print("Waking up Embedding Inference Endpoints. Retrying in 5 minutes") | ||
time.sleep(300) # 5 minutes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would be more satisfying to receive an event when the endpoint is available (HTTP SSE events for instance), but i guess that's painful to do in Python
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does HF ednpoints provide events? cc: @philschmid
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a huggingface_hub.InferenceEndpoint
client in Python if you want but it does the same as you (wait for model to be available).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If instead of an API url you have the name of an inference endpoint, you can do:
from huggingface_hub import get_inference_endpoint
endpoint = get_inference_endpoint(name="...")
client = endpoint.wait().client
client.text_embedding(...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mishig25 Little update on inference endpoint. Before the .wait()
call, you must do .resume()
. If the endpoint scaled down to zero or have been paused, it will be restarted. So the snippet should look like this:
from huggingface_hub import get_inference_endpoint
endpoint = get_inference_endpoint(name="...")
client = endpoint.resume().wait().client
client.feature_extraction(...)
src/doc_builder/build_embeddings.py
Outdated
print(len(embeddings)) | ||
|
||
# Step 3: push embeddings to vector database | ||
# TODO |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ping again when you have this part i'd be interested in seeing it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very cool project! Looking forward to see it live 🎉
I've made a rough review of the current implementation. Feel free to ignore comments if you feel differently (especially if it's a POC for now)
711d783
to
d97d20a
Compare
ccf14ca
to
48672d1
Compare
554aa51
to
2d417a9
Compare
2d417a9
to
fa3fa2f
Compare
66bb76e
to
6522c16
Compare
6a7b825
to
ae19f1c
Compare
9d5f789
to
0a863af
Compare
f99bfbc
to
b0f055c
Compare
Add new command to doc-builder that creates embeddings from docs of huggingface libraries
Usage of the new command:
How it works
doc-builder handles all the autodoc derivatives to crawl correct python objects and get their docstrings in markdowns. For example, find diffusers chunks at diffuers-chunks.json
To save cost (for efficiency), I've turned on HF Inference Endpoints settings that makes it go to sleep if there was no usage in the last 15 mins. Therefore, I have this warmup check here:
doc-builder/src/doc_builder/build_embeddings.py
Lines 350 to 355 in 3e218b9
Note: almost all changes of this PR is addition (i.e. it does not break any existing doc-builder functionalities, I will merge the PR once I test with meilisearch)