🤖 AIによる機械翻訳(非公式) — これは OpenCV 5.0.0 公式リファレンス(英語)を AI (Claude) で自動翻訳したものです。訳に誤りを含む場合があります。正確な情報は 公式英語版(原文) を参照してください。

クラス Tokenizer


  • public class Tokenizer extends java.lang.Object
    DNN 用途向けの高レベルなトークナイザのラッパー。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 long nativeObj  
    • コンストラクタの要約

      コンストラクタ
      Modifier Constructor Description
      protected Tokenizer​(long addr)  
    • フィールドの詳細

      • nativeObj

        protected final long nativeObj
    • コンストラクタの詳細

      • Tokenizer

        protected Tokenizer​(long addr)
    • メソッドの詳細

      • 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.json with field model_type with value "gpt2" or "gpt4". - tokenizer.json produced by the corresponding model family. The argument is a path prefix; this function concatenates file names directly (e.g. model_dir + "config.json"), so model_dir must 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 underlying CoreBPE::encode with an empty allowed-special set.
        引数:
        text - UTF-8 の入力文字列。
        戻り値:
        トークン ID のベクトル(利便性のため 32 ビット ID を int に縮小している)。
      • decode

        public java.lang.String decode​(MatOfInt tokens)