You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
[BUG] custom model docs don't run: missing imports #760
Hi @clefourrier—It's not just that the example doesn't run; the base class, LightevalModel, is now completely (edit: mostly) abstract, and in particular has no __init__(). This means, among other things, that every subclass has to manually implement the following code block:
Ideally this functionality would be provided in the base class. I'd be happy to submit a PR for this and the documentation, but I'm writing to check first that HF would be interested in this.
FWIW, here is what's needed for a completely functional implementation that will work with the command-line custom subcommand (expanded from #757). This is much bigger than what's listed in the documentation, which is now out-of-date.
fromlighteval.models.abstract_modelimportLightevalModel, ModelInfofromtransformersimportAutoTokenizerclassTestModel(LightevalModel):
def__init__(self, config) ->None:
self.model_name=config.model_nameself.model_definition_file_path=config.model_definition_file_pathself.model_info=ModelInfo(
model_name=config.model_name,
model_sha="",
model_dtype=None,
model_size="",
)
# you need to provide a dummy tokenizer, and HF has nothing like an identity variantself._tokenizer=AutoTokenizer.from_pretrained("gpt2")
@propertydeftokenizer(self):
returnself._tokenizer@propertydefadd_special_tokens(self):
returnFalse@propertydefmax_length(self) ->int:
return32768defgreedy_until(self, requests, max_tokens=None, stop_sequences=None):
forrequestinrequests:
print(vars(request))
defloglikelihood(self, requests, log=True):
# Implement loglikelihood computationpassdefloglikelihood_rolling(self, requests):
# Implement rolling loglikelihood computationpassdefloglikelihood_single_token(self, requests):
# Implement single token loglikelihood computationpass
It's me :) I'm using lighteval for the first time and it's clear that the niche that sacrebleu filled (which was at least in part to make it easy to download test sets) has been completely superseded. It's very nice!
Hi @clefourrier@NathanHB, the imports reported here as missing are already fixed on main. When I re-checked the examples in evaluating-a-custom-model.mdx, two of them still don't run:
In the Python API example, tasks=truthfulqa:mc, (line 97) isn't quoted, so it raises a SyntaxError when copied.
In the CLI example, the quote on "wmt20:fr-de \ (line 62) is never closed.
#1352 fixes both. It's a 2-line, docs-only change with green CI, and it should let this issue be closed. Happy to adjust if you'd like it done differently.
Activity
[-][BUG] Python API docs don't run: missing imports[/-][+][BUG] custom model docs don't run: missing imports[/+]clefourrier commentedon May 21, 2025
Hi! Good catch, feel free to open a PR for these! :)
mjpost commentedon May 21, 2025
Hi @clefourrier—It's not just that the example doesn't run; the base class,
LightevalModel, is nowcompletely(edit: mostly) abstract, and in particular has no__init__(). This means, among other things, that every subclass has to manually implement the following code block:Ideally this functionality would be provided in the base class. I'd be happy to submit a PR for this and the documentation, but I'm writing to check first that HF would be interested in this.
FWIW, here is what's needed for a completely functional implementation that will work with the command-line
customsubcommand (expanded from #757). This is much bigger than what's listed in the documentation, which is now out-of-date.clefourrier commentedon May 21, 2025
It would be indeed great if you could open a PR for this! cc @NathanHB just for a double look but this lgtm
clefourrier commentedon May 21, 2025
(side note: are you the sacrebleu matt post? - edit: checked your github, seems like you are! I'm a huge fan, loved the lib!!! 🤩 )
mjpost commentedon May 21, 2025
It's me :) I'm using
lightevalfor the first time and it's clear that the niche that sacrebleu filled (which was at least in part to make it easy to download test sets) has been completely superseded. It's very nice!I'll prep a PR for comment later in the day.
mohansree14 commentedon Oct 14, 2026
Hi @clefourrier @NathanHB, the imports reported here as missing are already fixed on
main. When I re-checked the examples inevaluating-a-custom-model.mdx, two of them still don't run:tasks=truthfulqa:mc,(line 97) isn't quoted, so it raises aSyntaxErrorwhen copied."wmt20:fr-de \(line 62) is never closed.#1352 fixes both. It's a 2-line, docs-only change with green CI, and it should let this issue be closed. Happy to adjust if you'd like it done differently.