Skip to content

Commit c871456

Browse files
authored
Patch 0.9.1 (#708)
* fix inference endpoints bugs * Release: v0.9.1
1 parent 20cff95 commit c871456

File tree

5 files changed

+11
-50
lines changed

5 files changed

+11
-50
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ The command takes three required arguments:
6262
```python
6363
from lighteval.logging.evaluation_tracker import EvaluationTracker
6464
from lighteval.models.custom.custom_model import CustomModelConfig
65-
from lighteval.pipeline import Pipeline, PipelineParameters, EnvConfig
65+
from lighteval.pipeline import Pipeline, PipelineParameters
6666

6767
# Set up evaluation tracking
6868
evaluation_tracker = EvaluationTracker(

src/lighteval/data.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,6 @@ def __init__(
6767
requests (List): A list of requests.
6868
num_dataset_splits (int): The number of dataset splits.
6969
"""
70-
# We make sure the requests contain the tokenized versions of their values
71-
if any(r.tokenized_context is None for r in requests):
72-
raise ValueError("You passed a request for which tokenization had not happened yet.")
73-
7470
# sort the requests using the collate function and save the original order
7571
enumerated_requests = list(enumerate(requests))
7672
sorted_enumerated_requests = sorted(enumerated_requests, key=lambda x: self._sorting_criteria(x[1]))
@@ -270,11 +266,13 @@ def _sorting_criteria(self, request: GreedyUntilRequest) -> tuple[bool, bool, li
270266
Returns:
271267
Any: The collated data.
272268
"""
273-
toks = request.tokenized_context
269+
toks = request.context
274270
gen_length = request.generation_size
271+
275272
# The generative task has no limit except the model context
276273
if gen_length is None:
277274
gen_length = 0
275+
278276
return (
279277
request.do_sample,
280278
request.use_logits,

src/lighteval/models/abstract_model.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def get_method_from_request_type(self, request_type: RequestType):
9797
raise NotImplementedError(f"Request type {request_type} not supported")
9898

9999
def greedy_until_multi_turn( # noqa: C901
100-
self, requests: list[GreedyUntilMultiTurnRequest], override_bs: Optional[int] = None
100+
self, requests: list[GreedyUntilMultiTurnRequest]
101101
) -> GenerativeMultiturnResponse:
102102
"""Generates responses using a greedy decoding strategy until certain ending conditions are met."""
103103
return NotImplemented
@@ -106,7 +106,6 @@ def greedy_until_multi_turn( # noqa: C901
106106
def greedy_until(
107107
self,
108108
requests: list[GreedyUntilRequest],
109-
override_bs: Optional[int] = None,
110109
) -> list[GenerativeResponse]:
111110
"""
112111
Generates responses using a greedy decoding strategy until certain ending conditions are met.
@@ -122,24 +121,20 @@ def greedy_until(
122121
return NotImplemented
123122

124123
@abstractmethod
125-
def loglikelihood(
126-
self, requests: list[LoglikelihoodRequest], override_bs: Optional[int] = None
127-
) -> list[LoglikelihoodResponse]:
124+
def loglikelihood(self, requests: list[LoglikelihoodRequest]) -> list[LoglikelihoodResponse]:
128125
"""Tokenize the context and continuation and compute the log likelihood of those
129126
tokenized sequences.
130127
"""
131128
return NotImplemented
132129

133130
@abstractmethod
134-
def loglikelihood_rolling(
135-
self, requests: list[LoglikelihoodRollingRequest], override_bs: Optional[int] = None
136-
) -> list[LoglikelihoodResponse]:
131+
def loglikelihood_rolling(self, requests: list[LoglikelihoodRollingRequest]) -> list[LoglikelihoodResponse]:
137132
"""This function is used to compute the log likelihood of the context for perplexity metrics."""
138133
return NotImplemented
139134

140135
@abstractmethod
141136
def loglikelihood_single_token(
142-
self, requests: list[LoglikelihoodSingleTokenRequest], override_bs: Optional[int] = None
137+
self, requests: list[LoglikelihoodSingleTokenRequest]
143138
) -> list[LoglikelihoodSingleTokenResponse]:
144139
"""Tokenize the context and continuation and compute the log likelihood of those
145140
tokenized sequences.

src/lighteval/models/endpoints/inference_providers_model.py

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import logging
2525
from typing import Any, List, Optional
2626

27-
import yaml
2827
from huggingface_hub import AsyncInferenceClient, ChatCompletionOutput
2928
from huggingface_hub.errors import HfHubHTTPError
3029
from pydantic import NonNegativeInt
@@ -35,7 +34,6 @@
3534
from lighteval.data import GenerativeTaskDataset
3635
from lighteval.models.abstract_model import LightevalModel
3736
from lighteval.models.endpoints.endpoint_model import ModelInfo
38-
from lighteval.models.model_input import GenerationParameters
3937
from lighteval.models.model_output import (
4038
GenerativeResponse,
4139
LoglikelihoodResponse,
@@ -72,26 +70,6 @@ class InferenceProvidersModelConfig(ModelConfig):
7270
org_to_bill: str | None = None
7371
parallel_calls_count: NonNegativeInt = 10
7472

75-
@classmethod
76-
def from_path(cls, path):
77-
with open(path, "r") as f:
78-
config = yaml.safe_load(f)["model"]
79-
80-
model_name = config["model_name"]
81-
provider = config.get("provider", None)
82-
timeout = config.get("timeout", None)
83-
proxies = config.get("proxies", None)
84-
org_to_bill = config.get("org_to_bill", None)
85-
generation_parameters = GenerationParameters.from_dict(config)
86-
return cls(
87-
model=model_name,
88-
provider=provider,
89-
timeout=timeout,
90-
proxies=proxies,
91-
org_to_bill=org_to_bill,
92-
generation_parameters=generation_parameters,
93-
)
94-
9573

9674
class InferenceProvidersClient(LightevalModel):
9775
"""Client for making inference requests to various providers using the HuggingFace Inference API.
@@ -198,7 +176,6 @@ async def bounded_api_call(prompt, num_samples):
198176
def greedy_until(
199177
self,
200178
requests: list[GreedyUntilRequest],
201-
override_bs: Optional[int] = None,
202179
) -> list[GenerativeResponse]:
203180
"""
204181
Generates responses using a greedy decoding strategy until certain ending conditions are met.
@@ -256,22 +233,18 @@ def max_length(self) -> int:
256233
logger.warning("Tokenizer was not correctly loaded. Max model context length is assumed to be 30K tokens")
257234
return 30000
258235

259-
def loglikelihood(
260-
self, requests: list[LoglikelihoodRequest], override_bs: Optional[int] = None
261-
) -> list[LoglikelihoodResponse]:
236+
def loglikelihood(self, requests: list[LoglikelihoodRequest]) -> list[LoglikelihoodResponse]:
262237
"""Tokenize the context and continuation and compute the log likelihood of those
263238
tokenized sequences.
264239
"""
265240
raise NotImplementedError
266241

267-
def loglikelihood_rolling(
268-
self, requests: list[LoglikelihoodRollingRequest], override_bs: Optional[int] = None
269-
) -> list[LoglikelihoodResponse]:
242+
def loglikelihood_rolling(self, requests: list[LoglikelihoodRollingRequest]) -> list[LoglikelihoodResponse]:
270243
"""This function is used to compute the log likelihood of the context for perplexity metrics."""
271244
raise NotImplementedError
272245

273246
def loglikelihood_single_token(
274-
self, requests: list[LoglikelihoodSingleTokenRequest], override_bs: Optional[int] = None
247+
self, requests: list[LoglikelihoodSingleTokenRequest]
275248
) -> list[LoglikelihoodSingleTokenResponse]:
276249
"""Tokenize the context and continuation and compute the log likelihood of those
277250
tokenized sequences.

tests/test_unit_reorder.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
# SOFTWARE.
2222

23-
import pytest
2423
from transformers import AutoTokenizer
2524

2625
from lighteval.data import GenerativeTaskDataset
@@ -81,10 +80,6 @@
8180

8281

8382
class TestReorderGenerativeTaskDataset:
84-
def test_dataset_needs_tokenization(self):
85-
with pytest.raises(ValueError):
86-
GenerativeTaskDataset(requests=TEST_DATA, num_dataset_splits=DATASET_SPLITS)
87-
8883
def test_reorder_dataset(self):
8984
tokenizer = AutoTokenizer.from_pretrained("gpt2")
9085
data = TEST_DATA.copy()

0 commit comments

Comments
 (0)