Created
July 21, 2024 16:29
-
-
Save idontcalculate/476d9eec89ed8f3ed3a00993da0ef9ac to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from fastembed.embedding import TextEmbedding | |
def get_book_vector(book_data): | |
embedder = TextEmbedding(model_name="BAAI/bge-base-en") | |
text = f"{book_data['title']} {book_data['description']}" | |
vector = list(embedder.embed(text)) | |
return vector[0] # Since embed returns a generator, we convert it to a list and take the first item. | |
def get_query_vector(query_text): | |
embedder = TextEmbedding(model_name="BAAI/bge-base-en") | |
vector = list(embedder.embed(query_text)) | |
return vector[0] # same as the upper one |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment