Summarization condenses source content while preserving its key information. It can produce an article abstract, an executive report, a content preview, or a consolidated answer from many documents. The practical challenge is choosing a method that fits the amount of text without losing what matters. section 3.4 section 3.0
Start with a short text
For text that fits in one prompt, ask an LLM for a summary and specify the desired length. A request for a 30-word summary of a passage about 1980s home PCs yields a brief account of their role in personal computing. section 2.4.3
Choose the workflow by input size, document count, and how much detail must survive:
- Put the full input in one prompt when it fits the model’s context window, whether it is one document or several. section 3.3
- Use MapReduce when the input is too large, especially for many documents: summarize chunks independently, then combine those summaries. section 3.2 section 3.3
- Use refine when retaining the core of each document matters: update a running summary with each new document in sequence. section 3.2 section 3.3
Figure 3.4 Summarization flowchart. This flowchart guides you in selecting the right summarization approach based on whether you need to summarize multiple unrelated documents and whether the input text fits within the context window.
The flowchart turns document count and context-window fit into a choice between one prompt, MapReduce, and refine. section 3.3
MapReduce can process chunks independently and in parallel, favoring speed and lower token costs when some content loss is acceptable. Refine gives each step the current summary and the next input, preserving more context but adding sequential latency and token use. Inspect intermediate summaries rather than assuming the final result captured every important point. section 3.4 section 3.2.5
Build a running summary with LangChain
Wrap a refinement instruction in a PromptTemplate, connect it to a ChatOpenAI model with the LCEL pipe operator, and loop over Document objects. For each document, pass its page_content and the current summary to the chain; keep the result for the next iteration. Returning both final_summary and intermediate_steps makes the progression visible. section 3.2.5
Summarize web research
A research engine can search for a question, extract page text, summarize each result, and combine the summaries into a report. Keep each page summary alongside its URL and search query so the report can retain citations. A travel query about Astorga illustrates the per-page summaries. section 4.1 section 4.6.6 section 4.8











