liveBook · Manning

Few-shot chain of thought

As explained in Build an Advanced RAG Application (From Scratch)

Few-shot chain-of-thought prompting provides example problems with reasoning steps to guide a model in solving a new problem step by step.

Few-shot chain-of-thought prompting supplies example problems with reasoning steps, then asks a language model to solve a new problem step by step. It improves reasoning over a few-shot baseline, but requires carefully prepared example prompts. section 5.3.2

Use the technique to:

  • Elicit an explicit sequence of reasoning statements before the final answer. section 5.3.2
  • Guide analysis of large semantic-search result sets that would otherwise overwhelm users. section 5.3.2
  • Separate reasoning extraction from answer extraction, which requests only the missing numerical result. section 5.3.2

Hotel recommendation analysis

Provide hotel search results and ask which hotel best matches the query, compare the top three using review quotes, identify recurring themes, summarize strengths and weaknesses, and make an overall recommendation. A resulting analysis selects Grand Hotel du Palais Royal for its Louvre location, nearby food options, cleanliness, and service.

How Build an Advanced RAG Application (From Scratch) covers it

How deep it goes
Demonstrates prompt structure, reasoning-versus-answer extraction, and an API-oriented hotel-analysis workflow.
Examples
Uses mathematical word problems, hotel examples, FAISS results, review quotes, and a step-by-step recommendation prompt.
What it assumes
Builds on few-shot prompting and assumes retrieved results can be inserted into a model prompt.
What you can do after
Apply it via an OpenAI chat-completion call to analyze retrieved results and produce a recommendation.
How it connects
Connects few-shot prompting with chain-of-thought prompting, semantic search, retrieval, and recommendation.

Also explained in

Compare how 3 books explain few-shot chain of thought →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build an Advanced RAG Application (From Scratch). The section links point to the parts of the book it draws on.