← All models

text-classification · text · WASM · ~156 MB

Japanese WRIME emotion — the feeling behind Japanese text

Most emotion models only read English, and most Japanese BERTs can't even run in a browser — they need a MeCab morphological analyser the browser doesn't have. This one is different on both counts: it's a Japanese-native model (Ruri v3, a Japanese ModernBERT) fine-tuned on WRIME, the Japanese emotion corpus, and its tokenizer is SentencePiece — so it runs fully on your device. Type Japanese below and it scores the text across Plutchik's eight emotions: 喜び joy, 悲しみ sadness, 期待 anticipation, 驚き surprise, 怒り anger, 恐れ fear, 嫌悪 disgust, 信頼 trust. Watch the real probabilities, and look inside to see how it reads a spaceless sentence.

At a glance

Modelarajun/ruri-v3-30m-wrime-onnx (ONNX build of a WRIME fine-tune of cl-nagoya/ruri-v3-pt-30m)
Base modelcl-nagoya/ruri-v3-pt-30m — Ruri v3, a Japanese ModernBERT encoder (30M params)
Task / pipelinetext-classification — eight emotion classes, loaded via AutoModelForSequenceClassification for raw logits
OutputA softmax over 8 emotions (Plutchik): joy · sadness · anticipation · surprise · anger · fear · disgust · trust
How it worksModernBERT encodes the Japanese text; a small classification head predicts the 8-way distribution
LanguageJapanese only — trained on WRIME (SNS posts annotated for the writer's emotion)
TokenizerSentencePiece (tokenizer.json + tokenizer.model) — no MeCab/fugashi, so it runs client-side; splits a spaceless sentence into subword pieces
Quantizationfp32 — the page runs the full-precision model.onnx (WebAssembly has no fp16 compute kernel, so the fp16 export can't run on this backend)
BackendWebAssembly (runs anywhere; no WebGPU needed)
Download~156 MB (fp32 graph + SentencePiece model), cached after first load
LicenseNot formally specified on the export (research model; the base Ruri v3 is Apache-2.0 · WRIME is a research corpus)
Web APIsWebAssembly, Web Workers — all Baseline widely available

Run it

Type or paste Japanese, or pick a sample. The emotion verdict updates as you type; the bars show the full eight-way split.

See inside — subword pieces & which of them moved the emotion

Japanese is written without spaces, so the first thing the model does is split your sentence into SentencePiece pieces — the dashed chips below marked ▁ are where the tokenizer decided a new unit begins. This is the step a MeCab-based Japanese BERT would need a native analyser for; SentencePiece does it in pure WebAssembly, which is why this model runs in a tab.

To make the model's reasoning legible we run occlusion attribution: re-score the text with each piece removed and measure how far the winning emotion's confidence drops (in log-odds). A piece tinted in the emotion's colour was pushing that emotion; a grey piece was pulling against it. Because the tokenizer — not a word list — decides the units, it works on Japanese with no segmentation heuristics.

Analyse some text, then explain it to inspect per-piece attribution.

Why it matters

Sentiment as "positive / negative" throws away most of what a message carries. The difference between an angry complaint, a fearful one and a disgusted one changes how you'd route or answer it — and in Japanese, where politeness and indirection hide a lot of the signal, a model trained on Japanese social text reads cues a translated English model misses. That this one runs entirely on-device means emotion analysis of private Japanese text — reviews, DMs, support threads — never has to leave the browser.

Use cases

Basics

One Japanese sentence, the full eight-emotion split with probabilities and the raw logits behind them.

Practical

Paste a batch of Japanese reviews or messages and get an emotion-sorted, colour-coded board.

Wild

An emotion tug-of-war: edit a sentence word by word and watch the winning emotion flip in real time.

Multi-model

Eight-way Japanese emotion vs three-way multilingual polarity — run both on the same text and compare.

How the API works

The one-liner uses the text-classification pipeline:

import { pipeline } from "@huggingface/transformers";

const clf = await pipeline(
  "text-classification",
  "arajun/ruri-v3-30m-wrime-onnx",
  { dtype: "fp32" },
); // downloads + caches ~156 MB once

const out = await clf("今日はとても嬉しい気分です。", { top_k: 8 });
// → [{ label: "喜び", score: 0.93 }, { label: "信頼", score: 0.04 }, … ]

For the "see inside" surface we load one level lower — AutoModelForSequenceClassification — so we can read the exact logits tensor ([1, 8]), softmax it ourselves to show every emotion's probability plus its raw logit, and reuse the loaded instance to re-score occluded variants for per-piece attribution. All of it runs in a Web Worker so the page never janks. The model loads with dtype: "fp32" because the WebAssembly backend has no fp16 compute kernel.

References