CoolFace
Apppublic

Ahmed-El-Zainy/eval_sales_korean_agent

sourceHugging Faceupdated 1y agoView on Hugging Face
1likes
App README

Korean Q&A Evaluation System

A comprehensive evaluation framework for Korean language Q&A systems using DeepEval, designed to assess answer relevancy and quality for business intelligence queries.

Overview

This project evaluates Korean language question-answering systems using Google's Gemini model through the DeepEval framework. It focuses on business-related queries covering financial metrics, production data, and operational insights.

Features

๐Ÿ” Evaluation Capabilities

  • โ€”Answer Relevancy Evaluation: Measures how well answers address the input questions
  • โ€”Korean Language Support: Specialized for Korean business terminology and context
  • โ€”Comprehensive Metrics: Detailed scoring with verbose logging and explanations
  • โ€”CSV Dataset Integration: Easy data loading from structured CSV files
  • โ€”Gemini Model Integration: Leverages Google's latest Gemini 2.0 Flash model

๐ŸŒ Interactive Demos

  • โ€”Gradio Interface: User-friendly web interface with real-time evaluation
  • โ€”Streamlit Dashboard: Professional analytics dashboard with advanced visualizations
  • โ€”Single Question Evaluation: Test individual Q&A pairs instantly
  • โ€”Batch Dataset Processing: Evaluate entire datasets with progress tracking
  • โ€”Public Sharing: Generate shareable links for collaborative evaluation

๐Ÿ“Š Advanced Visualizations

  • โ€”Score Distribution Histograms: Understand score patterns across your dataset
  • โ€”Pass/Fail Analytics: Visual breakdown of success rates
  • โ€”Metrics Comparison Charts: Compare different evaluation metrics
  • โ€”Text Length Analysis: Correlation between answer length and scores
  • โ€”Interactive Tables: Sortable, filterable results with detailed breakdowns
  • โ€”Export Capabilities: Download results in JSON format for further analysis

Project Structure

โ”œโ”€โ”€ src/                    # Source code modules
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”œโ”€โ”€ config.py          # Configuration management
โ”‚   โ”œโ”€โ”€ logger.py          # Logging setup and utilities
โ”‚   โ”œโ”€โ”€ dataset_loader.py  # Dataset loading and processing
โ”‚   โ”œโ”€โ”€ evaluator.py       # Main evaluation engine
โ”‚   โ””โ”€โ”€ utils.py           # Utility functions
โ”œโ”€โ”€ assets/
โ”‚   โ””โ”€โ”€ bench_korean.csv   # Korean Q&A benchmark dataset
โ”œโ”€โ”€ logs/                  # Log files (auto-created)
โ”œโ”€โ”€ results/               # Evaluation results (auto-created)
โ”œโ”€โ”€ main.py               # Main entry point
โ”œโ”€โ”€ run_evaluation.py     # Simple runner script
โ”œโ”€โ”€ deep_eval.py          # Legacy script (deprecated)
โ”œโ”€โ”€ config.yaml           # Configuration file
โ”œโ”€โ”€ .env                  # Environment variables
โ”œโ”€โ”€ requirements.txt      # Python dependencies
โ””โ”€โ”€ README.md            # Project documentation

Dataset

The benchmark dataset (assets/bench_korean.csv) contains Korean business Q&A pairs covering:

  • โ€”Financial Metrics: Revenue, profit margins, cost analysis
  • โ€”Production Data: Manufacturing yields, process efficiency
  • โ€”Operational Insights: Inventory status, departmental performance
  • โ€”Quality Control: Failure costs, process optimization

Sample questions include:

  • โ€”"์ด๋ฒˆ ๋‹ฌ ์šฐ๋ฆฌ ํšŒ์‚ฌ ์ „์ฒด ๋งค์ถœ์€ ์–ผ๋งˆ์•ผ?" (What's our company's total revenue this month?)
  • โ€”"์‚ฌ์—…๋ถ€๋ณ„ ๋งค์ถœ ๋น„์ค‘์ด ์–ด๋–ป๊ฒŒ ๋˜๋‚˜์š”?" (What's the revenue distribution by business unit?)
  • โ€”"์ตœ๊ทผ ์ˆ˜์œจ์ด ๋‚ฎ์€ ๊ณต์ •์ด ์žˆ๋‚˜์š”?" (Are there any processes with low yields recently?)

Installation

  1. 1.Clone the repository:
bash
git clone <repository-url>
cd eval_Korean_qa
  1. 1.Install dependencies:
bash
pip install -r requirements.txt
  1. 1.Set up your Google AI API key in deep_eval.py:
python
GOOGLEAI_API_KEY = "your-api-key-here"

Usage

๐ŸŒ Live Demo Interfaces

Gradio Demo (Recommended)

Interactive web interface with real-time evaluation and visualizations:

bash
python launch_gradio.py
  • โ€”Local: http://localhost:7860
  • โ€”Public: Shareable link generated automatically
  • โ€”Features: Single evaluation, batch processing, interactive charts
Streamlit Demo

Professional dashboard interface:

bash
python launch_streamlit.py
  • โ€”Local: http://localhost:8501
  • โ€”Features: Advanced visualizations, detailed analytics, download results

๐Ÿ–ฅ๏ธ Command Line Interface

Quick Start

Run evaluation with default settings:

bash
python run_evaluation.py
Advanced Usage

Run evaluation with custom parameters:

bash
python main.py --dataset assets/bench_korean.csv --threshold 0.8 --verbose --log-level INFO
Command Line Options
bash
python main.py --help

Available options:

  • โ€”--config: Path to configuration file (default: src/config.yaml)
  • โ€”--dataset: Path to dataset CSV file (default: assets/bench_korean.csv)
  • โ€”--output: Output path for results (optional)
  • โ€”--log-level: Logging level (DEBUG, INFO, WARNING, ERROR)
  • โ€”--threshold: Evaluation threshold (default: 0.8)
  • โ€”--verbose: Enable verbose evaluation mode

๐Ÿ“Š Visualization Features

Both demo interfaces include:

  • โ€”Score Distribution Histograms: Visual distribution of evaluation scores
  • โ€”Pass/Fail Pie Charts: Success rate visualization
  • โ€”Metrics Comparison: Side-by-side metric analysis
  • โ€”Score vs Length Analysis: Correlation between text length and scores
  • โ€”Interactive Tables: Detailed results with sorting and filtering
  • โ€”Export Functionality: Download results in JSON format

๐Ÿ”ง Programmatic Usage

python
from src.config import Config
from src.dataset_loader import DatasetLoader
from src.evaluator import KoreanQAEvaluator
from src.logger import setup_logging
from src.visualization import EvaluationVisualizer

# Setup logging
logger_setup = setup_logging()

# Load configuration
config = Config("src/config.yaml")

# Load dataset
dataset_loader = DatasetLoader()
dataset = dataset_loader.load_from_csv("assets/bench_korean.csv")

# Run evaluation
evaluator = KoreanQAEvaluator(
    model_name=config.gemini_model,
    api_key=config.google_api_key
)
results = evaluator.evaluate_dataset(dataset)

# Create visualizations
visualizer = EvaluationVisualizer()
score_hist = visualizer.create_score_histogram(results)
pie_chart = visualizer.create_pass_fail_pie_chart(results)

Evaluation Metrics

Answer Relevancy

  • โ€”Threshold: 0.8 (configurable)
  • โ€”Model: Gemini 2.0 Flash
  • โ€”Scoring: 0.0 to 1.0 scale
  • โ€”Verbose Mode: Detailed statement-by-statement analysis

Results Interpretation

  • โ€”Score โ‰ฅ 0.8: Pass (relevant answer)
  • โ€”Score < 0.8: Fail (needs improvement)
  • โ€”Overall Pass Rate: Percentage of test cases meeting threshold

Configuration

Key parameters in deep_eval.py:

python
EVAL_MODEL = "gemini-2.0-flash"           # Evaluation model
threshold = 0.8                           # Pass/fail threshold
verbose_mode = True                       # Detailed logging

Sample Results

Recent evaluation achieved:

  • โ€”Overall Pass Rate: 91.67%
  • โ€”Perfect Scores: 10/12 test cases
  • โ€”Average Score: 0.94

Common failure patterns:

  • โ€”Irrelevant topic mentions in responses
  • โ€”Off-topic statements mixed with relevant content

Logging

The system provides comprehensive logging with multiple levels and outputs:

Log Files

  • โ€”logs/evaluation_YYYYMMDD.log: All evaluation logs
  • โ€”logs/errors_YYYYMMDD.log: Error logs only
  • โ€”Console output: Real-time logging during execution

Log Levels

  • โ€”DEBUG: Detailed debugging information
  • โ€”INFO: General information about execution
  • โ€”WARNING: Warning messages
  • โ€”ERROR: Error messages

Log Features

  • โ€”Automatic log rotation (10MB max file size)
  • โ€”Timestamped entries
  • โ€”Module and line number tracking
  • โ€”Separate error log files
  • โ€”Configurable log levels

Requirements

  • โ€”Python 3.7+
  • โ€”DeepEval framework
  • โ€”Google AI API access
  • โ€”Pandas for data handling
  • โ€”PyYAML for configuration
  • โ€”python-dotenv for environment variables

Contributing

  1. 1.Fork the repository
  2. 2.Create a feature branch
  3. 3.Add test cases to the CSV dataset
  4. 4.Update evaluation metrics as needed
  5. 5.Submit a pull request

License

This project is licensed under the MIT License.

Support

For questions or issues:

  • โ€”Check the DeepEval documentation
  • โ€”Review the verbose evaluation logs
  • โ€”Ensure proper API key configuration