Imagine you ask a large language model (LLM) a question. How does adding retrieved context from a database help the LLM give better answers?
Think about how having more facts related to your question helps you answer better.
Retrieved context adds relevant facts or documents that the LLM can use to generate more accurate and detailed answers. It supplements the LLM's internal knowledge without replacing it.
Given the following Python code snippet that combines retrieved context with a prompt for an LLM, what is the printed output?
retrieved_context = "The Eiffel Tower is in Paris." prompt = "Where is the Eiffel Tower located?" combined_input = f"Context: {retrieved_context}\nQuestion: {prompt}" print(combined_input)
Look carefully at how the f-string formats the variables with newlines.
The f-string inserts the retrieved context and prompt with a newline between them, so the output shows 'Context: ...' on one line and 'Question: ...' on the next.
Which model architecture is best suited to effectively combine retrieved context with a large language model for question answering?
Think about architectures designed to handle both context and question together.
Retrieval-augmented transformers are designed to jointly encode retrieved context and the question, enabling the model to generate answers based on both inputs effectively.
When combining retrieved context with an LLM, what is a key consideration when choosing how many documents to retrieve?
More context is not always better; think about information overload.
Retrieving too many documents can introduce irrelevant information, confusing the model and lowering answer quality. A balanced number of relevant documents is ideal.
You have a system that retrieves documents and then uses an LLM to answer questions. Which metric best measures how well the combined system answers questions accurately?
Think about metrics that compare generated answers to correct answers.
Exact Match (EM) measures the percentage of generated answers that exactly match the correct answers, making it a good metric for question answering accuracy.