LinguaLens (LSADA)
LinguaLens (formerly LSADA - Language Services and Data Analysis) is a flexible Python framework for evaluating content quality using Large Language Models (LLMs).
It provides a structured way to:
- Define evaluation tasks with specific metrics and weighting.
- Use different LLM providers (currently OpenAI, Cloudverse supported).
- Generate prompts tailored to your evaluation criteria.
- Parse LLM responses to extract scores and justifications.
- Aggregate results from multiple evaluations for robustness.
Installation
You can install LinguaLens directly from PyPI:
pip install python-lingualens
Quick Start Example
-
Set your LLM API Key: Make sure you have your API key (e.g., for OpenAI) set as an environment variable:
export OPENAI_API_KEY="your_api_key_here" # On Windows (Command Prompt) # set OPENAI_API_KEY=your_api_key_here # On Windows (PowerShell) # $env:OPENAI_API_KEY="your_api_key_here"
-
Run the basic usage script: Navigate to the
examplesdirectory and run the script:cd examples python 1_basic_usage.py
This script demonstrates:
- Initializing an OpenAI client.
- Initializing the
Evaluatorfor a specific task (conversation_evaluation). - Evaluating sample content.
- Printing the detailed results, including the overall score, individual metric scores, and justifications.
# examples/1_basic_usage.py (Simplified Snippet) import os import logging from lingualens import Evaluator, LLMManager logging.basicConfig(level=logging.INFO) api_key = os.getenv("OPENAI_API_KEY") task_type = "conversation_evaluation" content_to_evaluate = "... (your content here) ..." if not api_key: logging.error("OPENAI_API_KEY not set.") else: try: llm_client = LLMManager.initialize_client(vendor="openai", api_key=api_key) evaluator = Evaluator(task_type=task_type, include_justification=True) result = evaluator.evaluate(content=content_to_evaluate, llm_client=llm_client) print("\n----- Evaluation Results -----") print(f"Task Type: {result.get('metadata', {}).get('task_type')}") print(f"Total Weighted Score: {result.get('total_weighted_score')}") # ... (print detailed scores and justifications) ... except Exception as e: logging.error(f"An error occurred: {e}", exc_info=True)
Core Components
Evaluator: The main class to orchestrate the evaluation.LLMManager: Manages and initializes clients for different LLM vendors.TaskManager: Handles task definitions, metrics, and can auto-identify tasks.PromptGenerator: Creates detailed prompts for the LLM based on configuration.LLMResponseParser: Extracts structured data from LLM responses.MetricsCalculator: Aggregates scores and performs calculations.ConfigManager: Loads configurations from pool
Metadata
Release files for python-lingualens 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| python_lingualens-1.0.2.tar.gz | 23.0 kB | Without provenance | Details for python_lingualens-1.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| python_lingualens-1.0.2-py3-none-any.whl | Python 3 | none | any | Details for python_lingualens-1.0.2-py3-none-any.whl |
Total release size: 48.0 kB
Release files / python_lingualens-1.0.2.tar.gz
| Download URL | python_lingualens-1.0.2.tar.gz |
|---|---|
| Size | 23.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8d6f74923ff3417d831973892c5a7e73a66cd4eb758aefed5db2b8846c07c986
|
|
BLAKE2b-256 checksum How to use checksums |
1dcf48db0cac13df3a5241092412af7f8dabd51099e4607fbe32e4b1e90cf828
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.12
|
Release files / python_lingualens-1.0.2-py3-none-any.whl
| Download URL | python_lingualens-1.0.2-py3-none-any.whl |
|---|---|
| Size | 25.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
228c3910f0fe5321d2c1b420d7d0ed572132f6afe1cf996166a13b588b049b6d
|
|
BLAKE2b-256 checksum How to use checksums |
7df21f4788d4f5839bc7ce7f9c302e17f48ea1a77bcda14cdd06c3ff525f81d5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.12
|
Security for python-lingualens 1.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.