Skip to content
HUIAHUB
VideointermediateModels & inference

Transformers.js v4.3: Structured Output in the browser

by Hugging Face11:08 long4.5K views

Why watchAn 11-minute Hugging Face walkthrough of Transformers.js 4.3 for JavaScript developers who need models in the browser to return valid JSON every time.

What this video covers

This Hugging Face video walks through the Transformers.js 4.3 release, whose headline feature is structured output in the browser. A new package, @huggingface/transformers-structured-output, forces a model to follow an exact JSON Schema or regular expression.

The first minute and a half covers the rest of the release. After the announcement at 0:00, the chapter at 0:26 is about the new documentation pipeline, which the description calls a complete overhaul. Community-contributed fixes and features get a short mention at 1:00.

From 1:19 the video sets out the problem: language models return unreliable JSON, and developers end up stripping markdown fences and hoping the property names came out right. At 2:18 it explains how constrained decoding works. According to the description, the new package hooks into the logits processor in Transformers.js; adding that processor is the subject of the chapter at 3:25.

The longest stretch, from 3:37 to 6:03, covers the new packages folder in the repository and the plugin approach that structured output uses. At 6:03 the video turns to constraining output with a regex instead of a JSON Schema, and at 6:45 a recipe generator demo shows the feature in use.

The second half tells the story behind the feature. From 7:33 it covers llguidance, which the first version wrapped through WASM. At 9:02 the video explains rewriting it in pure JavaScript, which the description says runs with almost no overhead. A chapter at 9:22 looks at performance on Gemma 4, Granite and LFM 2.5; the sources do not give the figures. The last chapter, at 10:26, points viewers to try it.

The description links the 4.3.0 release notes on GitHub and the npm pages for both the main library and the structured output package.

Written by HuiaHub from the creator's title, description and chapters. All credit for the video goes to Hugging Face.

Key takeaways

  • Transformers.js 4.3 can constrain model output to a JSON Schema or a regex in the browser.
  • Structured output ships as a separate package, @huggingface/transformers-structured-output.
  • The package works by hooking into the Transformers.js logits processor.
  • Constrained decoding removes the need to parse markdown fences out of model replies.
  • The feature started as a WASM wrapper around llguidance and was rewritten in pure JavaScript.
  • Version 4.3 also overhauls the documentation pipeline.

Chapters

  1. 0:00Transformers.js 4.3 is out (opens YouTube at this moment)
  2. 0:26New documentation pipeline (opens YouTube at this moment)
  3. 1:00Community contributions (opens YouTube at this moment)
  4. 1:19The problem: unreliable JSON from LLMs (opens YouTube at this moment)
  5. 2:18How constrained decoding works (opens YouTube at this moment)
  6. 3:25Adding the structured output processor (opens YouTube at this moment)
  7. 3:37The new packages folder and plugin approach (opens YouTube at this moment)
  8. 6:03Using regex instead of JSON Schema (opens YouTube at this moment)
  9. 6:45Demo: recipe generator (opens YouTube at this moment)
  10. 7:33Behind the feature: llguidance (opens YouTube at this moment)
  11. 9:02Rewriting it in pure JavaScript (opens YouTube at this moment)
  12. 9:22Performance across Gemma 4, Granite and LFM 2.5 (opens YouTube at this moment)
  13. 10:26Try it out (opens YouTube at this moment)

More videos

All videos