Reasoning Vector

概要

Reasoning Vector は、ベースモデルとReasoningモデル間の重みの差分を抽出する手法により生成されたモデルです。 本モデルは、ChatVectorと同様の生成方法を採用しており、追加学習したベースモデルに対して推論能力(Reasoning)を追加するために使用されます。 単体では使用できません。

モデル

使用方法

以下は、ベースモデルにReasoning Vectorを適用して推論モデルを生成する際の例です。

from transformers import AutoModelForCausalLM, AutoTokenizer

# ベースモデルのロード
base_model = AutoModelForCausalLM.from_pretrained("your-base-model")
tokenizer = AutoTokenizer.from_pretrained("your-base-model")

# Reasoning Vectorのロード(差分パラメータ)
reasoning_vector = AutoModelForCausalLM.from_pretrained("HachiML/ReasoningVector-Mistral-Small-24B-Instruct-2501-reasoning")

# ベースモデルに差分を適用(実装に応じた適用方法を記載)
# 除外対象
skip_layers = ["model.embed_tokens.weight", "model.norm.weight", "lm_head.weight"]
for k, v in base_model.state_dict().items():
    # layernormも除外
    if (k in skip_layers) or ("layernorm" in k):
        continue
    new_v += reasoning_vector.state_dict()[k].to(v.device)
    v.copy_(new_v)

# 推論の実行例
inputs = tokenizer("推論したいテキストを入力", return_tensors="pt")
outputs = base_model.generate(**inputs)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
Downloads last month
5
Safetensors
Model size
23.6B params
Tensor type
BF16
·
Inference Providers NEW
This model is not currently available via any of the supported Inference Providers.
The model cannot be deployed to the HF Inference API: The model has no library tag.

Collection including HachiML/ReasoningVector-Mistral-Small-24B-Instruct-2501-reasoning