Closed ssdidis closed 3 months ago
it looks like in this pipeline, the function build_and_store_faiss_index() is a wrapper that calls the faiss library. However, the rest of the functions are either user-defined or come from some other library - can't really tell because your code is not reproducible. Your error says you have a problem in embeddings.encode([query_text]) which is probably not using faiss since the core faiss does not support embedding text @ssdidis so this is out of scope for us.
am trying to build a similarity search in python, cannot debug the function:
def perform_similarity_search(query_text, index, embeddings, top_k=5): """Perform similarity search in the FAISS index for a given query text."""
Use the embeddings object to embed the query_text into a vector.
def run_indexing_pipeline(): documents = fetch_documents(documents_dir) text_chunks = divide_documents_into_text_chunks(documents) embeddings_model = prepare_embeddings() faiss_index = build_and_store_faiss_index(text_chunks, embeddings_model, faiss_db_path)
def perform_similarity_search(query_text, index, embeddings, top_k=5): """Perform similarity search in the FAISS index for a given query text."""
Use the embeddings object to embed the query_text into a vector.
ERRORS: Traceback (most recent call last): File "/home/ubuntu/new_d.py", line 61, in
run_indexing_pipeline()
File "/home/ubuntu/new_d.py", line 56, in run_indexing_pipeline
distances, indices = perform_similarity_search(query, faiss_index, embeddings_model)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ubuntu/new_d.py", line 36, in perform_similarity_search
query_vector = embeddings.encode([query_text])
This is error being shown, pls let me know how I can correct it