ruri-v3-30m-tflite

English | 日本語

Model Summary

Unofficial LiteRT (.tflite) conversion of cl-nagoya/ruri-v3-30m (a general-purpose Japanese text-embedding model) for Android and other LiteRT runtimes. All credit for the original model goes to its authors.

  • Files: ruri-v3-30m_seq128.tflite, ruri-v3-30m_seq256.tflite, ruri-v3-30m_seq512.tflite (fixed sequence length, fp32, converted with litert-torch).

  • Inputs: input_ids and attention_mask, both int32 [1, seq] (pad to the fixed length with the tokenizer's pad id; the attention mask is respected in the graph).

  • Output: L2-normalized embedding [1, dim] (mean pooling is inside the graph; use the prefixes from the base model card, e.g. 検索クエリ: / 検索文書: ).

  • Verified on the LiteRT interpreter against PyTorch (see VERIFICATION below). Tokenizer files are copied from the base model; on-device tokenization: use the Kotlin UnigramTokenizer (exact Hugging Face ids on 450/450 fixtures) in japanese-rag-kotlin, which also provides LiteRtEmbedder / LiteRtReranker for these files.

  • Verified end to end on the Android emulator (API 36.1, arm64) with the Kotlin library (retrieval and reranking correct for the sample queries). Not included yet: quantized variants (fp16 / int8), the MediaPipe .task bundle, real-device latency numbers.

  • Live demo: Ruri Atlas — explore Japanese & English sentence embeddings as a 3-D map in your browser (WebGPU), switch embedding models, toggle the reranker, and see where a prompt-injection lands. Nothing is sent to a server.

Usage (Python, LiteRT interpreter)

import numpy as np
from ai_edge_litert.interpreter import Interpreter
from transformers import AutoTokenizer

tok = AutoTokenizer.from_pretrained("cl-nagoya/ruri-v3-30m")
text = "検索文書: 瑠璃色(るりいろ)は、紫みを帯びた濃い青のことである。"
enc = tok(text, padding="max_length", truncation=True, max_length=128, return_tensors="np")
it = Interpreter(model_path="ruri-v3-30m_seq128.tflite"); it.allocate_tensors()
i = it.get_input_details()
it.set_tensor(i[0]["index"], enc["input_ids"].astype(np.int32))
it.set_tensor(i[1]["index"], enc["attention_mask"].astype(np.int32))
it.invoke()
print(it.get_tensor(it.get_output_details()[0]["index"]))

Kotlin / Android (untested sketch): load the file with the LiteRT Interpreter, feed two IntArrays of the fixed length, read a FloatArray.

Security: see SECURITY.md (file audit by model-audit-lite). Related: japanese-llm-security hub. License: apache-2.0 (same as the base model).

Security

Audited against its upstream with model-audit-lite: weight format, bundled code, and a machine-readable lineage (ML-BOM). Details, checksums and how to reproduce: SECURITY.md.

モデルの概要

cl-nagoya/ruri-v3-30m(汎用の日本語テキスト埋め込みモデル)の、Androidなど LiteRT 向けの非公式な .tflite 変換です。元のモデルの著者に敬意を表します。

  • ファイル: ruri-v3-30m_seq128.tflite / _seq256 / _seq512(固定シーケンス長、fp32、litert-torch で変換)。
  • 入力: input_ids と attention_mask(どちらも int32 [1, seq]。固定長までパディング。attention mask はグラフ内で反映されます)。
  • 出力: L2正規化済みの埋め込み [1, 次元](平均プーリングはグラフ内。接頭辞は元モデルのカードに従い 検索クエリ: / 検索文書: など)。
  • LiteRT インタプリタで PyTorch と照合して検証済みです(下記 VERIFICATION)。トークナイザーのファイルは元モデルからのコピーで、端末上のトークナイズは、japanese-rag-kotlin のKotlin版 UnigramTokenizer(450件のフィクスチャでHugging Faceと同一ID)を使えます。このファイル用の LiteRtEmbedder / LiteRtReranker も同リポジトリにあります。
  • Androidエミュレータ(API 36.1、arm64)でKotlinライブラリとのエンドツーエンド動作を確認済みです(サンプルクエリの検索・再ランキングが正解)。未対応: 量子化版(fp16 / int8)、MediaPipe の .task、実機でのレイテンシ計測。

使い方は上の Python の例を参照してください。Kotlin / Android は、LiteRT の Interpreter で読み込み、固定長の IntArray を2つ渡して FloatArray を受け取る形です(未検証のスケッチ)。

セキュリティ: SECURITY.md(model-audit-lite によるファイル監査)を参照してください。関連: japanese-llm-security ハブ。 ライセンス: apache-2.0(元モデルと同じ)。

  • ライブデモ: Ruri Atlas — 日本語・英語の文の埋め込みを、ブラウザ上(WebGPU)で3Dの地図として見られます。埋め込みモデルの切り替え、リランカーのON/OFF、プロンプトインジェクションの効き方の可視化もできます。文章はサーバーに送られません。

セキュリティー

model-audit-lite で変換元と突き合わせて監査済みです(重みの形式、同梱コード、機械可読な系譜=ML-BOM)。詳細・チェックサム・再現方法は SECURITY.md をご覧ください。

Downloads last month
47
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for masahiroid/ruri-v3-30m-tflite

Finetuned
(4)
this model