Find answers from the community

Updated last year

Faiss embeddings

At a glance

The community member is asking how to get the raw embeddings of retrieved nodes when using the faiss vector store, instead of just the indices and similarities. They provide an example of their current retrieval code and mention that they need the raw embeddings to create clusters from their index.

In the comments, another community member suggests using faiss directly, although they are unsure if it returns embeddings. The original poster confirms that using faiss directly works and is simpler.

Useful resources
Any way to get the raw embeddings of retrieved nodes (not just indices + similarities as pictured) when using faiss vectorstore?
Or a hack/workaround to get the raw embeddings here?

example of my current retrieval code:

Plain Text
    from llama_index.vector_stores.types import VectorStoreQuery
      vsq = VectorStoreQuery(query_embedding=item.query_embedding, similarity_top_k=item.num_results, output_fields=['embeddings'])
      query_result = index.vector_store.query(query=vsq)
      return query_result
    

and:

Plain Text
 x = await index.as_retriever(similarity_top_k=num_results_to_retrieve).aretrieve(QueryBundle("not used", embedding=item.query_embedding))



Looking make clusters from my index, and to create the clusters i need the raw embeddings
Attachment
image.png
L
B
3 comments
You might have to use faiss directly?

Although I'm not even sure if it returns embeddings. The vector store source code doesn't seem to indicate that anyways

https://github.com/run-llama/llama_index/blob/8043613e0aadcb6d5fffd4f1dc466f911088ac73/llama_index/vector_stores/faiss.py#L169
@Logan M right on, works with using faiss directly:

thanks
Attachment
image.png
actually simpler this way here hah
Attachment
image.png
Add a reply
Sign up and join the conversation on Discord