🤖 AIによる機械翻訳(非公式) — これは OpenCV 5.0.0 公式リファレンス(英語)を AI (Claude) で自動翻訳したものです。訳に誤りを含む場合があります。正確な情報は 公式英語版(原文) を参照してください。
Package org.opencv.dnn
クラス Tokenizer
- java.lang.Object
-
- org.opencv.dnn.Tokenizer
public class Tokenizer extends java.lang.ObjectDNN 用途向けの高レベルなトークナイザのラッパー。LLM 向けにトークンをエンコード・デコードするためのシンプルな API を提供する。モデルは Tokenizer::load() で読み込む。using namespace cv::dnn; Tokenizer tok = Tokenizer::load("/path/to/model/"); std::vector<int> ids = tok.encode("hello world"); std::string text = tok.decode(ids);
-
-
フィールドの要約
フィールド Modifier and Type Field Description protected longnativeObj
-
コンストラクタの要約
コンストラクタ Modifier Constructor Description protectedTokenizer​(long addr)
-
メソッドの要約
すべてのメソッド 静的メソッド インスタンスメソッド 具象メソッド Modifier and Type Method Description static Tokenizer__fromPtr__​(long addr)java.lang.Stringdecode​(MatOfInt tokens)MatOfIntencode​(java.lang.String text)Encode UTF-8 text to token ids (special tokens currently disabled).longgetNativeObjAddr()static Tokenizerload​(java.lang.String model_config)Load a tokenizer from a model directory.
-
-
-
メソッドの詳細
-
getNativeObjAddr
public long getNativeObjAddr()
-
__fromPtr__
public static Tokenizer __fromPtr__​(long addr)
-
load
public static Tokenizer load​(java.lang.String model_config)
Load a tokenizer from a model directory. Expects the directory to contain: -config.jsonwith fieldmodel_typewith value "gpt2" or "gpt4". -tokenizer.jsonproduced by the corresponding model family. The argument is a path prefix; this function concatenates file names directly (e.g.model_dir+ "config.json"), somodel_dirmust end with an appropriate path separator.- 引数:
model_config- モデルの config.json へのパス。- 戻り値:
- 使用可能な状態の Tokenizer。ファイルが見つからない場合や
model_typeがサポートされていない場合は cv::Exception をスローする。
-
encode
public MatOfInt encode​(java.lang.String text)
Encode UTF-8 text to token ids (special tokens currently disabled). Calls the underlyingCoreBPE::encodewith an empty allowed-special set.- 引数:
text- UTF-8 の入力文字列。- 戻り値:
- トークン ID のベクトル(利便性のため 32 ビット ID を int に縮小している)。
-
decode
public java.lang.String decode​(MatOfInt tokens)
-
-