Skip to content

Commit

Permalink
Merge branch 'main' into add-custom-model
Browse files Browse the repository at this point in the history
  • Loading branch information
JoelNiklaus authored Jan 7, 2025
2 parents f6df2a3 + f6fee3a commit 348e427
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 19 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ Hub, S3, or locally.

## 🔑 Key Features

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


## ⚡️ Installation
Expand All @@ -58,7 +58,7 @@ Hub, S3, or locally.
pip install lighteval
```

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

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

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

If you're adding a new feature, please open an issue first.
Expand Down
13 changes: 8 additions & 5 deletions src/lighteval/models/endpoints/endpoint_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ def greedy_until(

for _, _ in tqdm(
dataset.splits_start_end_iterator(),
total=self.DATASET_SPLITS,
total=dataset.num_dataset_splits,
desc="Splits",
position=0,
disable=self.disable_tqdm,
Expand All @@ -532,12 +532,15 @@ def greedy_until(
responses = asyncio.run(self._async_process_batch_generate(batch))
else:
responses = self._process_batch_generate(batch)
for response in responses:
for i, response in enumerate(responses):
results.append(
GenerativeResponse(
result=response.generated_text,
logits=[item.logprob for item in response.details.prefill] if returns_logits else None,
truncated_tokens_count=-1,
generated_tokens=[token.id for token in response.details.tokens],
truncated_tokens_count=max(
len(self.tokenizer.encode(batch[i].context)) - self.max_length, 0
),
padded_tokens_count=-1,
)
)
Expand All @@ -556,7 +559,7 @@ def loglikelihood(

for _, _ in tqdm(
dataset.splits_start_end_iterator(),
total=self.DATASET_SPLITS,
total=dataset.num_dataset_splits,
desc="Splits",
position=0,
disable=self.disable_tqdm,
Expand Down Expand Up @@ -607,7 +610,7 @@ def loglikelihood_rolling(

for _, _ in tqdm(
dataset.splits_start_end_iterator(),
total=self.DATASET_SPLITS,
total=dataset.num_dataset_splits,
desc="Splits",
position=0,
disable=self.disable_tqdm,
Expand Down
4 changes: 3 additions & 1 deletion src/lighteval/models/model_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,9 @@ def load_custom_model(config: CustomModelConfig, env_config: EnvConfig):
return model


def load_model_with_inference_endpoints(config: InferenceEndpointModelConfig, env_config: EnvConfig):
def load_model_with_inference_endpoints(
config: Union[InferenceEndpointModelConfig, ServerlessEndpointModelConfig], env_config: EnvConfig
):
logger.info("Spin up model using inference endpoint.")
model = InferenceEndpointModel(config=config, env_config=env_config)
return model
Expand Down
5 changes: 1 addition & 4 deletions src/lighteval/models/transformers/transformers_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -880,10 +880,7 @@ def greedy_until(
input_ids=tokenized["input_ids"],
input_lengths=[len(item == 1) for item in tokenized["attention_mask"]],
input_mask=tokenized["attention_mask"],
truncated=[
len(c) - tokenized["input_ids"].shape[1] if len(c) > tokenized["input_ids"].shape[1] else 0
for c in context
],
truncated=[max(len(c) - tokenized["input_ids"].shape[1], 0) for c in context],
padded=[sum(mask == 0) for mask in tokenized["attention_mask"]],
)

Expand Down

0 comments on commit 348e427

Please sign in to comment.