Course contentsShow
← Machine Learning and Deep Learning
Lesson 1310 of 3,53829. Core NLP TasksFree lesson

QA with Large Language Models

Zero-shot and few-shot QA using instruction-tuned LLMs without task-specific fine-tuning.

QA with Large Language Models

What you'll learn: How instruction-tuned LLMs can answer questions directly without task-specific training, using zero-shot and few-shot prompting.

The Core Idea

With Large Language Models (LLMs) like GPT-4 or instruction-tuned variants of other models, you don't need to fine-tune on question-answering datasets anymore. Instead, you simply ask the model your question in natural language. The model has learned general QA patterns during instruction tuning, so it can answer immediately.

Zero-shot QA means giving the model a question with context and expecting an answer—no examples provided. Few-shot QA means showing the model 1-3 example question-answer pairs first, then asking your real question.

How It Works

Think of it like asking a knowledgeable friend versus training a specialist. Traditional QA systems (like BERT on SQuAD) are specialists trained specifically for span extraction. LLMs are generalists who've seen so many instruction-following examples during training that they understand "when given a question and context, provide an answer."

You format your prompt like:

Context: [passage]
Question: [your question]
Answer:

The LLM generates the answer—sometimes extracting spans, sometimes synthesizing information, depending on the question type. Few-shot prompting helps the model understand your preferred answer format by showing examples first.

Why This Matters

This approach is incredibly flexible. You can switch question types, domains, or formats instantly without retraining. The trade-off? You lose some precision compared to fine-tuned models and consume more compute per query. But for rapid prototyping, multi-domain QA, or when you lack training data, LLM-based QA is transformative.

Key Takeaway: Instruction-tuned LLMs enable zero-shot and few-shot QA through natural language prompting alone, trading specialized accuracy for unprecedented flexibility across question types and domains.