Skip to content

feat: implement better hugging face output parsing #1604

Description

@jakelorocco

We should implement output parsing for the hugging face backend. We currently scan the output for tools, but we don't do this for thinking tokens (and any others that we might want to capture).

The transformers library also added it's own output parser capabilities with models being able to define their own response schemas; we could utilize this for models that have it defined, and fall back to some simple parsing for our own.

Activity

  1. added
    p1
    on Sep 1, 2026
  2. added
    area/backends
    on Sep 1, 2026
  3. jakelorocco commented on Sep 29, 2026

    @jakelorocco
    ContributorAuthor
  4. planetf1 commented on Oct 6, 2026

    @planetf1
    Contributor

    Status (2026-10-06): the Granite-specific parsing is done; the general work is still open.

    Done: for non-streaming generation, thinking tags now parse into mot.thinking on LocalHFBackend via _split_think_tags() (PR #1616, merged 2026-09-16), applied where the chat template declares a thinking variable. Granite XML tool calls also parse on the local HF path (PR #1692, merged 2026-10-05).

    Still open, in three parts:

    1. The parser only knows Granite's convention. _split_think_tags() is a fixed string match on the closing think tag, and output from models that use other reasoning delimiters passes through unparsed.
    2. The transformers-native path is unused. PreTrainedTokenizerBase.parse_response() parses output against a schema the tokenizer declares, but no tokenizer available to this backend declares a response_schema today, so the backend never calls it. The API is available in the transformers this repo resolves to (5.10.2, within the >5.5.0,<6.0.0 pin).
    3. The split only runs on non-streaming generation.

    The docstring of _split_think_tags() records parts 1 and 2 with "see #1604" pointers, so this issue remains the right home for that work.

  5. assigned and unassigned on Oct 23, 2026
  6. self-assigned this
    on Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/backendsp1

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions