Question answering produces an answer to a natural-language question. A small FAQ bot can treat the task as search: match the user’s wording to a stored question, then return its paired response. section 3.7
A practical question-answering pipeline can combine these roles:
- Index documents or questions with TF–IDF vectors or semantic embeddings. section 3.7 section 10.3.9
- Retrieve documents likely to contain relevant information. section 10.3.9
- Extract an answer from the retrieved context, or ask a generative model to synthesize one. section 10.3.10 section 10.3.11
- Constrain generation to supplied sources and allow an explicit “I don’t know” response when the context is insufficient. section 10.3.11
FAQ matching with TF–IDF
Load question-and-answer pairs, fit scikit-learn’s TfidfVectorizer on the questions, transform a user query, and select the question with the largest dot product. A query such as “What’s overfitting a model?” retrieves “What is overfitting?” and returns its stored answer. Sparse or misspelled wording can produce poor matches. section 3.7
Retrieval-augmented answering
A Haystack pipeline can place an EmbeddingRetriever before a reader such as roberta-base-squad2, or connect retrieval to a generative PromptNode using flan-T5. Extractive QA works well when the answer is stated clearly; generation helps expand answers to more complicated why and how questions, but still needs grounding checks. section 10.3.9 section 10.3.11



