Skip to content

Commit 348e427

Browse files
authored
Merge branch 'main' into add-custom-model
2 parents f6df2a3 + f6fee3a commit 348e427

File tree

4 files changed

+21
-19
lines changed

4 files changed

+21
-19
lines changed

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ Hub, S3, or locally.
4444

4545
## 🔑 Key Features
4646

47-
- **Speed**: [Use vllm as backend for fast evals](https://github.com/huggingface/lighteval/wiki/Use-VLLM-as-backend).
48-
- **Completeness**: [Use the accelerate backend to launch any models hosted on Hugging Face](https://github.com/huggingface/lighteval/wiki/Quicktour#accelerate).
49-
- **Seamless Storage**: [Save results in S3 or Hugging Face Datasets](https://github.com/huggingface/lighteval/wiki/Saving-and-reading-results).
50-
- **Python API**: [Simple integration with the Python API](https://github.com/huggingface/lighteval/wiki/Using-the-Python-API).
51-
- **Custom Tasks**: [Easily add custom tasks](https://github.com/huggingface/lighteval/wiki/Adding-a-Custom-Task).
52-
- **Versatility**: Tons of [metrics](https://github.com/huggingface/lighteval/wiki/Metric-List) and [tasks](https://github.com/huggingface/lighteval/wiki/Available-Tasks) ready to go.
47+
- **Speed**: [Use vllm as backend for fast evals](https://huggingface.co/docs/lighteval/use-vllm-as-backend).
48+
- **Completeness**: [Use the accelerate backend to launch any models hosted on Hugging Face](https://huggingface.co/docs/lighteval/quicktour#accelerate).
49+
- **Seamless Storage**: [Save results in S3 or Hugging Face Datasets](https://huggingface.co/docs/lighteval/saving-and-reading-results).
50+
- **Python API**: [Simple integration with the Python API](https://huggingface.co/docs/lighteval/using-the-python-api).
51+
- **Custom Tasks**: [Easily add custom tasks](https://huggingface.co/docs/lighteval/adding-a-custom-task).
52+
- **Versatility**: Tons of [metrics](https://huggingface.co/docs/lighteval/metric-list) and [tasks](https://huggingface.co/docs/lighteval/available-tasks) ready to go.
5353

5454

5555
## ⚡️ Installation
@@ -58,7 +58,7 @@ Hub, S3, or locally.
5858
pip install lighteval
5959
```
6060

61-
Lighteval allows for many extras when installing, see [here](https://github.com/huggingface/lighteval/wiki/Installation) for a complete list.
61+
Lighteval allows for many extras when installing, see [here](https://huggingface.co/docs/lighteval/installation) for a complete list.
6262

6363
If you want to push results to the Hugging Face Hub, add your access token as
6464
an environment variable:
@@ -106,8 +106,8 @@ Harness and HELM teams for their pioneering work on LLM evaluations.
106106
## 🌟 Contributions Welcome 💙💚💛💜🧡
107107

108108
Got ideas? Found a bug? Want to add a
109-
[task](https://github.com/huggingface/lighteval/wiki/Adding-a-Custom-Task) or
110-
[metric](https://github.com/huggingface/lighteval/wiki/Adding-a-New-Metric)?
109+
[task](https://huggingface.co/docs/lighteval/adding-a-custom-task) or
110+
[metric](https://huggingface.co/docs/lighteval/adding-a-new-metric)?
111111
Contributions are warmly welcomed!
112112

113113
If you're adding a new feature, please open an issue first.

src/lighteval/models/endpoints/endpoint_model.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ def greedy_until(
510510

511511
for _, _ in tqdm(
512512
dataset.splits_start_end_iterator(),
513-
total=self.DATASET_SPLITS,
513+
total=dataset.num_dataset_splits,
514514
desc="Splits",
515515
position=0,
516516
disable=self.disable_tqdm,
@@ -532,12 +532,15 @@ def greedy_until(
532532
responses = asyncio.run(self._async_process_batch_generate(batch))
533533
else:
534534
responses = self._process_batch_generate(batch)
535-
for response in responses:
535+
for i, response in enumerate(responses):
536536
results.append(
537537
GenerativeResponse(
538538
result=response.generated_text,
539539
logits=[item.logprob for item in response.details.prefill] if returns_logits else None,
540-
truncated_tokens_count=-1,
540+
generated_tokens=[token.id for token in response.details.tokens],
541+
truncated_tokens_count=max(
542+
len(self.tokenizer.encode(batch[i].context)) - self.max_length, 0
543+
),
541544
padded_tokens_count=-1,
542545
)
543546
)
@@ -556,7 +559,7 @@ def loglikelihood(
556559

557560
for _, _ in tqdm(
558561
dataset.splits_start_end_iterator(),
559-
total=self.DATASET_SPLITS,
562+
total=dataset.num_dataset_splits,
560563
desc="Splits",
561564
position=0,
562565
disable=self.disable_tqdm,
@@ -607,7 +610,7 @@ def loglikelihood_rolling(
607610

608611
for _, _ in tqdm(
609612
dataset.splits_start_end_iterator(),
610-
total=self.DATASET_SPLITS,
613+
total=dataset.num_dataset_splits,
611614
desc="Splits",
612615
position=0,
613616
disable=self.disable_tqdm,

src/lighteval/models/model_loader.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,9 @@ def load_custom_model(config: CustomModelConfig, env_config: EnvConfig):
166166
return model
167167

168168

169-
def load_model_with_inference_endpoints(config: InferenceEndpointModelConfig, env_config: EnvConfig):
169+
def load_model_with_inference_endpoints(
170+
config: Union[InferenceEndpointModelConfig, ServerlessEndpointModelConfig], env_config: EnvConfig
171+
):
170172
logger.info("Spin up model using inference endpoint.")
171173
model = InferenceEndpointModel(config=config, env_config=env_config)
172174
return model

src/lighteval/models/transformers/transformers_model.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -880,10 +880,7 @@ def greedy_until(
880880
input_ids=tokenized["input_ids"],
881881
input_lengths=[len(item == 1) for item in tokenized["attention_mask"]],
882882
input_mask=tokenized["attention_mask"],
883-
truncated=[
884-
len(c) - tokenized["input_ids"].shape[1] if len(c) > tokenized["input_ids"].shape[1] else 0
885-
for c in context
886-
],
883+
truncated=[max(len(c) - tokenized["input_ids"].shape[1], 0) for c in context],
887884
padded=[sum(mask == 0) for mask in tokenized["attention_mask"]],
888885
)
889886

0 commit comments

Comments
 (0)