Summarization Patterns
Three battle-tested patterns for turning long documents, transcripts, and chat logs into high-signal summaries with Meridian's adaptive model router. Each pattern trades latency, cost, and fidelity differently — pick the one that matches your workload.
1. Single-pass summarization
The cheapest and fastest pattern. Send the full document in one request and ask for a bounded summary. Works for anything under the model's effective context budget — typically articles, short reports, and meeting transcripts under 30k tokens. Route toazure/model-routerand let Meridian choose between fast and reasoning models based on length.
Best for: news articles, single meetings, support tickets, short PDFs.
2. Map-reduce over chunks
For documents that exceed the context window, split into overlapping chunks, summarize each in parallel, then summarize the summaries. The map stage runs on a cheap fast model; the reduce stage on a reasoning model. Overlap of 10–15% keeps cross-chunk context from being lost at boundaries.
Best for: long PDFs, books, multi-hour transcripts, large codebases.
3. Refine (rolling summary)
Process chunks sequentially. Each call receives the previous running summary plus the next chunk and produces an updated summary. Slower than map-reduce because it cannot parallelize, but preserves narrative order — ideal when the document tells a story or accumulates state.
Best for: legal contracts, novels, incident timelines, long email threads.
Example: map-reduce with Meridian
import OpenAI from 'openai';
const client = new OpenAI({
apiKey: process.env.MERIDIAN_KEY,
baseURL: 'https://llm.getnimbus.net/v1',
});
async function summarize(chunks: string[]) {
const partials = await Promise.all(
chunks.map((c) =>
client.chat.completions.create({
model: 'azure/model-router',
messages: [
{ role: 'system', content: 'Summarize in 3 bullets.' },
{ role: 'user', content: c },
],
}).then((r) => r.choices[0].message.content)
)
);
const merged = partials.join('\n---\n');
const final = await client.chat.completions.create({
model: 'azure/model-router',
messages: [
{ role: 'system', content: 'Combine into a unified summary.' },
{ role: 'user', content: merged },
],
});
return final.choices[0].message.content;
}