Question answering, or QA, is an NLP task where a system takes a question and produces an answer.
Question — What year was the first iPhone released?
Answer — 2007
QA helps users find information faster. Instead of reading a long document, a user can ask a question and receive a direct answer.
Long document — A detailed article about the history of computing.
Question — When was the first computer invented?
Answer — The mid-twentieth century.
A QA system usually works with three things. The question is what the user wants to know. The context is the text used to find the answer. The answer is the information returned.
Context — The Python programming language was created by Guido van Rossum in 1991.
Question — Who created Python?
Answer — Guido van Rossum.
Without a good context, the system may produce a wrong or unsupported answer.
Extractive QA finds the answer directly from the text. The answer is a span of words taken from the passage. The system does not generate new words.
Context — The Eiffel Tower was built in 1889 by Gustave Eiffel.
Question — Who built the Eiffel Tower?
Extracted answer — Gustave Eiffel
Generative QA creates a new answer based on the context and the question. The answer is not copied directly from the text. It is more flexible but requires careful evaluation.
Context — Overfitting happens when a model learns training data too closely.
Question — What is overfitting in simple terms?
Generated answer — Overfitting is when a model memorizes training data instead of learning general patterns.
Retrieval-Augmented Generation, or RAG, combines search with text generation. The system first finds relevant documents, then generates an answer using those documents.
The user asks a question
The system searches a knowledge base or document collection
Relevant documents are retrieved
The system generates an answer using those documents
Question — What are the main causes of overfitting?
Retrieved passage — A passage about overfitting from a knowledge base.
Generated answer — Overfitting can be caused by too much model complexity, not enough training data, or training for too many epochs.
RAG helps reduce hallucinations by grounding answers in real retrieved documents.
Open-domain QA answers questions about any topic. Closed-domain QA focuses on a specific subject area.
Answers questions on any topic.
Example — What is the capital of France?
Focuses on a specific subject area.
Example — What are the side effects of ibuprofen? (medical knowledge base)
A typical QA pipeline processes the question, finds context, generates an answer, and returns the result.
Receive the question from the user
Preprocess the question
Search for or load relevant context
Find or generate an answer from the context
Post-process the output
Return the answer to the user
Context — Machine learning is a method of data analysis that automates analytical model building. Systems can learn from data, identify patterns, and make decisions with minimal human intervention.
Question — What does machine learning allow systems to do?
Answer — Learn from data, identify patterns, and make decisions with minimal human intervention.
A QA system may not always find the answer in the given context. If the answer is not present, the system should say so rather than making something up.
Context — Tokenization is the process of breaking text into smaller units.
Question — What year was NLP invented?
Expected behavior — The context does not contain information about when NLP was invented.
A system that makes up an answer instead of saying it does not know is producing a hallucination.
A hallucination happens when a QA system produces an answer that sounds confident but is not supported by the context.
Hallucinations are a serious problem because users may trust the answer.
QA systems should be evaluated carefully to catch incorrect or unsupported answers.
Common methods: exact match scoring, partial match, human review, retrieval accuracy.
Context — Reinforcement learning is a type of machine learning where an agent learns by taking actions and receiving rewards or penalties based on those actions.
Question 1 — What is reinforcement learning?
Question 2 — Who invented reinforcement learning?
Answer both questions and explain why one answer can be found in the context but the other cannot.
Ask the AI if you need help understanding question answering, extractive vs generative QA, retrieval-augmented generation, QA pipelines, hallucinations, or how to evaluate QA systems.