Multi-Perspective RAG Text Summarizer
Goal
A RAG pipeline that improves multi-perspective summarization by dynamically retrieving and integrating live web documents to produce more balanced, well-grounded summaries on controversial topics.
The Problem
Traditional multi-perspective summarization systems rely on static, curated corpora that quickly become outdated and limited in perspective diversity, often reinforcing one-sided narratives and failing to capture the full range of arguments available on controversial topics. Meanwhile, naive web retrieval introduces noise and irrelevant content, making it difficult to reliably improve summary quality without careful filtering and structured generation.
Methodology
We broke down this project into five stages:
1. Offline Retrieval
- Built a TF-IDF vectorization pipeline using scikit-learn with lowercase normalization for consistent matching.
- For each query, computed cosine similarity against a 4,107-document corpus from ThePerspective dataset to retrieve the top-k most relevant offline documents.
- This established a clean baseline for comparison and enabled quantifying the marginal value of web augmentation.
2. Web Document Retrieval
- Implemented a robust web retrieval module using the Tavily search API with exponential backoff retry logic (starting at 1 second, doubling up to 32 seconds) to handle rate limiting gracefully.
- The module caches results locally to avoid redundant API calls during development and experimentation.
- Each retrieved document is normalized into a consistent schema storing URL, content, title, domain, and source metadata for traceability.
3. Relevance Filtering with LLM-as-Judge
- Deployed GPT-5-Nano as a binary relevance classifier to filter web documents before summarization.
- The LLM-as-Judge receives the query and each web document, returning a structured JSON mapping of relevance classifications.
- Validated this approach with human annotation: two independent annotators labeled 600 instances (30 queries × 10 web docs × 2 people) achieving 93% raw inter-rater agreement.
- This filtering step is critical — it prevents noise from degrading summary quality while preserving novel, relevant perspectives.
4. Corpus Merging
- Designed a flexible merger that combines the TF-IDF offline documents with relevance-flagged web documents into a unified corpus for each query.
- The merger supports configurable weighting and can be easily extended to incorporate additional document sources.
- This modular design enables future experimentation with different retrieval strategies (e.g., BM25, GritLM) without rewriting downstream components.
5. Structured Multi-Perspective Summarization
- To enforce strict JSON schema compliance, built a constrained generation pipeline using Llama-3.2-3B-Instruct with the Outlines library.
- The model outputs exactly 2 opposing claims, each with a list of supporting perspectives and associated evidence document IDs.
- Implemented a retry system with up to 10 regeneration attempts (early exiting after 5 parsing failures) and temperature=0.1 for deterministic, reproducible outputs.
- The prompt was iteratively refined to balance perspective diversity, factual grounding, and coverage while avoiding penalization of web-derived perspectives that diverge from static gold summaries.
Results
Web-augmented summaries consistently outperformed offline baselines across all k configurations:
| k = | Merged | Offline |
|---|---|---|
| 5 | 8.15/10 | 7.70/10 |
| 10 | 7.94/10 | 7.77/10 |
| 20 | 7.95/10 | 7.80/10 |
Web relevance rates were impressive at lower k values (94-96% at k=5 and k=10) but dropped to 73.8% at k=20, revealing diminishing returns from excessive document retrieval. Notably, 44% of high-context experiments failed due to context window limits (1,500 token generation budget), highlighting the practical trade-off between information richness and model capacity—a finding that aligns with recent "Lost in the Middle" research on LLM context utilization.
Evaluation was comprehensive, using LLM-as-Judge scoring across five dimensions (claim relevance, perspective-claim alignment, perspective distinctness, coverage of core arguments, and factual grounding), each rated 0-2 for a total out of 10. All metrics were calculated with bootstrapped 95% confidence intervals for statistical rigor.