Skip to content

Can i get similarity_top_k in faiss index?  #3

@nasirus

Description

@nasirus

I am using GPTFaissIndex and want to get the top 5 closest matching term to the query.
Can someone clarify where to set the parameter? i have tried to set in index.query but failed
Code:

query = "Who is the author in the book?"
d = 1536
faiss_index = faiss.IndexFlatL2(d)
documents = SimpleDirectoryReader('./test').load_data()
promptHelper = PromptHelper(2000, 512,20)
service_context = ServiceContext.from_defaults(llm_predictor=llm_predictor, prompt_helper=promptHelper)
index = GPTFaissIndex.from_documents(documents, faiss_index=faiss_index, service_context=service_context)
result = index.query(
      query_final,
      similarity_top_k=5,
      text_qa_template=prompt,
      mode="embedding",
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions