How alirezasalemi7/expert works
Project Type and Purpose
• ExPerT is a Python library (an open-source evaluation tool) for explainable, reference-based scoring of personalized long-form text generated by large language models (LLMs). It provides a pipeline that:
a. Extracts atomic aspects from generated and reference texts
b. Matches and aligns those aspects
c. Produces alignment scores and human-readable explanations via an LLM backbone
High-Level Architecture
• This is a library/API-driven system, not a web application. The core runtime is a single Python process that orchestrates calls to an external LLM service.
• Main components:
• Client code (user script or notebook)
• ExPerT orchestrator (expert_score.expert)
• Submodules:
– Aspect Extraction (aspects/extraction.py)
– Aspect Matching (matching/match.py, matching/utils.py)
– Utilities (utils/api_llm.py, utils/json_parsing.py)
• External LLM Service (OpenAI, Google, or Hugging Face model)
• Local Cache Directory
Data Flow and Component Interaction
1. Client invokes expert(inputs, outputs, references, …).
2. The orchestrator prepares prompts and calls utils/api_llm to dispatch to the chosen LLM.
3. LLM responses are parsed by utils/json_parsing.
4. Parsed output feeds into:
a. Aspect Extraction module → yields atomic aspects + evidences
b. Aspect Matching module → aligns aspects between generated vs. reference
5. Scoring logic in expert.py aggregates content/style alignment scores.
6. Explanations are assembled (detailed step-by-step).
7. Final score + explanations return to client.
8. Cache module (in api_llm) handles prompt/result caching and retry logic.
Architectural Patterns and Design Principles
• Pipeline pattern: sequential stages (extract → match → score → explain).
• Separation of concerns:
• aspects/ handles extraction logic
• matching/ handles alignment logic
• utils/ abstracts LLM API and parsing
• Extensibility points:
• Swap or configure LLM backend (OpenAI, Google, Hugging Face)
• Tweak extraction or matching strategies by subclassing modules
Elements
• Clear component labels: “Client Script,” “ExPerT Orchestrator,” “Aspect Extraction,” etc.
• Arrowheads showing flow order: client → orchestrator → LLM → parsing → extraction → matching → scoring → client.