Skip to content

Add Hugging Face Transformers extension by 0.2Studio#2547

Open
DDguan2010 wants to merge 3 commits into
TurboWarp:masterfrom
DDguan2010:master
Open

Add Hugging Face Transformers extension by 0.2Studio#2547
DDguan2010 wants to merge 3 commits into
TurboWarp:masterfrom
DDguan2010:master

Conversation

@DDguan2010

Copy link
Copy Markdown

Statement on AI Use

The code in this extension was partially drafted and refactored with the help of AI (OpenAI GPT-5/Codex) to accelerate development. All AI-generated portions were reviewed, tested, and corrected by human developers. I take full responsibility for the final code, which has been checked for correctness, security, and compliance with the TurboWarp extension gallery requirements.

Description

Add a new Hugging Face Transformers extension that allows TurboWarp projects to run Hugging Face Transformers.js models directly in the browser, including common NLP tasks and lower-level advanced model/pipeline/tokenizer/processor access.

Extension Details

  • Name: Hugging Face Transformers
  • ID: huggingfacetransformers
  • Slug: huggingface-transformers
  • Author: 0.2Studio
  • License: MPL-2.0

Features

  • Common AI task blocks — Use ready-to-run blocks for sentiment analysis, question answering, text generation, translation, summarization, fill-mask, zero-shot classification, and named entity recognition
  • Advanced model access — Load and reuse pipelines, models, tokenizers, and processors manually
  • Transformers.js integration — Loads the official Hugging Face Transformers.js browser bundle
  • Configurable execution — Supports custom model IDs, device, and dtype options
  • Progress reporting — Exposes loading status and last progress information
  • WebGPU detection — Includes a block to check whether WebGPU is supported
  • Chinese localization — Strings are integrated with the TurboWarp gallery translation system, with source-mode fallback for zh-cn

Blocks Overview

Category Examples
Quick Tasks Analyze sentiment, answer question from context, generate text, translate, summarize
Classification Text classification, zero-shot classification, named entity recognition
Language Modeling Fill mask, text generation
Advanced Runtime Load/run/release pipeline, model, tokenizer, processor
Diagnostics Transformers status, last loading progress, available dtypes, WebGPU supported

Files Included

File Purpose
extensions/huggingface-transformers.js Extension source code
images/huggingface-transformers.svg Extension cover image
docs/huggingface-transformers.md Extension documentation

Checklist

  • Extension code follows the gallery guidelines
  • Metadata comments are present
  • SPDX license identifier is valid (MPL-2.0)
  • Cover image is included and automatically detected by the gallery
  • Extension added to extensions/extensions.json
  • npm run validate passes
  • npm run lint passes
  • I have read the contribution guidelines

Notes

  • The extension is unsandboxed because it downloads model files and uses browser-side inference runtime features
  • It uses the official Hugging Face browser build of Transformers.js
  • Common task blocks use stable default models, while advanced blocks allow custom model IDs
  • Some model repositories may still fail at runtime if the upstream ONNX export or quantized weights are incompatible with the current browser/runtime combination
  • Translation strings are integrated into translations/extension-runtime.json and translations/extension-metadata.json

@DDguan2010 DDguan2010 requested review from a team and GarboMuffin as code owners June 27, 2026 16:28
@github-actions github-actions Bot added the pr: new extension Pull requests that add a new extension label Jun 27, 2026
@DDguan2010

Copy link
Copy Markdown
Author

!format

@Brackets-Coder

Copy link
Copy Markdown
Contributor

Probably not going to be merged for the same reasons as #2545

@Brackets-Coder

Brackets-Coder commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Also, description formatting looks almost identical to #2545 leading me to believe some kind of connection exists between the two (e.g., AI-generated description, although that's less of a concern than AI-generated code)

@DDguan2010

Copy link
Copy Markdown
Author

It's not like that. This is a member of my studio. After learning that his extension application was rejected, I decided to rewrite the extension based on the requirements you mentioned. This is an extension for running local models, which does not require a key and is a very good extension. I sincerely hope to be able to have a look.The similarity in the introduction is because I am a Chinese and my English proficiency is not so good. Therefore, I adopted his format and made some modifications. I hope you can understand.

@Brackets-Coder

Copy link
Copy Markdown
Contributor

While I like the idea of local LLMs in the browser, unfortunately they likely won't be very beneficial to our target audience. LLMs take a lot of RAM and even a small model with 4-bit quantization such as Gemma4:e4b (which is supposed to be able to run on modern smartphones) would likely max out the 8 GB of RAM on a chromebook

@Brackets-Coder

Copy link
Copy Markdown
Contributor

see this comment: #2486 (comment)

@DDguan2010

Copy link
Copy Markdown
Author

there are not only LLM`s in this extension,there are small models for analyzing/fill blanks/translating/labelling and so on.there are also some advanced blocks which you can load some models from HuggingFace for advanced use.We have already choosed the small and good ones for users to use,some of them are only 50~200MB.Please have a look,thanks.
image
image

@GarboMuffin

Copy link
Copy Markdown
Member

there's no issue with the idea of having a sentiment analysis extension or an on-device AI translation extension or a classification extension or whatever

the way this is being proposed isn't great though

from an extension design perspective, many of these use cases are very different and shouldn't just be in one big extension. the blocks also should not be returning JSON, they should be returning values that are useful on their own, not after being combined with 5 different blocks from the JSON extension to get something actually meaningful

there's also some technical issues with this extension as-is. even on my Reasonably Okay internet i'm finding myself waiting for minutes (!!) to fill in a plan for the first time. maybe that's fine for some uses, but likely all realistic projects that would want to use this extension would not find that OK.

(also note that ~1/3rd of TurboWarp users are on cheap Chromebooks)

see the face sensing extension for what i think is a pretty good use of "AI" in an extension - it's a couple megabyte model that does a very narrow task and does it well. we can ship that model in every copy of the desktop app and package it into projects automatically. works great. those things do not work so well when we're looking at massive language models unfortunately

anyway the point is mostly that people have proposed tens of versions of AI-as-an-extension. this is probably the closest one to being mergable just on account of it not requiring everybody to type in their OpenAI API key.

don't have an answer for you at this time on direction

@DDguan2010

Copy link
Copy Markdown
Author

ok got it.May I ask if it's possible to submit a extension for training AI model? For example, using TensorFlow.js to implement AI model training on the web page.

@Brackets-Coder

Copy link
Copy Markdown
Contributor

anyway the point is mostly that people have proposed tens of versions of AI-as-an-extension. this is probably the closest one to being mergable just on account of it not requiring everybody to type in their OpenAI API key.

Tend to agree. Any kind of AI extension for TurboWarp at this point must be local

ok got it.May I ask if it's possible to submit a extension for training AI model? For example, using TensorFlow.js to implement AI model training on the web page.

You could try, but you would probably have to implement it well and justify its use case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr: new extension Pull requests that add a new extension

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants