Skip to content

Commit e6466bc

Browse files
committed
update from suggestions
1 parent 25af204 commit e6466bc

14 files changed

Lines changed: 191 additions & 285 deletions

docs/source/adding-a-custom-task.mdx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ dataset to a document to be used for evaluation.
4343
from lighteval.tasks.requests import Doc
4444

4545
# Define as many as you need for your different tasks
46-
def prompt_fn(line, task_name: str = None):
46+
def prompt_fn(line: dict, task_name: str):
4747
"""Defines how to go from a dataset line to a doc object.
4848
Follow examples in src/lighteval/tasks/default_prompts.py, or get more info
4949
about what this function should do in the README.
@@ -99,7 +99,7 @@ task = LightevalTaskConfig(
9999
name="myothertask",
100100
prompt_function=prompt_fn, # Must be defined in the file or imported
101101
suite=["community"],
102-
hf_repo="your_dataset_name",
102+
hf_repo="your_dataset_repo_on_hf",
103103
hf_subset="default",
104104
hf_avail_splits=["train", "test"],
105105
evaluation_splits=["test"],
@@ -157,6 +157,11 @@ TASKS_TABLE = SUBSET_TASKS
157157
# TASKS_TABLE = [task]
158158
```
159159

160+
### Step 6: Creating a requirement file
161+
162+
If your task has requirements, you need to create a `requirement.txt` file with
163+
only the required dependencies so that anyone can run your task.
164+
160165
## Running Your Custom Task
161166

162167
Once your file is created, you can run the evaluation with the following command:

docs/source/adding-a-new-metric.mdx

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,25 @@
11
# Adding a New Metric
22

3-
Lighteval provides a flexible system for creating custom metrics to evaluate model performance. This guide explains how to create and integrate new metrics into the evaluation framework.
4-
53
## Before You Start
64

5+
### Two different types of metrics
6+
7+
There are two types of metrics in Lighteval:
8+
9+
#### Sample-Level Metrics
10+
- **Purpose**: Evaluate individual samples/predictions
11+
- **Input**: Takes a `Doc` (document/sample) and `ModelResponse` (model's prediction)
12+
- **Output**: Returns a float or boolean value for that specific sample
13+
- **Example**: Checking if a model's answer matches the correct answer for one question
14+
15+
#### Corpus-Level Metrics
16+
- **Purpose**: Compute final scores across the entire dataset/corpus
17+
- **Input**: Takes the results from all sample-level evaluations
18+
- **Output**: Returns a single score representing overall performance
19+
- **Examples**:
20+
- Simple aggregation: Calculating average accuracy across all test samples
21+
- Complex metrics: BLEU score where sample-level metric prepares data (tokenization, etc.) and corpus-level metric computes the actual BLEU score
22+
723
### Check Existing Metrics
824

925
First, check if you can use one of the parameterized functions in

docs/source/available-tasks.mdx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# Available Tasks
22

3-
Lighteval provides a comprehensive collection of evaluation tasks covering various aspects of language model capabilities. You can explore and use these tasks to evaluate your models across different domains and skills.
4-
53
## Discovering Available Tasks
64

75
### List All Tasks

docs/source/contributing-to-multilingual-evaluations.mdx

Lines changed: 53 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Contributing to Multilingual Evaluations
22

3-
Lighteval supports multilingual evaluations through a comprehensive system of translation literals and language-adapted templates. This guide explains how to contribute translations and create new multilingual tasks.
3+
Lighteval supports multilingual evaluations through a comprehensive system of translation literals and language-adapted templates.
44

55
## Contributing Translation Literals
66

@@ -53,14 +53,6 @@ Language.ENGLISH: TranslationLiterals(
5353
)
5454
```
5555

56-
### Translation Guidelines
57-
58-
- **Accuracy**: Ensure translations are accurate and contextually appropriate
59-
- **Consistency**: Use consistent terminology across all literals
60-
- **Cultural Sensitivity**: Consider cultural differences in language usage
61-
- **Punctuation**: Only adjust punctuation if your language uses different conventions
62-
- **Indices**: Update the indices list if your language uses different alphabetical characters
63-
6456
## Contributing New Multilingual Tasks
6557

6658
### Prerequisites
@@ -81,12 +73,59 @@ For multilingual evaluations, the `prompt_function` should be implemented using
8173

8274
#### Template Types
8375
Available template types include:
84-
- **XNLI**: Natural language inference tasks
85-
- **COPA**: Causal reasoning tasks
86-
- **Multiple Choice**: Standard multiple choice questions
87-
- **Question Answering**: Open-ended question answering
76+
- **XNLI**: Natural language inference tasks - [`get_nli_prompt_function`](https://github.com/huggingface/lighteval/blob/main/src/lighteval/tasks/templates/nli.py#L162)
77+
- **COPA**: Causal reasoning tasks - [`get_copa_prompt_function`](https://github.com/huggingface/lighteval/blob/main/src/lighteval/tasks/templates/copa.py#L76)
78+
- **Multiple Choice**: Standard multiple choice questions - [`get_mcq_prompt_function`](https://github.com/huggingface/lighteval/blob/main/src/lighteval/tasks/templates/multichoice.py#L81)
79+
- **Question Answering**: Open-ended question answering - [`get_qa_prompt_function`](https://github.com/huggingface/lighteval/blob/main/src/lighteval/tasks/templates/qa.py#L46)
8880
- **Custom**: Specialized task templates
8981

82+
#### Formulation Types
83+
84+
##### Multiple Choice Formulation (MCF)
85+
Used for standard multiple choice questions where the model selects from lettered options:
86+
```python
87+
MCFFormulation()
88+
```
89+
90+
**Example output:**
91+
```
92+
Question: What is the capital of France?
93+
A. London
94+
B. Paris
95+
C. Berlin
96+
D. Rome
97+
Answer: | A/B/C/D
98+
```
99+
100+
##### Classification Formulation (CF)
101+
Used for classification tasks where the model generates the answer directly:
102+
```python
103+
CFFormulation()
104+
```
105+
106+
**Example output:**
107+
```
108+
Question: What is the capital of France?
109+
Answer: | Paris
110+
```
111+
112+
##### Hybrid Formulation
113+
Used for tasks that present choices but expect the full answer text:
114+
```python
115+
HybridFormulation()
116+
```
117+
118+
**Example output:**
119+
```
120+
Question: What is the capital of France?
121+
A. London
122+
B. Paris
123+
C. Berlin
124+
D. Rome
125+
Answer: | Paris
126+
```
127+
128+
90129
### Creating Your Multilingual Task
91130

92131
#### Step 1: Create the Task File
@@ -158,102 +197,15 @@ Follow the custom task guide to test if your task is correctly implemented.
158197
> [!TIP]
159198
> All [`~tasks.lighteval_task.LightevalTaskConfig`] parameters are strongly typed, including the inputs to the template function. Make sure to take advantage of your IDE's functionality to make it easier to correctly fill these parameters.
160199
161-
### Formulation Types
162-
163-
#### Multiple Choice Formulation (MCF)
164-
Used for standard multiple choice questions:
165-
```python
166-
MCFFormulation()
167-
```
168-
169-
#### Classification Formulation (CF)
170-
Used for classification tasks:
171-
```python
172-
CFFormulation()
173-
```
174-
175-
#### Hybrid Formulation
176-
Used for tasks that combine multiple approaches:
177-
```python
178-
HybridFormulation()
179-
```
180-
181-
### Language Support
182-
183-
Currently supported languages include:
184-
- **English** (ENGLISH)
185-
- **Spanish** (SPANISH)
186-
- **French** (FRENCH)
187-
- **German** (GERMAN)
188-
- **Italian** (ITALIAN)
189-
- **Portuguese** (PORTUGUESE)
190-
- **Russian** (RUSSIAN)
191-
- **Chinese** (CHINESE)
192-
- **Japanese** (JAPANESE)
193-
- **Korean** (KOREAN)
194-
- **Arabic** (ARABIC)
195-
- **Hindi** (HINDI)
196-
- **Turkish** (TURKISH)
197-
- **Dutch** (DUTCH)
198-
- **Polish** (POLISH)
199-
- **Swedish** (SWEDISH)
200-
- **Norwegian** (NORWEGIAN)
201-
- **Danish** (DANISH)
202-
- **Finnish** (FINNISH)
203-
204-
### Best Practices
205-
206-
#### Translation Literals
207-
- **Test your translations** with native speakers
208-
- **Consider regional variations** in language usage
209-
- **Maintain consistency** with existing translations
210-
- **Document any special considerations** in your PR
211-
212-
#### Multilingual Tasks
213-
- **Choose appropriate templates** for your task type
214-
- **Test across multiple languages** to ensure consistency
215-
- **Consider cultural differences** in task interpretation
216-
- **Validate dataset quality** for each language
217-
- **Use appropriate metrics** for your task formulation
218-
219-
#### Code Quality
220-
- **Follow existing code style** and conventions
221-
- **Add comprehensive documentation** for your task
222-
- **Include example usage** in your PR description
223-
- **Test thoroughly** before submitting
224-
225-
### Testing Your Contribution
226-
227-
#### Local Testing
228-
```bash
229-
# Test your task locally
230-
lighteval accelerate \
231-
"model_name=openai-community/gpt2" \
232-
"community|your_task_name|0|0" \
233-
--max-samples 10
234-
```
235-
236-
#### Validation Checklist
200+
### Validation Checklist
237201
- [ ] Translation literals are accurate and complete
238202
- [ ] Task works correctly across all target languages
239203
- [ ] Metrics are appropriate for the task type
240204
- [ ] Documentation is clear and comprehensive
241205
- [ ] Code follows project conventions
242206

243-
### Submitting Your Contribution
244-
245-
1. **Create a feature branch** for your changes
246-
2. **Add comprehensive tests** for your task
247-
3. **Update documentation** as needed
248-
4. **Open a pull request** with a clear description
249-
5. **Respond to review feedback** promptly
250-
251-
Once everything is good, open a PR, and we'll be happy to review it!
252-
253207
### Getting Help
254208

255209
- **GitHub Issues**: Report bugs or ask questions
256210
- **Discussions**: Join community discussions
257211
- **Documentation**: Review existing guides and examples
258-
259-
For more detailed information about multilingual evaluations, see the [Multilingual Tasks Reference](package_reference/tasks).

docs/source/index.mdx

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,36 @@
11
# Lighteval
22

3-
🤗 Lighteval is your all-in-one toolkit for evaluating Large Language Models (LLMs) across multiple backends—whether it's
4-
[Transformers](https://github.com/huggingface/transformers),
5-
[Text Generation Inference (TGI)](https://github.com/huggingface/text-generation-inference),
6-
[Inference Providers](https://huggingface.co/docs/huggingface_hub/en/guides/inference),
7-
[VLLM](https://github.com/vllm-project/vllm), or
8-
[Nanotron](https://github.com/huggingface/nanotron)—with
9-
ease. Dive deep into your model's performance by saving and exploring detailed,
10-
sample-by-sample results to debug and see how your models stack up.
3+
🤗 Lighteval is your all-in-one toolkit for evaluating Large Language Models
4+
(LLMs) across multiple backends with ease. Dive deep into your model's
5+
performance by saving and exploring detailed, sample-by-sample results to debug
6+
and see how your models stack up.
117

128
## Key Features
139

1410
### 🚀 **Multi-Backend Support**
1511
Evaluate your models using the most popular and efficient inference backends:
16-
- **Transformers**: Standard Hugging Face models with full customization
17-
- **VLLM**: High-performance inference with optimized memory usage
18-
- **SGLang**: Fast and efficient model serving
19-
- **TGI**: Production-ready text generation inference
20-
- **Inference Endpoints**: Cloud-based model deployment
21-
- **LiteLLM**: Unified interface for multiple LLM providers
22-
- **Nanotron**: Distributed training and evaluation
12+
- `transformers`: Evaluate models on CPU or one or more GPUs using [🤗
13+
Accelerate](https://github.com/huggingface/transformers)
14+
- `nanotron`: Evaluate models in distributed settings using [⚡️
15+
Nanotron](https://github.com/huggingface/nanotron)
16+
- `vllm`: Evaluate models on one or more GPUs using [🚀
17+
VLLM](https://github.com/vllm-project/vllm)
18+
- `custom`: Evaluate custom models (can be anything)
19+
- `sglang`: Evaluate models using [SGLang](https://github.com/sgl-project/sglang) as backend
20+
- `inference-endpoint`: Evaluate models using Hugging Face's [Inference Endpoints API](https://huggingface.co/inference-endpoints/dedicated)
21+
- `tgi`: Evaluate models using [🔗 Text Generation Inference](https://huggingface.co/docs/text-generation-inference/en/index) running locally
22+
- `litellm`: Evaluate models on any compatible API using [LiteLLM](https://www.litellm.ai/)
23+
- `inference-providers`: Evaluate models using [HuggingFace's inference providers](https://huggingface.co/docs/inference-providers/en/index) as backend**: Distributed training and evaluation
2324

2425
### 📊 **Comprehensive Evaluation**
25-
- **Extensive Task Library**: 100+ pre-built evaluation tasks
26+
- **Extensive Task Library**: 1000s pre-built evaluation tasks
2627
- **Custom Task Creation**: Build your own evaluation tasks
2728
- **Flexible Metrics**: Support for custom metrics and scoring
2829
- **Detailed Analysis**: Sample-by-sample results for deep insights
2930

3031
### 🔧 **Easy Customization**
31-
Customization at your fingertips: create [new tasks](adding-a-custom-task) and
32-
[metrics](adding-a-new-metric) tailored to your needs, or browse all our existing tasks and metrics.
32+
Customization at your fingertips: create [new tasks](adding-a-custom-task),
33+
[metrics](adding-a-new-metric) or [model](evaluating-a-custom-model) tailored to your needs, or browse all our existing tasks and metrics.
3334

3435
### ☁️ **Seamless Integration**
3536
Seamlessly experiment, benchmark, and store your results on the Hugging Face Hub, S3, or locally.
@@ -49,11 +50,6 @@ pip install lighteval
4950
lighteval accelerate \
5051
"model_name=openai-community/gpt2" \
5152
"leaderboard|truthfulqa:mc|0|0"
52-
53-
# Evaluate using VLLM for better performance
54-
lighteval vllm \
55-
"model_name=HuggingFaceH4/zephyr-7b-beta,dtype=float16" \
56-
"leaderboard|gsm8k|3|1"
5753
```
5854

5955
### Save Results

docs/source/use-inference-providers-as-backend.mdx

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -47,29 +47,6 @@ Optionally, you can charge them to an organization by setting `org_to_bill="<you
4747
Hugging Face Inference Providers supports a wide range of LLM providers see the [Inference Providers documentation](https://huggingface.co/docs/inference-providers/en/index) for the complete list.
4848

4949

50-
## Key Parameters
51-
52-
### Provider Configuration
53-
- `model_name`: The Hugging Face model ID to use
54-
- `provider`: The inference provider (together, fireworks, novita, etc.)
55-
- `timeout`: Request timeout in seconds (null for default)
56-
- `proxies`: Proxy configuration (null for default)
57-
- `parallel_calls_count`: Number of parallel API calls (default: 10)
58-
- `org_to_bill`: Organization name for billing (optional)
59-
60-
### Generation Parameters
61-
- `temperature`: Controls randomness in generation (0.0 = deterministic, 1.0 = random)
62-
- `max_new_tokens`: Maximum number of tokens to generate
63-
- `top_k`: Top-k sampling parameter
64-
- `top_p`: Nucleus sampling parameter
65-
- `repetition_penalty`: Penalty for repeating tokens
66-
- `stop_tokens`: List of tokens that stop generation
67-
68-
### Advanced Configuration
69-
- `trust_remote_code`: Whether to trust remote code from the model
70-
- `use_auth_token`: Custom authentication token
71-
- `device_map`: Device mapping for model loading
72-
7350
## Billing and Costs
7451

7552
### Personal Account Billing

docs/source/use-litellm-as-backend.mdx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,8 @@ model_parameters:
4242
LiteLLM supports a wide range of LLM providers:
4343
4444
### Cloud Providers
45-
- **OpenAI**: GPT models (GPT-3.5, GPT-4, etc.)
46-
- **Azure OpenAI**: Azure-hosted OpenAI models
47-
- **Google Vertex AI**: PaLM, Gemini models
48-
- **AWS Bedrock**: Claude, Llama, and other models
49-
- **Anthropic**: Claude models
50-
- **Together AI**: Various open-source models
45+
46+
all cloud providers can be found in the [litellm documentation](https://docs.litellm.ai/docs/providers).
5147
5248
### Local/On-Premise
5349
- **VLLM**: Local VLLM servers

src/lighteval/logging/evaluation_tracker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ class EvaluationTracker:
9494
9595
The EvaluationTracker coordinates multiple specialized loggers to track different aspects of model evaluation:
9696
97-
- Details Logger (DetailsLogger): Records per-instance evaluation details and predictions
97+
- Details Logger (DetailsLogger): Records per-sample evaluation details and predictions
9898
- Metrics Logger (MetricsLogger): Tracks aggregate evaluation metrics and scores
9999
- Versions Logger (VersionsLogger): Records task and dataset versions
100100
- General Config Logger (GeneralConfigLogger): Stores overall evaluation configuration

0 commit comments

Comments
 (0)