This project evaluates an LLM's ability to categorize customer service calls for a water utility company based on the customer's input text, using a robust multi-strategy approach.
The project includes two main evaluation approaches:
- Reads customer call data from a JSON file
- Sends each customer input to Anthropic's Claude model for classification
- Compares the LLM's prediction with the actual category
- Generates basic evaluation metrics
The robust evaluation system uses multiple strategies to improve classification reliability:
- Primary Parser: Direct command with format expectations
- Backup Parser: Chain of thought approach for more complex reasoning
- Negative Checker: Determines if text contains enough information to categorize
- Schema Validator: Checks if output matches expected schema
Results from these strategies are combined to produce:
- Final classification with confidence levels (high, medium, low)
- Flags for calls that need human review
- Comprehensive evaluation metrics
The system evaluates classification into these categories:
- RESTORE
- ABATEMENT
- AMR (METERING)
- BILLING
- BPCS (BROKEN PIPE)
- BTR/O (BAD TASTE & ODOR)
- C/I - DEP (CAVE IN/DEPRESSION)
- CEMENT
- CHOKED DRAIN
- CLAIMS
- COMPOST
-
Install the required dependencies:
pip install -r requirements.txt -
Create a
.envfile with your Anthropic API key:ANTHROPIC_API_KEY=your_api_key_here
python evaluate.py --input customer-calls.json --output evaluation_results.json
python run_robust_evaluation.py --input customer-calls.json --output robust_evaluation_results.json --model claude-3-7-sonnet-20250219
--input: Path to the customer calls JSON file (default: "customer-calls.json")--output: Path to save evaluation results (default: "evaluation_results.json" or "robust_evaluation_results.json")--limit: Limit the number of calls to process (optional, for testing)--model: Model to use for classification (default: "claude-3-7-sonnet-20250219")
The robust evaluation generates comprehensive metrics including:
- Overall accuracy
- Per-category performance (precision, recall, F1 score)
- Confidence-level metrics (accuracy by confidence level)
- Statistics on calls flagged for human review