Downloads · 30 days
208
16% of all-time downloads
ikedachin/llm-jp-4-8b-thinking_imabari_qa_v4_reasoning_effort_v2
llm-jp-4-8b-thinking_imabari_qa_v4_reasoning_effort_v2 is a text generation model from ikedachin. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as other.
日本語の説明は下にあります。 Japanese description is available below.
Downloads · 30 days
208
16% of all-time downloads
All-time downloads
1.3K
Public
Parameters
8.6B
17.2 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors17.2 GB · 100%
From the Hugging Face model README
日本語の説明は下にあります。
Japanese description is available below.
This model is a fully merged model created by taking llm-jp/llm-jp-4-8b-thinking as the base model.
It is fine-tuned using QA data containing both Imabari dialect and standard Japanese reasoning text and answers. A custom chat template provides the analysis_imabari and final_imabari channels alongside the standard analysis and final channels.
This repository contains the merged full model, not a LoRA adapter.
Therefore, you do not need to load the base model separately at inference time.
llm-jp/llm-jp-4-8b-thinkingThe only change from v1 is the training dataset:
| Version | Training data |
|---|---|
| v1 | Imabari dialect only |
| v2 | Imabari dialect and standard Japanese |
The base model, training method, hyperparameters, custom chat template, merged-model format, and license notices are unchanged from v1. Adding standard Japanese data does not by itself establish improved style control; no v2 evaluation results are reported in this card.
v2 uses the following two datasets, containing Imabari dialect and standard Japanese QA respectively:
| Style | Dataset | License |
|---|---|---|
| Imabari dialect | ikedachin/imabari_wiki_qa_v4_reasoning_effort_llmjp4 | CC BY-SA 4.0 |
| Standard Japanese | ikedachin/std_lang_wiki_qa_v4_validated_w_reasoning_effort_llmjp4 | CC BY-SA 4.0 |
The Imabari dataset is the one listed in the v1 model card. The standard Japanese dataset is derived from it by converting thinking and answer into standard Japanese while retaining the questions and reasoning-effort labels. The conversion is intended to preserve meaning, conclusions, and supporting information.
QA data is formatted using the same custom chat template as v1, supporting the standard analysis / final and Imabari analysis_imabari / final_imabari channels. The final training/validation sizes and mixing ratio for this model are not specified here.
The standard Japanese dataset was re-split independently of its source. When evaluating the combined data, check for shared source QA and articles across training and validation splits.
This model was created through the following process:
The model was fine-tuned with the following settings:
| Setting | Value |
|---|---|
| Epochs | 1 |
| Learning rate | 1e-4 |
| Maximum sequence length | 8,192 tokens |
| Per-device training batch size | 2 |
| Gradient accumulation steps | 8 |
| Optimizer | AdamW (adamw_torch) |
| Learning-rate scheduler | Cosine |
| Warmup steps | 0 |
| Weight decay | 0.01 |
| LoRA rank / alpha / dropout | 8 / 16 / 0.0 |
| LoRA target modules | q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj |
| Gradient checkpointing | Enabled |
| Packing | Disabled |
Reasoning-effort handling: All training prompts use Reasoning: medium, regardless of the original low, medium, or high label in the dataset. The inference template accepts all three values, but this training does not establish learning of the intended three-level conditioning.
torch.float16pip install transformers torch accelerate
Use the merged model directory, or replace model_name below with your uploaded Hugging Face repository ID. Always load the Tokenizer distributed with this fine-tuned model, because it contains the modified chat template.
The following example assumes an environment with sufficient memory for FP16 inference, such as the GPU environment used for training.
The following describes the official chat template for llm-jp-4-8b-thinking, before the modifications made for this model.
analysis, commentary, and final as a fixed set of channels. The official template does not read a valid_channels argument.analysis for reasoning and final for answers. It reads reasoning from thinking and the answer from content; historical reasoning is normally omitted during inference.reasoning_effort is an existing LLM-jp-4 template option. It supplies the value in Reasoning: ... and defaults to "medium".add_generation_prompt=True is a Transformers option used by the official template. The official template appends <|start|>assistant; it does not use generate_thinking, thinking_channel, or channel to choose a starting channel.Thus, the default channel names and reasoning-effort option come from LLM-jp-4. The configurable channel list and explicit starting-channel controls described next are modifications made for this fine-tuned model.
This model's chat template has been modified to add valid_channels, making the previously fixed channel list in the system prompt configurable. The modifications also introduce the Imabari-dialect channel names analysis_imabari and final_imabari, along with controls for selecting the generation-start header.
| Added option | Behavior in this model's template |
|---|---|
valid_channels | Replaces the fixed channel list with the supplied names. If omitted, it starts from analysis, commentary, and final. The template also inserts user and commentary when missing. This is prompt text, not a decoding constraint. |
generate_thinking | With True, starts in thinking_channel. With False or when omitted, starts in channel. This applies when add_generation_prompt=True. |
thinking_channel | Selects the initial reasoning channel; defaults to "analysis". Use "analysis_imabari" for Imabari reasoning. |
channel | Selects the initial answer channel when generate_thinking=False; defaults to "final". Use "final_imabari" for an Imabari answer. |
The template retains the existing reasoning_effort option. The names analysis_imabari and final_imabari, and the arguments in the table above, are features of this repository's modified template, not additional standard LLM-jp-4 API options. Load this model's saved Tokenizer to use them.
The channel list and the starting channel are separate settings. valid_channels tells the model which channel names are available. thinking_channel or channel determines the header appended to the prompt. Setting only valid_channels does not change the starting channel.
This model's chat template also simplifies the official template for QA: it retains supplied historical reasoning, uses a fixed date, and does not include the official tool-call rendering. Selecting analysis and final in this modified template does not restore the complete official template behavior.
First choose the channel list with valid_channels. Then choose whether to start with reasoning, and explicitly select the starting channel.
| Requested style | valid_channels |
|---|---|
| Imabari channels | ["analysis_imabari", "final_imabari", "commentary"] |
| Standard channels | ["analysis", "final", "commentary"] |
| Both sets available | ["analysis", "final", "analysis_imabari", "final_imabari", "commentary"] |
These are suggested lists for this modified template. Keep role="assistant" for assistant messages; a channel does not replace the role.
For example, the Imabari list produces the following system-prompt declaration. user is inserted by the template:
# Valid channels: user, analysis_imabari, final_imabari, commentary. Channel must be included for every message.
Next, select the starting header. All rows below assume add_generation_prompt=True and use this model's modified template.
| Requested start | generate_thinking | thinking_channel | channel | Prompt suffix |
|---|---|---|---|---|
| Imabari reasoning | True | "analysis_imabari" | Not used | <|start|>assistant<|channel|>analysis_imabari<|message|> |
| Standard reasoning | True | "analysis" | Not used | <|start|>assistant<|channel|>analysis<|message|> |
| Imabari answer directly | False | Not used | "final_imabari" | <|start|>assistant<|channel|>final_imabari<|message|> |
| Standard answer directly | False | Not used | "final" | <|start|>assistant<|channel|>final<|message|> |
When generate_thinking=True, channel="final_imabari" does not force the later answer channel. The initial header uses only thinking_channel; the model generates subsequent channel transitions. To start directly in final_imabari, set generate_thinking=False and channel="final_imabari".
The following inference example uses the added Imabari controls together with the inherited reasoning_effort option. These prompt settings do not guarantee dialect consistency. See Reasoning-effort handling above for what this training run actually conditioned on.
This example prints the formatted prompt, input IDs, generated IDs before decoding, and decoded text with and without special tokens. The same chat_kwargs are used for prompt display and tokenization.
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
model_name = "ikedachin/llm-jp-4-8b-thinking_imabari_qa_v4_reasoning_effort_v2"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(
model_name,
dtype=torch.float16,
device_map="auto",
)
model.eval()
messages = [{"role": "user", "content": "今治の特産品について教えてください。"}]
chat_kwargs = {
# Existing LLM-jp-4 / Transformers options
"reasoning_effort": "medium", # "low", "medium", "high"
"add_generation_prompt": True,
# Options added in this model's modified template
"valid_channels": ["analysis_imabari", "final_imabari", "commentary"],
"generate_thinking": True,
"thinking_channel": "analysis_imabari",
"channel": "final_imabari", # Used when generate_thinking=False
}
# 1. Formatted prompt
prompt = tokenizer.apply_chat_template(messages, tokenize=False, **chat_kwargs)
print("=== Prompt ===")
print(prompt)
# 2. Tokenize
inputs = tokenizer.apply_chat_template(
messages,
tokenize=True,
return_tensors="pt",
return_dict=True,
**chat_kwargs,
)
print("=== Input token IDs ===")
print(inputs["input_ids"][0].tolist())
inputs = {key: value.to(model.device) for key, value in inputs.items()}
# 3. Generate
with torch.inference_mode():
output_ids = model.generate(
**inputs,
max_new_tokens=512,
do_sample=False,
pad_token_id=tokenizer.eos_token_id,
)
# output_ids includes the prompt
input_length = inputs["input_ids"].shape[1]
generated_ids = output_ids[0, input_length:]
# 4. Before decode
print("=== Full output token IDs (prompt + generation) ===")
print(output_ids[0].tolist())
print("=== Generated token IDs only ===")
print(generated_ids.tolist())
# 5. After decode
raw_text = tokenizer.decode(generated_ids, skip_special_tokens=False)
text = tokenizer.decode(generated_ids, skip_special_tokens=True)
print("=== Generated text: special tokens kept ===")
print(raw_text)
print("=== Generated text: special tokens removed ===")
print(text)
# 6. Entire conversation
print("=== Full conversation: special tokens kept ===")
print(tokenizer.decode(output_ids[0], skip_special_tokens=False))
To try another row of the channel table, change chat_kwargs and rerun from the prompt creation step. For example, set "generate_thinking": False and "channel": "final_imabari" to start directly in the Imabari answer channel.
output_ids is a two-dimensional tensor with a batch dimension. output_ids[0] contains the prompt plus generated tokens; generated_ids contains only the new tokens. .tolist() displays their integer IDs.skip_special_tokens=False: Special-token markers remain visible, making message boundaries and channel transitions easier to inspect.skip_special_tokens=True: Registered special tokens are removed. This does not extract only the final answer: reasoning text, role names, and channel names may remain.In this template, <|start|>, <|channel|>, <|message|>, <|end|>, and <|return|> delimit messages, headers, and turn endings. Names such as analysis_imabari are text between these markers. The initial assistant header is already part of the input, so it does not appear at the start of raw_text, which decodes only newly generated tokens. Decode output_ids[0] to see that header too. For multiple sequences, use tokenizer.batch_decode(output_ids, ...).
To start generation in the standard reasoning channel, replace chat_kwargs in the inference example with the following and rerun from prompt creation:
chat_kwargs = {
"reasoning_effort": "medium",
"add_generation_prompt": True,
"valid_channels": ["analysis", "final", "commentary"],
"generate_thinking": True,
"thinking_channel": "analysis",
"channel": "final", # Used when generate_thinking=False
}
To start directly in the standard answer channel, set generate_thinking=False. These settings select prompt channels; they do not guarantee the language style of the generated text. v1 output samples are not reproduced as v2 results.
In this modified template, for previous assistant messages, put thinking_channel and channel inside each message dictionary. These fields format existing history. The top-level arguments to apply_chat_template select the header for the next generation and do not rewrite historical messages.
# Illustrative history
history = [
{"role": "user", "content": "今治の特産品について教えてください。"},
{
"role": "assistant",
"thinking_channel": "analysis_imabari",
"thinking": "今治の特産品として、タオルについて答えるんよ。",
"channel": "final_imabari",
"content": "今治タオルが有名なんよ。",
},
{"role": "user", "content": "もう少し詳しく教えてください。"},
]
print(tokenizer.apply_chat_template(history, tokenize=False, **chat_kwargs))
The template formats a nonempty thinking field as a reasoning message and content as an answer message. If the per-message channels are omitted, it uses analysis and final. For history containing an answer only, omit thinking and retain the answer's channel. Setting generate_thinking=False affects the next generation header; it does not remove reasoning already present in history.
References: Transformers chat templates, Tokenizer decoding API.
Channel-based style control: v1 reported frequent Imabari-dialect output even with standard channels. v2 adds standard Japanese to the training data, but this card reports no evaluation establishing how reliably v2 separates the two styles.
Current date: 2026-09-19 string. It does not automatically reflect the inference date.本モデルは、llm-jp/llm-jp-4-8b-thinking をベースモデルとしています。
今治弁と標準語の両方の思考文・回答を含むQAデータでファインチューニングしています。独自のチャットテンプレートにより、標準の analysis / final に加えて、今治弁用の analysis_imabari / final_imabari チャネルを指定できます。
このリポジトリには LoRAアダプタではなく、マージ済みモデル本体 が含まれています。
そのため、推論時にベースモデルを別途読み込む必要はありません。
llm-jp/llm-jp-4-8b-thinkingv1 から変更したのは、学習データセットのみです。
| バージョン | 学習データ |
|---|---|
| v1 | 今治弁のみ |
| v2 | 今治弁と標準語 |
ベースモデル、学習方法、ハイパーパラメータ、独自チャットテンプレート、マージ済みモデルとしての提供形式、ライセンス表記はv1と同じです。標準語データの追加による文体の切り替え性能の改善を保証するものではなく、このカードではv2の評価結果は掲載していません。
v2では、以下の今治弁と標準語の2種類のQAデータセットを使用しています。
| 文体 | データセット | ライセンス |
|---|---|---|
| 今治弁 | ikedachin/imabari_wiki_qa_v4_reasoning_effort_llmjp4 | CC BY-SA 4.0 |
| 標準語 | ikedachin/std_lang_wiki_qa_v4_validated_w_reasoning_effort_llmjp4 | CC BY-SA 4.0 |
今治弁データセットはv1のモデルカードに記載されたものです。標準語データセットは、その thinking(思考文)と answer(最終回答)を標準語の「です・ます調」に変換した派生版です。質問と reasoning effort ラベルを引き継ぎ、元の意味・結論・根拠を保持する方針で変換されています。
QAデータの整形には、v1と同じ独自チャットテンプレートを使用します。このテンプレートは標準の analysis / final と今治弁用の analysis_imabari / final_imabari に対応しています。本モデルで実際に使用した最終的な学習件数・検証件数・混合比率は、本カードでは記載していません。
標準語版は派生元と独立して再分割されています。両データセットを併用した評価では、学習用と検証用の間に同じ元QAや記事が含まれていないか確認が必要です。
本モデルは以下の流れで作成しています。
2e-4、最大系列長8,192トークン、デバイスあたりのバッチサイズ2、勾配累積8reasoning effort の扱い: 学習時のプロンプトは、元データの low・medium・high のラベルにかかわらず、すべて Reasoning: medium に統一しています。推論時には3段階を指定できますが、この学習によって意図した3段階の条件付けを獲得したことを示すものではありません。
torch.float16pip install transformers torch accelerate
マージ済みモデルの保存先、またはアップロード先の Hugging Face リポジトリIDを指定します。独自チャットテンプレートを使うため、ベースモデルのTokenizerではなく、この学習済みモデルに付属するTokenizerを読み込んでください。 以下のコードは、学習時のGPU環境など、FP16でモデルを読み込める十分なメモリがある環境を想定しています。
まず、今回の改造前にあたる llm-jp-4-8b-thinking の公式チャットテンプレート の動作を説明します。
analysis・commentary・final に固定されています。公式テンプレートは valid_channels 引数を参照しません。analysis、回答に final を使います。思考文はメッセージ内の thinking、回答は content から読み込みます。推論時の過去の思考文は、通常は履歴に展開されません。reasoning_effort は LLM-jp-4にもともとある設定です。システムプロンプトの Reasoning: ... に値を設定し、省略時は "medium" になります。add_generation_prompt=True は、公式テンプレートでも使われるTransformersの指定です。公式テンプレートが付ける末尾は <|start|>assistant までで、generate_thinking・thinking_channel・channel による開始チャネルの指定は行いません。つまり、標準のチャネル名や reasoning effort の指定はLLM-jp-4由来です。次に説明する「チャネル一覧の変更」と「生成開始チャネルの指定」は、今回のモデル用に加えた改造です。
このモデルのチャットテンプレートを改変し、固定だったシステムプロンプトのチャネル一覧を変更できるよう、valid_channels を追加しています。あわせて、今治弁用のチャネル名 analysis_imabari・final_imabari と、生成開始ヘッダーを選ぶ設定を追加しました。
| 追加した設定 | 今回のテンプレートでの動作 |
|---|---|
valid_channels | システムプロンプトのチャネル一覧を、指定した名前に変更します。省略時は analysis・commentary・final を使います。また、user と commentary がなければ自動で補います。プロンプトへの記載であり、生成トークンを強制的に制限する設定ではありません。 |
generate_thinking | True なら thinking_channel、False または省略時は channel から生成を開始します。add_generation_prompt=True の場合に使われます。 |
thinking_channel | 生成開始時の思考チャネルを選びます。省略時は "analysis"。今治弁の思考から始める場合は "analysis_imabari" を指定します。 |
channel | generate_thinking=False のとき、生成開始時の回答チャネルを選びます。省略時は "final"。今治弁の回答から始める場合は "final_imabari" を指定します。 |
既存の reasoning_effort は引き続き利用できます。一方、analysis_imabari・final_imabari という名前と、上表の引数は、このリポジトリの改造テンプレートで使う機能です。LLM-jp-4の標準APIに追加されたものではないため、このモデルに保存されたTokenizerを読み込んで使用してください。
チャネル一覧と、開始チャネルは別の指定です。 valid_channels は「利用可能なチャネル名」をモデルに伝え、thinking_channel または channel は「入力末尾に付ける生成開始ヘッダー」を決めます。valid_channels だけを変更しても、開始チャネルは変わりません。
また、今回のテンプレートはQA向けに簡略化しており、履歴に渡した思考文を保持し、日付を固定しています。公式のツール呼び出し用の整形処理は含めていません。この改造テンプレートで analysis・final を指定しても、公式テンプレート全体の動作に戻るわけではありません。
最初に valid_channels でチャネル一覧を選びます。続いて、思考から始めるかどうかと、実際に開始するチャネルを指定します。
| 使用したいチャネル | valid_channels |
|---|---|
| 今治弁用 | ["analysis_imabari", "final_imabari", "commentary"] |
| 標準チャネル用 | ["analysis", "final", "commentary"] |
| 両方を利用可能にする | ["analysis", "final", "analysis_imabari", "final_imabari", "commentary"] |
上表は、この改造テンプレートで使う指定例です。assistantメッセージの role は "assistant" のままにします。チャネル名を role に指定するものではありません。
例えば今治弁用の一覧を渡すと、システムプロンプトには次の宣言が入ります。user はテンプレート側で補われます。
# Valid channels: user, analysis_imabari, final_imabari, commentary. Channel must be included for every message.
次に、生成開始ヘッダーを指定します。以下はすべて 今回の改造テンプレートで add_generation_prompt=True にした場合の動作です。
| 開始したい形式 | generate_thinking | thinking_channel | channel | プロンプト末尾 |
|---|---|---|---|---|
| 今治弁の思考 | True | "analysis_imabari" | 使用されない | <|start|>assistant<|channel|>analysis_imabari<|message|> |
| 標準の思考 | True | "analysis" | 使用されない | <|start|>assistant<|channel|>analysis<|message|> |
| 今治弁の回答から | False | 使用されない | "final_imabari" | <|start|>assistant<|channel|>final_imabari<|message|> |
| 標準の回答から | False | 使用されない | "final" | <|start|>assistant<|channel|>final<|message|> |
generate_thinking=True のとき、channel="final_imabari" は思考後の回答チャネルを強制しません。 開始ヘッダーには thinking_channel だけが使われ、その後のチャネル遷移はモデルが生成します。final_imabari から直接始めたい場合は、generate_thinking=False と channel="final_imabari" を指定します。
次の推論例では、追加した今治弁用の設定と、標準から引き継いだ reasoning_effort を組み合わせています。これらのプロンプト指定は、方言表現の一貫性を保証するものではありません。今回の学習で reasoning effort をどのように扱ったかは、前述の 学習方法 を参照してください。
以下では、整形済みプロンプト、入力トークンID、decode前の生成トークンID、特殊トークンを残した出力・除いた出力を順に表示します。表示用と推論用で条件が変わらないよう、同じ chat_kwargs を使います。
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
model_name = "ikedachin/llm-jp-4-8b-thinking_imabari_qa_v4_reasoning_effort_v2"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(
model_name,
dtype=torch.float16,
device_map="auto",
)
model.eval()
messages = [{"role": "user", "content": "今治の特産品について教えてください。"}]
chat_kwargs = {
# LLM-jp-4・Transformersの既存の設定
"reasoning_effort": "medium", # "low", "medium", "high"
"add_generation_prompt": True,
# 今回の改造テンプレートで追加した設定
"valid_channels": ["analysis_imabari", "final_imabari", "commentary"],
"generate_thinking": True,
"thinking_channel": "analysis_imabari",
"channel": "final_imabari", # generate_thinking=False のときに使用
}
# 1. モデルに渡すプロンプト文字列
prompt = tokenizer.apply_chat_template(messages, tokenize=False, **chat_kwargs)
print("=== 入力プロンプト ===")
print(prompt)
# 2. プロンプトをトークンIDに変換
inputs = tokenizer.apply_chat_template(
messages,
tokenize=True,
return_tensors="pt",
return_dict=True,
**chat_kwargs,
)
print("=== 入力トークンID ===")
print(inputs["input_ids"][0].tolist())
inputs = {key: value.to(model.device) for key, value in inputs.items()}
# 3. 続きのトークンを生成
with torch.inference_mode():
output_ids = model.generate(
**inputs,
max_new_tokens=512,
do_sample=False,
pad_token_id=tokenizer.eos_token_id,
)
# output_idsには入力プロンプトも含まれる
input_length = inputs["input_ids"].shape[1]
generated_ids = output_ids[0, input_length:]
# 4. decode前:整数のトークンID列
print("=== 入力と生成を含むトークンID ===")
print(output_ids[0].tolist())
print("=== 生成部分のみのトークンID ===")
print(generated_ids.tolist())
# 5. decode後:生成部分のみを文字列に戻す
raw_text = tokenizer.decode(generated_ids, skip_special_tokens=False)
text = tokenizer.decode(generated_ids, skip_special_tokens=True)
print("=== 生成テキスト:特殊トークンあり ===")
print(raw_text)
print("=== 生成テキスト:特殊トークンなし ===")
print(text)
# 6. 入力と生成をまとめて確認
print("=== 会話全体:特殊トークンあり ===")
print(tokenizer.decode(output_ids[0], skip_special_tokens=False))
別の形式を試す場合は、chat_kwargs を変更してプロンプト生成から再実行します。例えば "generate_thinking": False、"channel": "final_imabari" にすると、今治弁の回答チャネルから開始します。
output_ids はバッチ次元を持つ2次元のテンソルです。output_ids[0] は入力と生成の両方を含み、generated_ids は新しく生成された部分だけです。.tolist() で整数のID列を表示します。skip_special_tokens=False でdecode: メッセージ区切りなどの特殊トークンが残るため、チャネル遷移を確認できます。skip_special_tokens=True でdecode: 登録済みの特殊トークンを取り除きます。最終回答だけを抽出する処理ではありません。 思考本文や assistant、final_imabari などの通常の文字列が残る場合があります。このテンプレートでは、<|start|> はメッセージ開始、<|channel|> はチャネル指定、<|message|> は本文開始、<|end|> はメッセージ終了、<|return|> はassistantターンの終了を表します。analysis_imabari などの名前は、その間に置かれる文字列です。最初のassistantヘッダーは入力側に含まれるため、生成部分だけをdecodeした raw_text の先頭には出ません。開始チャネルも含めて確認するには output_ids[0] をdecodeします。複数系列をまとめて文字列に戻す場合は tokenizer.batch_decode(output_ids, ...) を使います。
標準の思考チャネルから生成を開始するには、推論例の chat_kwargs を次のように変更して、プロンプト生成から再実行します。
chat_kwargs = {
"reasoning_effort": "medium",
"add_generation_prompt": True,
"valid_channels": ["analysis", "final", "commentary"],
"generate_thinking": True,
"thinking_channel": "analysis",
"channel": "final", # generate_thinking=False のときに使用
}
標準の回答チャネルから直接開始する場合は、generate_thinking=False に変更します。これらはプロンプトのチャネルを指定する設定であり、生成される文章の文体を保証するものではありません。v1の生成例をv2の実測結果として掲載することはしていません。
今回の改造テンプレートでは、過去のassistantメッセージに対して、thinking_channel と channel を各メッセージの辞書内に指定します。これは履歴の整形に使う値です。apply_chat_template の引数として渡す同名の値は、次に生成するヘッダー用で、過去のメッセージのチャネルを書き換えません。
# 会話履歴の形式例(モデルの実測出力ではありません)
history = [
{"role": "user", "content": "今治の特産品について教えてください。"},
{
"role": "assistant",
"thinking_channel": "analysis_imabari",
"thinking": "今治の特産品として、タオルについて答えるんよ。",
"channel": "final_imabari",
"content": "今治タオルが有名なんよ。",
},
{"role": "user", "content": "もう少し詳しく教えてください。"},
]
print(tokenizer.apply_chat_template(history, tokenize=False, **chat_kwargs))
thinking に内容がある場合は思考メッセージ、content は回答メッセージとして整形されます。メッセージ内のチャネルを省略すると analysis / final が使われます。回答だけの履歴では thinking を省略し、回答の channel を残します。generate_thinking=False は次の生成開始ヘッダーに作用するため、履歴に含まれる思考文は削除されません。
参考:Transformers chat templates, Tokenizer decoding API.
未定
チャネルによる文体の切り替えについて
v1では、標準の analysis・final チャネルを指定しても今治弁になることが多いと報告されていました。v2では標準語データを追加していますが、標準語と今治弁をどの程度安定して切り替えられるかについて、このカードでは評価結果を掲載していません。
Current date: 2026-09-19 に固定されており、推論時の日付に自動更新されません。This repository provides a fine-tuned model based on llm-jp/llm-jp-4-8b-thinking.
The base model is provided by llm-jp under the Apache License 2.0.
The following training datasets are provided by ikedachin under CC BY-SA 4.0, retaining the same training-data license as v1:
The standard Japanese dataset is derived from the Imabari dataset by standardizing the language of the reasoning text and final answers. Its modifications also include updating messages, recounting tokens, clearing evaluation values, updating record IDs, and recreating distribution splits.
The dataset cards identify the following upstream sources:
For v2, QA data containing Imabari dialect and standard Japanese was formatted using the same custom chat template as v1 and used for LoRA fine-tuning. The resulting adapter was merged into the base model. Refer to both dataset cards and their source cards for the original materials' attribution and modification history.
For transparency, this card uses license: other and describes the base model and training data terms separately.
Users should review:
Creative Commons' guidance on AI training distinguishes a conservative approach to following ShareAlike from the legal question of whether copyright permission is required. Applicable obligations can depend on the use, distribution, and jurisdiction. The dataset license alone is not presented here as a definitive determination of the license governing the model weights.
If you redistribute this model, merge it into another model, publish derivatives, or use it commercially, review the applicable obligations of both the base model and the training data, including attribution, license notices, and source notices.
ベースモデルと学習データの条件を分けて記載しています。再配布や派生モデルの公開時には、両方の条件と、著作権表示・ライセンス表示・出典表示の要否を確認してください。
This section is provided for transparency and is not legal advice.
この記載は法的助言ではなく、公開時の透明性を高めるための説明です。