GifproGifpro

ブラウザでAI推論!Transformers.jsが動いた

VISTA DE CÓDIGO

エディタを読み込み中…
P

Prompt

Create a single HTML page that demonstrates running a Hugging Face Transformers model directly in the browser using Transformers.js. The page should load a small text classification model (e.g., distilbert-base-uncased-finetuned-sst-2-english) and allow the user to input a sentence and get a sentiment prediction (positive/negative) with confidence score. Show a loading indicator while the model is being downloaded and initialized. Use a clean, modern UI with a textarea, a predict button, and a result display area. Use CDN for Transformers.js and any necessary CSS/JS libraries.

このデモでは、Transformers.js を使用して Hugging Face の transformer モデルをブラウザ上で直接実行する方法を示します。モデル(distilbert-base-uncased-finetuned-sst-2-english)は完全にクライアント側でダウンロードされ実行されるため、バックエンドサーバーは不要です。ユーザーが英語の文を入力し、予測ボタンをクリックすると、感情(ポジティブまたはネガティブ)と信頼度スコアが表示されます。モデルの取得と初期化中はローディングインジケーターが表示されます。このアプローチは、プライバシーが重要なアプリケーションやオフライン対応の Web アプリに最適です。

¿Te resultó útil este prompt?

Comentarios

Los comentarios aparecen después de la moderación

この記事が役に立ったら投げ銭で応援

Apple Pay / Google Pay / カード (Visa/Mastercard/JCB/Amex) / Link / Alipay / WeChat Pay 対応 · Stripeで安全に決済

開発者が選ぶ最強ツール集

運営者が毎日使っているツール・ガジェット 6選

見る
Inicioヘルプ