Find answers from the community

Updated 3 months ago

Does anyone know how to do a similarity

Does anyone know how to do a similarity search between embeddings? Let's say I have this:
embedding_model = HuggingFaceEmbedding(model_name="embedder")
index = VectorStoreIndex.from_documents(documents, embed_model=embedding_model, storage_context=storage_context)

I want to use the same embedding_model to encode a query and find the most similar document in my vector store
v
W
D
3 comments
You can get lower level with retrievers & response_synthesizer, but you can also turn the index into query like: https://docs.llamaindex.ai/en/stable/understanding/putting_it_all_together/q_and_a.html#semantic-search

I think the piece missing there is to

Plain Text
from llama_index.core import Settings
Settings.embed_model = embedding_model
This will directly fall under your requirement: https://docs.llamaindex.ai/en/stable/module_guides/querying/retriever/root.html#retriever

It will use your query to find similar nodes from your dataset and will return that.
Thanks! Will try out the suggestions πŸ™‚
Add a reply
Sign up and join the conversation on Discord