Skip to content

Tokenizer.Decode special-cases EnglishRoberta #7010

Closed

Description

@stephentoub

This suggests there's something wrong with the Model abstraction, and it means that any other model of a similar ilk to EnglishRoberta could not be supported (or not supported efficiently, or whatever reason caused this to be special-cased here). The special-casing should be removed and the abstraction fixed to make the special-casing unnecessary.

if (Model is EnglishRoberta robertaModel)
{
foreach (int id in ids)
{
tokens.Add(robertaModel.IdToFilteredToken(id, skipSpecialTokens) ?? "");
}
}
else
{
foreach (int id in ids)
{
tokens.Add(Model.IdToToken(id, skipSpecialTokens) ?? "");
}
}

Activity

  1. stephentoub commented on Feb 16, 2024

    @stephentoub
    MemberAuthor
  2. tarekgh commented on Feb 16, 2024

    @tarekgh
    Member

    @stephentoub this was in the abstraction and I removed it from there because the functionality was specific to this tokenizer only. This is why I made it this way. I have no idea ever any other tokenizers will need that. If we see cases like this in the future we can decide to add it to the abstraction. But for now I suggest not adding it.

  3. tarekgh commented on Feb 16, 2024

    @tarekgh
    Member

    The other idea is to have Model.IdToToken always return the filtered token in EnglishRoberta tokenizer.

    CC @michaelgsharp @LittleLittleCloud

  4. self-assigned this
    on Feb 16, 2024
  5. stephentoub commented on Feb 16, 2024

    @stephentoub
    MemberAuthor

    @stephentoub this was in the abstraction and I removed it from there because the functionality was specific to this tokenizer only. This is why I made it this way. I have no idea ever any other tokenizers will need that. If we see cases like this in the future we can decide to add it to the abstraction. But for now I suggest not adding it.

    There are only three tokenizers in the library. If 1/3rd of them needs whatever this is, seems likely another will as well. And if someone wanted to provide their own EnglishRoberta equivalent (maybe faster, or with subtly different semantics), how would they?

  6. stephentoub commented on Feb 17, 2024

    @stephentoub
    MemberAuthor

    I just noticed that Tiktoken is also special-cased by Decode. That's two models that Decode is special-casing. Certainly seems like there's something wrong with the abstraction.

  7. tarekgh commented on Feb 17, 2024

    @tarekgh
    Member

    Ok, will think about these two cases.

  8. stephentoub commented on Feb 17, 2024

    @stephentoub
    MemberAuthor

    Thanks :)

  9. locked and limited conversation to collaborators on Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions