When you ask ChatGPT to summarize a long document, it often produces generic, fluffy, and low-density text. It leaves out critical entities (names, dates, specific metrics) in favor of readable but ultimately useless overviews. Today, we are going to fix that using the Chain of Density (CoD) prompting technique.
What is Chain of Density Prompting?
Originally detailed in a research paper by Salesforce, AI researchers discovered that you can force an LLM to incrementally increase the "information density" of a summary over multiple iterations within a single prompt.
💡 Pro Tip: This prompt works best on GPT-4o and Claude 3.5 Sonnet. Smaller models (like Llama-3-8B) may struggle to follow the strict iteration constraints.
The Master Prompt (Copy & Paste)
Use the following prompt structure. Replace [INSERT YOUR TEXT HERE] with your actual document.
You will generate increasingly concise, entity-dense summaries of the following text:
[INSERT YOUR TEXT HERE]
Repeat the following 2 steps 5 times.
Step 1: Identify 1-3 informative entities (e.g., people, places, concepts, numbers) from the text that are missing from the previously generated summary.
Step 2: Write a new, denser summary of identical length that covers every entity and detail from the previous summary plus the Missing Entities.
A Missing Entity is:
- Relevant: to the main story.
- Specific: descriptive yet concise (5 words or fewer).
- Novel: not in the previous summary.
Format your output in a JSON list with keys: 'Missing_Entities' and 'Denser_Summary'.
Why This Works (Comparison)
| Summary Type | Entity Density | Readability | Best Use Case |
|---|---|---|---|
| Standard Prompt ("Summarize this") | Low (Generic) | High | Casual reading, getting the gist |
| Bullet Points | Medium | High | Quick scanning |
| Chain of Density (Iteration 5) | Very High | Medium | Professional briefings, study notes, technical docs |
FAQ: Common Prompting Questions
Why output in JSON?
By forcing the LLM to output JSON, you engage its programmatic reasoning pathways, which often leads to stricter adherence to the rules you laid out in the prompt.
Can I use this for coding?
While CoD is meant for text summarization, you can adapt the concept (iterative refinement) for code by asking the AI to first write the logic, then in step 2 add error handling, and in step 3 optimize for Big O notation.