Transformers documentation

JEV

You are viewing main version, which requires installation from source. If you'd like regular pip install, checkout the latest stable version (v5.22.2).
Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

このモデルは2026年11月9日にHugging Face Transformersに貢献されました。

JEV

決定モデル、decision パイプライン、および DecisionConfig は実験的な機能です。これらの API は、非推奨化なしにいつでも変更される可能性があります。

JEVは、プロンプトの最後のトークンにおいて線形層で単一トークンのラベルをスコアリングする決定ヘッドです。言語モデルヘッドのlogitsと同様にソフトキャップが適用されています。JEVによって導入され、GEVでも使用されています。

JevForDecisionは、チェックポイントのモデルとそのヘッドです。ForCausalLMがモデルとそのlm_headであるのと同じです。これは、チェックポイントがヘッドを同梱するファイルを読み取ります。これは重みの隣に配置されており、vLLMの決定モデルの場合はreadout.safetensorsとdecision_config.json、JEVの場合はhead.safetensorsとjudge_config.jsonです。

from transformers import pipeline

decide = pipeline("decision", model="autotrust/GEV-26B-Decide")
decide(
    {
        "state": "I was charged twice for my order and want a refund.",
        "questions": {"refund": {"type": "noul", "instructions": "Is a refund requested?"}},
    }
)

画像アセットについては、decision pipelineを参照してください。

パイプラインなしの場合、決定モデルはgenerateのように使用されます。決定設定がチャットテンプレートを使用して各質問ごとにプロンプト(またはすべてに共通のプロンプト)をレンダリングし、decideが各質問の選択肢をスコアリングし、Question.answerがスコアを回答に変換します。

from_pretrained は、サブフォルダーに LoRA を保持するチェックポイント(decision_config.adapter、例えば JEV の adapter/ など)の LoRA を読み込みません。パイプラインが代わりに読み込みますが、パイプラインを使わない場合は、以下のように自分で load_adapter を呼び出してください。そうしないと、モデルはベースの重みで応答します。

import torch
from transformers import AutoTokenizer, JevForDecision

repo = "autotrust/JEV-9B"
model = JevForDecision.from_pretrained(repo, dtype=torch.bfloat16, device_map="auto")
tokenizer, config = AutoTokenizer.from_pretrained(repo), model.decision_config  # read from the checkpoint's files
if config.adapter:  # JEV keeps its LoRA in a subfolder: `from_pretrained` doesn't load it, the pipeline does
    model.load_adapter(repo, adapter_kwargs={"subfolder": config.adapter})

request = {
    "state": "I was charged twice for my order and I want my money back today.",
    "questions": {
        "refund": {"type": "noul", "instructions": "Does the customer ask for a refund?"},
        "urgency": {"type": "score", "criteria": ["Can wait", "This week", "Today", "Now"]},
    },
}
answers = {}
for inputs, questions in config.prepare_inputs(request, tokenizer):
    scores = model.decide(**inputs, decision_questions=questions)
    answers |= {q.name: q.answer(s.softmax(-1).tolist()) for q, s in zip(questions, scores)}

同じヘッドが、pplx-deciderとd3の255個の回答コードを読み取ります。これらはQwen3.5のバックボーンを備えており、プロンプト全体にアテンションを向けます(JevForDecisionのtext_configでis_causal=False)。これらのヘッド(readout.safetensors)と設定(decision_config.json)は、重みと同様にそのまま読み込まれます:

pipeline("decision", model="vllm-sr/d3")(request)  # or perplexity-ai/pplx-decider-v1.1-27b

JevConfig

クラス transformers.JevConfig

< >

( transformers_version: str | None = Nonearchitectures: list[str] | None = Noneoutput_hidden_states: bool | None = Falsereturn_dict: bool | None = Truedtype: str | torch.dtype | None = Nonechunk_size_feed_forward: int = 0is_encoder_decoder: bool = Falseid2label: dict[int, str] | dict[str, str] | None = Nonelabel2id: dict[str, int] | dict[str, str] | None = Noneproblem_type: Literal['regression', 'single_label_classification', 'multi_label_classification'] | None = Nonehidden_size: int = 4096num_verbalizers: int = 24offsets: dict[str, int] | None = Nonesoftcap: float | None = Nonetext_config: dict | transformers.configuration_utils.PreTrainedConfig | None = Noneinitializer_range: float = 0.02 )

パラメータ

  • hidden_size (int、任意、デフォルトは 4096) — 隠れ表現の次元数。
  • num_verbalizers (int、任意、デフォルトは 24) — すべての質問タイプにおいて、ヘッドによってスコアリングされる単一トークンラベルの数。
  • offsets (dict[str, int]、任意、デフォルトは {"noul" -- 0, "score": 2, "choice": 8}): 各質問タイプの最初のラベルの行: 質問の選択肢は、offsets[question.type] 以降の行で、順番にスコアリングされます。
  • softcap (float, 任意) — スコアのソフトキャップ、softcap * tanh(scores / softcap)。言語モデルヘッドの logits と同様の処理です。
  • text_config (dict または PreTrainedConfig、省略可) — ヘッドが読み取るモデルの設定、つまりそのリポジトリのconfig.jsonです。
  • initializer_range (float、任意、デフォルトは 0.02) — すべての重み行列を初期化するための truncated_normal_initializer の標準偏差です。

これは JevModel の設定を保存するための設定クラスです。指定された引数に基づいて Jev モデルをインスタンス化し、モデルのアーキテクチャを定義するために使用されます。デフォルト値で設定をインスタンス化すると、autotrust/JEV-9B と同様の設定が得られます。

設定オブジェクトはPreTrainedConfigを継承し、モデルの出力を制御するために使用できます。詳細については、PreTrainedConfigのドキュメントを参照してください。

例:

>>> from transformers import JevConfig, JevForDecision

>>> model = JevForDecision(JevConfig(hidden_size=4096))

decision_config

< >

( head_configs: dicttext_config: dict )

decision設定は、重みとJEVヘッドを一緒に提供するチェックポイントの、その設定ファイルから取得されます。

JevForDecision

クラス transformers.JevForDecision

< >

( config: JevConfig )

パラメータ

  • config (JevConfig) — モデルのパラメータをすべて含むモデル設定クラスです。設定ファイルで初期化しても、モデルに関連する重みは読み込まれず、設定のみが読み込まれます。モデルの重みをロードするには、from_pretrained() メソッドを参照してください。

JEV (autotrust/JEV-9B): リポジトリのモデルと決定ヘッド。各質問の<|mark|>の直前のトークンにおける、単一トークンラベルの線形スコア。言語モデルヘッドのlogitsと同様にソフトキャップが適用されています。

このモデルは PreTrainedModel を継承しています。すべてのモデルに実装されている汎用的なメソッド(ダウンロードや保存、入力埋め込みのリサイズ、ヘッドのプルーニングなど)については、スーパークラスのドキュメントを参照してください。

このモデルは、PyTorchのtorch.nn.Moduleのサブクラスでもあります。 通常のPyTorch Moduleとして使用し、一般的な使用方法や動作に関する詳細については、PyTorchのドキュメントを参照してください。

forward

< >

( input_ids: LongTensormarks: LongTensornum_options: LongTensorquestion_type_ids: LongTensor**kwargs )

パラメータ

  • input_ids (torch.LongTensor の形状 (batch_size, sequence_length)) — 語彙における入力シーケンスのトークンインデックスです。デフォルトでは、パディングは無視されます。

    インデックスはAutoTokenizerを使用して取得できます。詳細については、PreTrainedTokenizer.encode()およびPreTrainedTokenizer.call()を参照してください。

    入力IDとは何ですか?

  • marks (torch.LongTensor、形状 (num_marks,)) — 決定テンプレートの <|mark|> によって記録された位置: それぞれのマークの前のプロンプトのトークン数。
  • num_options (torch.LongTensor、形状 (num_questions,)) — プロンプトの各質問の選択肢の数。
  • question_type_ids (torch.LongTensor、形状 (num_questions,)) — プロンプトの各質問のタイプを、Question.questions_types におけるインデックスとして表したものです。

JevForDecisionのforwardメソッドは、__call__特殊メソッドをオーバーライドします。

この関数内でフォワードパスの手順を定義する必要がありますが、その後、この関数ではなくModuleインスタンスを呼び出すべきです。前者は前処理と後処理の実行を適切に処理するのに対し、後者はそれらを黙って無視するためです。

Update on GitHub