Skip to content

[BUG] custom model docs don't run: missing imports #760

Description

@jamesbraza

Describe the bug

https://github.com/huggingface/lighteval/blob/v0.9.2/docs/source/evaluating-a-custom-model.mdx#creating-a-custom-model did not import ParallelismManager.

https://github.com/huggingface/lighteval/blob/v0.9.2/docs/source/using-the-python-api.mdx uses a nonexistent EnvConfig

To Reproduce

N/a

Expected behavior

Docs to not have missing imports

Version info

lighteval==0.9.2

Activity

  1. changed the title [-][BUG] Python API docs don't run: missing imports[/-] [+][BUG] custom model docs don't run: missing imports[/+] on May 21, 2025
  2. clefourrier commented on May 21, 2025

    @clefourrier
    Member

    Hi! Good catch, feel free to open a PR for these! :)

  3. added theissue type on May 21, 2025
  4. mjpost commented on May 21, 2025

    @mjpost

    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:

        def __init__(self, config) -> None:
    	self.model_name = config.model_name
            self.model_definition_file_path = config.model_definition_file_path
    
            self.model_info = ModelInfo(
                model_name=config.model_name,
                model_sha="",
                model_dtype=None,
                model_size="",
            )
    
            self._tokenizer = AutoTokenizer.from_pretrained("gpt2")

    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.

    from lighteval.models.abstract_model import LightevalModel, ModelInfo
    from transformers import AutoTokenizer
    
    class TestModel(LightevalModel):
        def __init__(self, config) -> None:
    	self.model_name = config.model_name
            self.model_definition_file_path = config.model_definition_file_path
    
            self.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 variant
            self._tokenizer = AutoTokenizer.from_pretrained("gpt2")
    
        @property
        def tokenizer(self):
            return self._tokenizer
    
        @property
        def add_special_tokens(self):
            return False
    
        @property
        def max_length(self) -> int:
            return 32768
    
        def greedy_until(self, requests, max_tokens=None, stop_sequences=None):
            for request in requests:
                print(vars(request))
    
        def loglikelihood(self, requests, log=True):
            # Implement loglikelihood computation
            pass
    
        def loglikelihood_rolling(self, requests):
            # Implement rolling loglikelihood computation
            pass
    
        def loglikelihood_single_token(self, requests):
            # Implement single token loglikelihood computation
            pass
  5. clefourrier commented on May 21, 2025

    @clefourrier
    Member

    It would be indeed great if you could open a PR for this! cc @NathanHB just for a double look but this lgtm

  6. clefourrier commented on May 21, 2025

    @clefourrier
    Member

    (side note: are you the sacrebleu matt post? - edit: checked your github, seems like you are! I'm a huge fan, loved the lib!!! 🤩 )

  7. mjpost commented on May 21, 2025

    @mjpost

    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!

    I'll prep a PR for comment later in the day.

  8. mohansree14 commented on Oct 14, 2026

    @mohansree14

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions