for more information.This covers the basic usage of the Vespa store in LangChain.
Now you can return the results and continue using these in LangChain.Updating documents‚ÄãAn alternative to calling from_documents, you can create the vector
store directly and call add_texts from that. This can also be used to update
documents:query = "What did the president say about Ketanji Brown Jackson"results = db.similarity_search(query)result = results[0]result.page_content = "UPDATED: " + result.page_contentdb.add_texts([result.page_content], [result.metadata], result.metadata["id"])results = db.similarity_search(query)print(results[0].page_content)However, the pyvespa library contains methods to manipulate
content on Vespa which you can use directly.Deleting documents‚ÄãYou can delete documents using the delete function:result = db.similarity_search(query)# docs[0].metadata["id"] == "id:testapp:testapp::32"db.delete(["32"])result = db.similarity_search(query)# docs[0].metadata["id"] != "id:testapp:testapp::32"Again, the pyvespa connection contains methods to delete documents as well.Returning with scores‚ÄãThe similarity_search method only returns the documents in order of
relevancy. To retrieve the actual scores:results = db.similarity_search_with_score(query)result = results[0]# result[1] ~= 0.463This is a result of using the "all-MiniLM-L6-v2" embedding model using the
cosine distance function (as given by the argument angular in the
application function).Different embedding functions need different distance functions, and Vespa
needs to know which distance function to use when orderings documents.
Please refer to the
documentation on distance functions
for more information.As retriever‚ÄãTo use this vector store as a
LangChain retriever
simply call the as_retriever function, which is a standard vector store
Vespa is a fully featured search engine and vector database. It supports vector search (ANN), lexical search, and search in structured data, all in the same query.
Vespa is a fully featured search engine and vector database. It supports vector search (ANN), lexical search, and search in structured data, all in the same query. ->: for more information.This covers the basic usage of the Vespa store in LangChain.
Now you can return the results and continue using these in LangChain.Updating documents‚ÄãAn alternative to calling from_documents, you can create the vector
store directly and call add_texts from that. This can also be used to update
documents:query = "What did the president say about Ketanji Brown Jackson"results = db.similarity_search(query)result = results[0]result.page_content = "UPDATED: " + result.page_contentdb.add_texts([result.page_content], [result.metadata], result.metadata["id"])results = db.similarity_search(query)print(results[0].page_content)However, the pyvespa library contains methods to manipulate
content on Vespa which you can use directly.Deleting documents‚ÄãYou can delete documents using the delete function:result = db.similarity_search(query)# docs[0].metadata["id"] == "id:testapp:testapp::32"db.delete(["32"])result = db.similarity_search(query)# docs[0].metadata["id"] != "id:testapp:testapp::32"Again, the pyvespa connection contains methods to delete documents as well.Returning with scores‚ÄãThe similarity_search method only returns the documents in order of
relevancy. To retrieve the actual scores:results = db.similarity_search_with_score(query)result = results[0]# result[1] ~= 0.463This is a result of using the "all-MiniLM-L6-v2" embedding model using the
cosine distance function (as given by the argument angular in the
application function).Different embedding functions need different distance functions, and Vespa
needs to know which distance function to use when orderings documents.
Please refer to the
documentation on distance functions
for more information.As retriever‚ÄãTo use this vector store as a
LangChain retriever
simply call the as_retriever function, which is a standard vector store