Skip to content

Commit

Permalink
fix issue with truncated_tokens_count huggingface#2
Browse files Browse the repository at this point in the history
  • Loading branch information
guipenedo authored and Hynek Kydlicek committed Jul 12, 2024
1 parent fe395db commit c89c5d4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
7 changes: 3 additions & 4 deletions src/lighteval/models/dummy_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,17 @@ def greedy_until(self, requests: list[GreedyUntilRequest], override_bs: Optional

def loglikelihood(self, requests: list[LoglikelihoodRequest], override_bs: Optional[int] = None) -> list[
LoglikelihoodReturn]:
return [LoglikelihoodReturn((-random.random(), False), truncated_tokens_count=0, padded_tokens_count=0)
return [LoglikelihoodReturn((-random.random(), False))
for _ in requests]

def loglikelihood_rolling(self, requests: list[LoglikelihoodRollingRequest], override_bs: Optional[int] = None) -> \
list[LoglikelihoodReturn]:
return [LoglikelihoodReturn((-random.random(), False), truncated_tokens_count=0, padded_tokens_count=0)
return [LoglikelihoodReturn((-random.random(), False))
for _ in requests]

def loglikelihood_single_token(self, requests: list[LoglikelihoodSingleTokenRequest],
override_bs: Optional[int] = None) -> list[LoglikelihoodSingleTokenReturn]:
return [
LoglikelihoodSingleTokenReturn(result=[-random.random() for _ in req.tokenized_continuation],
truncated_tokens_count=0, padded_tokens_count=0)
LoglikelihoodSingleTokenReturn(result=[-random.random() for _ in req.tokenized_continuation])
for req in requests
]
4 changes: 2 additions & 2 deletions src/lighteval/models/model_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ class ModelReturn:
result: Union[tuple, list, str]
input_tokens: list[int] = field(default_factory=list) # model inputs
generated_tokens: list[int] = field(default_factory=list) # model generations
truncated_tokens_count: Optional[int] = None # How many tokens truncated
padded_tokens_count: Optional[int] = None # How many tokens of padding
truncated_tokens_count: Optional[int] = 0 # How many tokens truncated
padded_tokens_count: Optional[int] = 0 # How many tokens of padding

def get_result_for_eval(self):
raise NotImplementedError()
Expand Down

0 comments on commit c89c5d4

Please sign in to comment.