How citadel-ai/langcheck works
This project is an open‐source Python library called LangCheck that provides a suite of evaluation metrics, data augmentation, and visualization tools specifically designed for assessing LLM (large language model) outputs. It’s built in a modular fashion so that users can easily plug in various types of language metrics (reference-free, reference-based, source-based, query-based, text structure, and pairwise comparisons) as well as leverage data augmentations and interactive plots.
Main Components
• Core Library (src/langcheck): Represent the core business logic. This includes several submodules:
• Augment Module: Handles text transformations such as rephrasing, gender shifts, keyboard typos, punctuation removal, etc. Note the language-specific subdirectories (e.g., “src/langcheck/augment/en” and “src/langcheck/augment/ja”), which indicate modular support for multiple languages.
• Metrics Module: Contains various evaluation strategies and quality metrics. There are multiple language-specific folders (e.g., “en”, “de”, “ja”, “zh”) and different metric types (e.g., reference-based, reference-free, query-based, source-based, pairwise). Also include the “model_manager” submodule for handling language model configurations and loaders.
• Plotting Module: Provides interactive visualization tools for displaying metric distributions – illustrated by “src/langcheck/plot” (scatter plots, histograms, etc.).
• Utilities: Includes helper functions like logging (“_handle_logs.py”), I/O operations, and progress bars (“src/langcheck/utils”).
• Metrics Scorer and Prompts: Show that there is a component (within “src/langcheck/metrics/prompts”) for templating and dynamically generating evaluation prompts, including jailbreak templates.
• External Interfaces:
• Augmented Data Flow: Display how the augmentation module affects input data prior to metric evaluation.
• CI/CD and Configuration:
• CI/CD Pipelines: Represent GitHub Actions workflows (depicted in the “.github/workflows” folder) that handle formatting, installation, and testing (pytest) to emphasize continuous integration.
• Development Environment: Note the existence of configuration files like “pyproject.toml”, Docker’s devcontainer files, and the VSCode settings, all ensuring a consistent development and deployment environment.
• Testing and Documentation:
• Testing Module: Group the “tests” directory to show unit tests for various components (augmentations, different metric types, model management, etc.). This reinforces the project’s commitment to robust evaluation.
• Documentation: Include a block for documentation (“docs”), which details installation, quickstarts, and tutorials. This is essential for understanding the usage and integration of the system.
Relationships and Data Flow
• Follow the flow from metrics results to the Plotting module for visualization.
• That the Testing suite runs alongside these modules and that CI/CD pipelines automatically execute tests and formatting routines.
Architectural Patterns and Design Principles
• Modularity: Emphasize the separation into clear submodules (metrics, augmentation, plotting, utils) which follow a clear single-responsibility design.
• Language-specific Extensibility: Note how there’s a pattern of language-specific folders that allow for extensions (e.g., “en”, “ja”, “de”, “zh”), which can be visually grouped.
• Reusability: The project is designed as a Python package, so separate concerns such as data transformation, metric computation, and visualization are independently callable.