A comprehensive benchmarking pipeline for evaluating and comparing Large Language Model (LLM) performance on text summarization tasks across multiple providers and prompt styles.
Abstractor.ai provides a systematic way to test and compare different LLM models from OpenAI, Anthropic, and Google on their summarization capabilities. The pipeline measures three key dimensions:
- Speed: Response time for each API call
- Cost: Token usage and financial cost per request
- Quality: Semantic similarity between generated and reference summaries
This tool is useful for:
- Selecting the best LLM for your summarization use cases
- Understanding cost-performance trade-offs
- Evaluating quality across different prompt styles
- Benchmarking new models as they become available
- OpenAI: GPT-4o, GPT-4o mini, GPT-4 Turbo, GPT-3.5 Turbo
- Anthropic: Claude 3.5 Sonnet, Claude 3.5 Haiku, Claude 3 Opus
- Google: Gemini 2.0 Flash, Gemini 2.5 Flash, Gemini 2.5 Pro
- Concise: 2-3 sentence summaries
- Detailed: Comprehensive summaries with all important points
- Bullet Points: Organized key takeaways in list format
- Executive: Decision-focused summaries with actionable insights
- Response time tracking
- Token usage (input/output)
- Cost calculation based on current pricing
- Semantic similarity scoring against reference summaries
- Performance comparisons across models and prompt types
- Visualization dashboards showing performance comparisons
- Response time analysis by model and prompt type
- Cost-quality trade-off analysis
- Downloadable CSV and JSON reports with full results
- Python 3.8+
- API keys for the LLM providers you want to use
- Clone the repository:
git clone https://github.com/yourusername/abstractor.ai.git
cd abstractor.ai- Create a virtual environment:
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Configure API keys:
cp .env.example .envEdit .env and add your API keys:
OPENAI_API_KEY=sk-...
ANTHROPIC_API_KEY=sk-ant-...
GOOGLE_API_KEY=...
Place text files to summarize in data/texts/:
data/texts/
├── article1.txt
├── article2.txt
└── article3.txt
Optionally add reference summaries in data/references/ (for quality evaluation):
data/references/
├── article1.txt
├── article2.txt
└── article3.txt
Open llm_summarization_benchmark.ipynb and customize:
- Models to test: Comment/uncomment model selections
- Configuration: Adjust
max_tokens,temperature, and output paths - Rate limiting: Set
delay_between_requeststo avoid API rate limits
Example configuration:
MODELS_TO_TEST = {
"openai": ["gpt-4o-mini"],
"anthropic": ["claude-3-5-haiku-20241022"],
"google": ["gemini-2.5-flash"]
}Open and run the Jupyter notebook:
jupyter notebook llm_summarization_benchmark.ipynbThe notebook will:
- Load your text files
- Generate summaries using each model with different prompts
- Evaluate quality against references (if available)
- Generate visualizations and reports
Results are saved to results/ directory:
benchmark_results_*.csv: Raw data for all API callsbenchmark_report_*.png: Performance visualization dashboardfull_report_*.json: Complete analysis including model and prompt breakdowns
abstractor.ai/
├── llm_summarization_benchmark.ipynb # Main benchmark pipeline
├── requirements.txt # Python dependencies
├── .env.example # Example environment variables
├── data/
│ ├── texts/ # Input text files to summarize
│ └── references/ # Reference summaries for evaluation
└── results/ # Generated reports and visualizations
Total seconds taken for an API call to complete. Lower is faster.
Calculated based on token usage and current pricing per 1M tokens. Use this to understand API expenses.
Semantic similarity between the generated summary and reference summary (0.0 to 1.0). Higher indicates better quality alignment with expected output.
Input tokens consumed by the prompt + text, and output tokens generated. Affects both speed and cost.
Prices are based on current rates (as of late 2024) but may change. Check individual provider documentation for the latest:
- OpenAI: GPT-4o ($2.50/$10 per 1M), GPT-4o mini ($0.15/$0.60 per 1M)
- Anthropic: Claude 3.5 Sonnet ($3/$15 per 1M), Claude 3.5 Haiku ($0.80/$4 per 1M)
- Google: Gemini Flash ($0.10/$0.40 per 1M), Gemini Pro ($1.25/$5 per 1M)
Update pricing in the notebook's PRICING dictionary to keep costs accurate.
- Use
delay_between_requestsparameter to add delays between API calls - Start with fewer models and build up
- Consider testing during off-peak hours
- Test with cheaper models first (mini/Flash variants)
- Shorter maximum token limits reduce output costs
- Batch similar tests together
- Provide reference summaries for meaningful quality scoring
- Test multiple prompt styles to find the best one for your use case
- Use diverse text samples for comprehensive benchmarking
- Save your benchmark configurations in git
- Document any custom changes to prompts or settings
- Keep results from different runs for trend analysis
- Ensure
.envfile exists with correct API keys - Verify environment variables are loaded (check output at startup)
- Try restarting the notebook kernel
- Increase
delay_between_requestsparameter - Reduce number of models tested at once
- Spread benchmarks across multiple time periods
- Ensure reference summaries are in
data/references/ - Verify filenames match between texts and references exactly
- Check that
similarity_modelloads correctly (requires internet for first download)
- Google's safety filters may block some content types
- This is reflected in the error logs for those specific requests
- Filter out blocked responses from final analysis
See requirements.txt for full dependency list:
- LLM API clients (openai, anthropic, google-generativeai)
- Data processing (pandas, numpy)
- ML/evaluation (scikit-learn, sentence-transformers)
- Visualization (matplotlib, seaborn)
- Utilities (python-dotenv)
- Jupyter environment
MIT License - feel free to use and modify for your benchmarking needs.
Contributions welcome! Areas for enhancement:
- Support for additional LLM providers
- Custom evaluation metrics
- Real-time result streaming
- Web dashboard for results visualization
- Scheduling and automated recurring benchmarks
- Multi-language support
- Streaming response support
- Real-time cost tracking dashboard
- Automated model comparison reports
- Integration with LLM leaderboards