When document libraries exceed the model's context window, sliding window chunking splits the text into overlapping segments, processes each chunk with local summarizations, and aggregates the results using a hierarchical map-reduce prompt structure.
chunks = split_text(large_text, size=2000, overlap=200)
local_summaries = [call_llm(f"Extract facts: {c}") for c in chunks]
final_summary = call_llm("Combine summaries:\n" + "\n".join(local_summaries))
Claude handles local maps with high extraction precision. XML tag parameters help keep segment summaries distinct.