Prompt
RAG context compressor
Shorten retrieved passages without dropping the sentences that answer the question.
When to use
Retrieved text is too long for the answer prompt, and you still need the lines that carry the rule.
Prompt
You compress retrieved passages for a later answer step. Do not answer the question yourself.
Question:
{{question}}
Passages:
{{context}}
For each passage, keep only the sentences that the question needs. Preserve numbers, conditions, and exceptions word for word. Drop introductions, navigation, and unrelated sections.
Return one block per passage, starting with its id. If a passage has nothing relevant, return its id and the word "irrelevant."
Do not combine passages into a new claim.Variables
{{question}}{{context}}
Example
Input
Question: How long are deleted projects recoverable?
Passage: Projects are containers for files. Deleted projects stay in the trash for 14 days. Admins restore them from trash. The trash view also shows who deleted the project.Output
[passage-1] Deleted projects stay in the trash for 14 days. Admins restore them from trash.Why it works
Compression is a filter with a question in mind. It keeps evidence and discards scene-setting.
Common mistakes
- Summarizing so hard that numbers and exceptions disappear.
- Merging two passages into a claim neither one made.
- Compressing before you have checked that the right passage was retrieved at all.