Skip to content

Constraint.advance() docstring is slighly incorrect #32668

@alex-calderwood

Description

@alex-calderwood

System Info

according to the implementations of the Constraint ABC, the advance() function can return either a single token id (as the docstring indicates) or a list of token ids that would advance the beam search. It should be updated to reflect this.

Here is an example fix:

@abstractmethod
def advance(self):
    """
    When called, returns the token(s) that would take this constraint one step closer to being fulfilled.

    Return:
        token_ids (Union[int, List[int], None]): 
            - A single token ID (int) that advances the constraint
            - A list of token IDs that could advance the constraint
            - None if the constraint is completed or cannot be advanced
    """

Who can help?

No response

Information

  • The official example scripts
  • My own modified scripts

Tasks

  • An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
  • My own task or dataset (give details below)

Reproduction

Just a docstring change.

Expected behavior

Should be updated for accuracy, easy of implementing this abstract base class.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions