Skip to content

Commit 8e712b1

Browse files
committed
last fixes
1 parent 88e1cb9 commit 8e712b1

8 files changed

Lines changed: 21 additions & 115 deletions

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ There are two types of metrics in Lighteval:
88

99
#### Sample-Level Metrics
1010
- **Purpose**: Evaluate individual samples/predictions
11-
- **Input**: Takes a `Doc` (document/sample) and `ModelResponse` (model's prediction)
11+
- **Input**: Takes a `Doc` and `ModelResponse` (model's prediction)
1212
- **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
13+
- **Example**: Checking if a model's answer matches the correct answer for one sample
1414

1515
#### Corpus-Level Metrics
1616
- **Purpose**: Compute final scores across the entire dataset/corpus
@@ -94,7 +94,7 @@ with [`~metrics.utils.metric_utils.SampleLevelMetric`]:
9494
my_custom_metric = SampleLevelMetric(
9595
metric_name="custom_accuracy",
9696
higher_is_better=True,
97-
category="accuracy",
97+
category=SamplingMethod.GENERATIVE,
9898
sample_level_fn=custom_metric,
9999
corpus_level_fn=agg_function,
100100
)
@@ -113,7 +113,7 @@ custom_metric = SampleLevelMetricGrouping(
113113
"response_length": False, # Shorter responses might be better
114114
"confidence": True
115115
},
116-
category="comprehensive",
116+
category=SamplingMethod.GENERATIVE,
117117
sample_level_fn=custom_metric,
118118
corpus_level_fn={
119119
"accuracy": np.mean,

docs/source/evaluating-a-custom-model.mdx

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ Create a Python file containing your custom model implementation. The model must
1313
Here's a basic example:
1414

1515
```python
16-
from typing import List
1716
from lighteval.models.abstract_model import LightevalModel
1817
from lighteval.models.model_output import ModelResponse
1918
from lighteval.tasks.requests import Doc
@@ -28,17 +27,17 @@ class MyCustomModel(LightevalModel):
2827
self._cache = SampleCache(config)
2928

3029
@cached("predictions") # Enable caching for better performance
31-
def greedy_until(self, docs: List[Doc]) -> List[ModelResponse]:
30+
def greedy_until(self, docs: list[Doc]) -> list[ModelResponse]:
3231
# Implement generation logic
3332
pass
3433

3534
@cached("predictions") # Enable caching for better performance
36-
def loglikelihood(self, docs: List[Doc]) -> List[ModelResponse]:
35+
def loglikelihood(self, docs: list[Doc]) -> list[ModelResponse]:
3736
# Implement loglikelihood computation
3837
pass
3938

4039
@cached("predictions") # Enable caching for better performance
41-
def loglikelihood_rolling(self, docs: List[Doc]) -> List[ModelResponse]:
40+
def loglikelihood_rolling(self, docs: list[Doc]) -> list[ModelResponse]:
4241
# Implement rolling loglikelihood computation
4342
pass
4443
```
@@ -113,15 +112,15 @@ Your custom model must implement these core methods:
113112
For generating text until a stop sequence or max tokens is reached. This is used for generative evaluations.
114113

115114
```python
116-
def greedy_until(self, docs: List[Doc]) -> List[ModelResponse]:
115+
def greedy_until(self, docs: list[Doc]) -> list[ModelResponse]:
117116
"""
118117
Generate text until stop sequence or max tokens.
119118
120119
Args:
121-
docs: List of documents containing prompts and generation parameters
120+
docs: list of documents containing prompts and generation parameters
122121
123122
Returns:
124-
List of model responses with generated text
123+
list of model responses with generated text
125124
"""
126125
pass
127126
```
@@ -130,15 +129,15 @@ def greedy_until(self, docs: List[Doc]) -> List[ModelResponse]:
130129
For computing log probabilities of specific continuations. This is used for multiple choice logprob evaluations.
131130

132131
```python
133-
def loglikelihood(self, docs: List[Doc]) -> List[ModelResponse]:
132+
def loglikelihood(self, docs: list[Doc]) -> list[ModelResponse]:
134133
"""
135134
Compute log probabilities of continuations.
136135
137136
Args:
138-
docs: List of documents containing context and continuation pairs
137+
docs: list of documents containing context and continuation pairs
139138
140139
Returns:
141-
List of model responses with log probabilities
140+
list of model responses with log probabilities
142141
"""
143142
pass
144143
```
@@ -147,15 +146,15 @@ def loglikelihood(self, docs: List[Doc]) -> List[ModelResponse]:
147146
For computing rolling log probabilities of sequences. This is used for perplexity metrics.
148147

149148
```python
150-
def loglikelihood_rolling(self, docs: List[Doc]) -> List[ModelResponse]:
149+
def loglikelihood_rolling(self, docs: list[Doc]) -> list[ModelResponse]:
151150
"""
152151
Compute rolling log probabilities of sequences.
153152
154153
Args:
155-
docs: List of documents containing text sequences
154+
docs: list of documents containing text sequences
156155
157156
Returns:
158-
List of model responses with rolling log probabilities
157+
list of model responses with rolling log probabilities
159158
"""
160159
pass
161160
```
@@ -184,7 +183,7 @@ def __init__(self, config):
184183
Add cache decorators to your prediction methods:
185184
```python
186185
@cached("predictions")
187-
def greedy_until(self, docs: List[Doc]) -> List[ModelResponse]:
186+
def greedy_until(self, docs: list[Doc]) -> list[ModelResponse]:
188187
# Your implementation...
189188
```
190189

docs/source/use-huggingface-inference-endpoints-or-tgi-as-backend.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,15 @@ model_parameters:
9898
```bash
9999
lighteval endpoint inference-endpoint \
100100
"configs/endpoint_model.yaml" \
101-
"lighteval|gsm8k|0|0"
101+
"lighteval|gsm8k|0"
102102
```
103103

104104
### Using an Existing TGI Server
105105

106106
```bash
107107
lighteval endpoint tgi \
108108
"configs/tgi_server.yaml" \
109-
"lighteval|gsm8k|0|0"
109+
"lighteval|gsm8k|0"
110110
```
111111

112112
### Reusing an Existing Endpoint

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

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -66,28 +66,4 @@ model_parameters:
6666
org_to_bill: "my-organization"
6767
```
6868

69-
## Troubleshooting
70-
71-
### Common Issues
72-
73-
1. **API Key Errors**: Ensure your `HF_TOKEN` is set correctly
74-
2. **Provider Not Available**: Check that the provider supports your model
75-
3. **Billing Issues**: Verify you have sufficient credits or organization permissions
76-
4. **Timeout Errors**: Increase the timeout parameter for large models
77-
78-
### Performance Tips
79-
80-
- Use appropriate `parallel_calls_count` based on your needs
81-
- Monitor your usage to avoid unexpected costs
82-
- Consider using organization billing for team projects
83-
- Use appropriate timeout values for your model size
84-
85-
### Error Handling
86-
87-
Common error messages and solutions:
88-
- **"Provider not found"**: Check the provider name is correct
89-
- **"Model not available"**: Verify the model is supported by the provider
90-
- **"Insufficient credits"**: Add credits to your account or organization
91-
- **"Timeout"**: Increase the timeout parameter or use a smaller model
92-
9369
For more detailed error handling and provider-specific information, refer to the [Hugging Face Inference Providers documentation](https://huggingface.co/docs/inference-endpoints/guides/inference_providers).

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

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -69,28 +69,4 @@ model_parameters:
6969
api_key: ""
7070
```
7171
72-
73-
## Troubleshooting
74-
75-
### Common Issues
76-
77-
1. **API Key Errors**: Ensure your API key is correct and has sufficient permissions
78-
2. **Connection Errors**: Check that the base URL is accessible and the service is running
79-
3. **Model Not Found**: Verify the model name is correct for the specified provider
80-
4. **Rate Limiting**: Implement retry logic or reduce request frequency
81-
82-
### Performance Tips
83-
84-
- Implement retry logic for transient failures
85-
- Consider using batch processing for multiple evaluations
86-
- Monitor API usage and costs for cloud providers
87-
88-
### Error Handling
89-
90-
LiteLLM provides detailed error messages for common issues:
91-
- Invalid API keys
92-
- Model not available
93-
- Rate limiting
94-
- Network connectivity issues
95-
9672
For more detailed error handling and debugging, refer to the [LiteLLM documentation](https://docs.litellm.ai/docs/).

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

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -110,41 +110,3 @@ model_parameters:
110110
- `repetition_penalty`: Penalty for repeating tokens
111111
- `presence_penalty`: Penalty for token presence
112112
- `frequency_penalty`: Penalty for token frequency
113-
114-
## Advanced Features
115-
116-
### Backend Selection
117-
SGLang supports different backends for sampling and attention:
118-
119-
```yaml
120-
model_parameters:
121-
sampling_backend: "vllm" # or "hf", "hf_legacy"
122-
attention_backend: "flash" # or "xformers", "native"
123-
```
124-
125-
### Optimizations
126-
- `pairwise_tokenization`: Enable pairwise tokenization for multiple choice tasks
127-
- `add_special_tokens`: Add special tokens during tokenization
128-
- `skip_tokenizer_init`: Skip tokenizer initialization for faster startup
129-
130-
## Troubleshooting
131-
132-
### Common Issues
133-
134-
1. **Out of Memory Errors**: Reduce `mem_fraction_static` or `chunked_prefill_size`
135-
2. **Model Loading Errors**: Check that the model name and configuration are correct
136-
3. **Performance Issues**: Ensure appropriate backend selection for your hardware
137-
138-
### Performance Tips
139-
140-
- Use tensor parallelism for large models that don't fit on a single GPU
141-
- Use data parallelism for smaller models to increase throughput
142-
- Adjust `mem_fraction_static` based on your GPU memory capacity
143-
- Consider using `float16` or `bfloat16` for faster inference
144-
- Use appropriate sampling and attention backends for your hardware
145-
146-
### Memory Optimization
147-
148-
- Reduce `mem_fraction_static` if you encounter OOM errors
149-
- Adjust `chunked_prefill_size` based on your memory constraints
150-
- Use `skip_tokenizer_init=True` for faster startup if tokenizer is not needed

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,3 @@ model_parameters:
112112
1. **Out of Memory Errors**: Reduce `gpu_memory_utilization` or `max_model_length`
113113
2. **Worker Process Issues**: Ensure `VLLM_WORKER_MULTIPROC_METHOD=spawn` is set for multi-GPU setups
114114
3. **Model Loading Errors**: Check that the model name and revision are correct
115-
116-
### Performance Tips
117-
118-
- Use tensor parallelism for large models that don't fit on a single GPU
119-
- Use data parallelism for smaller models to increase throughput
120-
- Adjust `gpu_memory_utilization` based on your GPU memory capacity
121-
- Consider using `bfloat16` or `float16` for faster inference

docs/source/using-the-python-api.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def main():
4141
dtype="float16",
4242
)
4343

44-
task = "helm|mmlu|5"
44+
task = "lighteval|gsm8k|5"
4545

4646
pipeline = Pipeline(
4747
tasks=task,
@@ -78,7 +78,7 @@ You can evaluate on multiple tasks by providing a comma-separated list or a file
7878

7979
```python
8080
# Multiple tasks as comma-separated string
81-
tasks = "helm|mmlu|5|1,helm|truthfulqa:mc|0"
81+
tasks = "lighteval|aime24|0,lighteval|aime25|0"
8282

8383
# Or load from a file
8484
tasks = "./path/to/tasks.txt"

0 commit comments

Comments
 (0)