Skip to content

Structured Output in the browser with Transformers.js 4.3

Read the Portuguese translation →

Author: Hugging Face · Watch on YouTube

Video authored by the channel shown, not by IANIA; all rights belong to the creator. Transcript and summary generated automatically; the original-language content is preserved.

Original language: English

Original video: Structured Output in the browser with Transformers.js 4.3 · Channel: Hugging Face · 00:31 · Watch on YouTube

Topics: Prompt and context engineering, Software engineering with AI, AI developer tools, AI content generation

Transformers.js version 4.3 introduces structured output, a feature requested by the community. A new Transformers structured output package on NPM lets developers build a processor that hooks into token generation and ensures generated tokens follow a specified structure. The video gives JSON schemas and regular expressions as examples of constraints. The package is available on NPM, and the team invites users to try it and share feedback.

  • Structured output is a new feature in Transformers.js version 4.3.
  • The feature had been requested by the community.
  • A new Transformers structured output package is available on NPM.
  • The package lets developers build a structured output processor.
  • The processor hooks into the generation of new tokens.
  • It ensures each new token follows the required structure.
  • JSON schemas and regular expressions are given as examples of constraints.
  • The team encourages users to try the package and provide feedback.
Start Chapter Summary
00:00 Introducing structured output The video introduces structured output as a new Transformers.js 4.3 feature requested by the community.
00:00 The NPM package and token processor A new NPM package enables a processor that hooks into token generation to enforce a required structure.
00:31 Schema examples and feedback The speaker demonstrates JSON schema and regex constraints, then invites viewers to try the package and share feedback.

One of the amazing new features in version 4.3 is structured output. — 00:00

we finally found a solution that works great with Transformers JS. — 00:00

So, here we have a JSON schema — 00:31

we would love to get your feedback, too. — 00:31

Transformers.js, structured output, npm, JSON Schema, regex, Hugging Face

00:00 One of the amazing new features in version 4.3 is structured output. Structured output has been requested by the community since quite some time, and now we finally found a solution that works great with Transformers JS. So, what you can see is that we have this new Transformers structured output package on NPM that allows you to build a new structured output processor. What it does, it basically hooks into the generation process of new tokens, and it makes sure that every new token actually follows the structure that we

00:31 want. So, here we have a JSON schema, so it needs to follow this JSON schema. And here we have a regex, so it needs to satisfy this this regex. So, it is available on NPM. Please try it out. We are super happy with how it turned out, but we would love to get your feedback, too.