QA with Retrieval (Using Vector Stores)
Helps answer questions such as: Are there queries that donโt have sufficient context? Should you add more context for these queries to get better answers? Or can you change your embeddings?
Last updated
Helps answer questions such as: Are there queries that donโt have sufficient context? Should you add more context for these queries to get better answers? Or can you change your embeddings?
Last updated
Framework | Phoenix Inferences | Phoenix Traces & Spans |
---|---|---|
Q&A with Retrieval at a Glance
LLM Input: User Query + retrieved document
LLM Output: Response based on query + document
Evaluation Metrics:
Did the LLM answer the question correctly (correctness)
For each retrieved document, is the document relevant to answer the user query?
Possibly the most common use-case for creating a LLM application is to connect an LLM to proprietary data such as enterprise documents or video transcriptions. Applications such as these often times are built on top of LLM frameworks such as Langchain or llama_index, which have first-class support for vector store retrievers. Vector Stores enable teams to connect their own data to LLMs. A common application is chatbots looking across a company's knowledge base/context to answer specific questions.
There are varying degrees of how we can evaluate retrieval systems.
Step 1: First we care if the chatbot is correctly answering the user's questions. Are there certain types of questions the chatbot gets wrong more often?
Step 2: Once we know there's an issue, then we need metrics to trace where specifically did it go wrong. Is the issue with retrieval? Are the documents that the system retrieves irrelevant?
Step 3: If retrieval is not the issue, we should check if we even have the right documents to answer the question.
Visualize the chain of the traces and spans for a Q&A chatbot use case. You can click into specific spans.
When clicking into the retrieval span, you can see the relevance score for each document. This can surface irrelevant context.
Phoenix surfaces up clusters of similar queries that have poor feedback.
Phoenix can help uncover when irrelevant context is being retrieved using the LLM Evals for Relevance. You can look at a cluster's aggregate relevance metric with precision @k, NDCG, MRR, etc to identify where to improve. You can also look at a single prompt/response pair and see the relevance of documents.
Phoenix can help you identify if there is context that is missing from your knowledge base. By visualizing query density, you can understand what topics you need to add additional documentation for in order to improve your chatbots responses.
By setting the "primary" dataset as the user queries, and the "corpus" dataset as the context I have in my vector store, I can see if there are clusters of user query embeddings that have no nearby context embeddings, as seen in the example below.
Found a problematic cluster you want to dig into, but don't want to manually sift through all of the prompts and responses? Ask chatGPT to help you understand the make up of the cluster. Try out the colab here
The first thing we need is to collect some sample from your vector store, to be able to compare against later. This is to able to see if some sections are not being retrieved, or some sections are getting a lot of traffic where you might want to beef up your context or documents in that area.
For more details, visit this page.
We also will be logging the prompt/response pairs from the deployed application.
For more details, visit this page.
Question | Metric | Pros | Cons |
---|---|---|---|
id | text | embedding |
---|---|---|
query | embedding | retrieved_document_ids | relevance_scores | response |
---|---|---|---|---|
Is this a bad response to the answer?
User feedback or LLM Eval for Q&A
Most relevant way to measure application
Hard to trace down specifically what to fix
Is the retrieved context relevant?
Directly measures effectiveness of retrieval
Requires additional LLMs calls
Is the knowledge base missing areas of user queries?
Query density (drift) - Phoenix generated
Highlights groups of queries with large distance from context
Identifies broad topics missing from knowledge base, but not small gaps
1
Voyager 2 is a spacecraft used by NASA to expl...
[-0.02785328, -0.04709944, 0.042922903, 0.0559...
who was the first person that walked on the moon
[-0.0126, 0.0039, 0.0217, ...
[7395, 567965, 323794, ...
[11.30, 7.67, 5.85, ...
Neil Armstrong
LangChain
LlamaIndex