Text Generation
PEFT
Safetensors
MiniMax H3
English
lora
sft
trl
script-generation
video-generation
conversational
Instructions to use woodfireind/H3-ScriptGen with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use woodfireind/H3-ScriptGen with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen3.5-0.8B") model = PeftModel.from_pretrained(base_model, "woodfireind/H3-ScriptGen") - Notebooks
- Google Colab
- Kaggle
H3-ScriptGen: MiniMax-H3 FL2VA scriptwriting LoRA (Qwen3.5-0.8B base, continue-trained from final adapter)
Browse files- .gitattributes +3 -0
- README.md +111 -0
- adapter_config.json +48 -0
- adapter_model.safetensors +3 -0
- chat_template.jinja +154 -0
- checkpoint-105/README.md +209 -0
- checkpoint-105/adapter_config.json +48 -0
- checkpoint-105/adapter_model.safetensors +3 -0
- checkpoint-105/chat_template.jinja +154 -0
- checkpoint-105/optimizer.pt +3 -0
- checkpoint-105/rng_state.pth +3 -0
- checkpoint-105/scheduler.pt +3 -0
- checkpoint-105/tokenizer.json +3 -0
- checkpoint-105/tokenizer_config.json +32 -0
- checkpoint-105/trainer_state.json +244 -0
- checkpoint-105/training_args.bin +3 -0
- checkpoint-210/README.md +209 -0
- checkpoint-210/adapter_config.json +48 -0
- checkpoint-210/adapter_model.safetensors +3 -0
- checkpoint-210/chat_template.jinja +154 -0
- checkpoint-210/optimizer.pt +3 -0
- checkpoint-210/rng_state.pth +3 -0
- checkpoint-210/scheduler.pt +3 -0
- checkpoint-210/tokenizer.json +3 -0
- checkpoint-210/tokenizer_config.json +32 -0
- checkpoint-210/trainer_state.json +454 -0
- checkpoint-210/training_args.bin +3 -0
- docs/H3_FORMAT_README.md +58 -0
- docs/VIDEO_PROMPT_base-en.txt +222 -0
- docs/VIDEO_PROMPT_ref-en.txt +341 -0
- docs/h3_prompt_format.py +246 -0
- scripts/build_sft_from_scriptlib.py +361 -0
- scripts/train_dataset.full.jsonl +0 -0
- scripts/train_dataset.jsonl +6 -0
- scripts/train_script_lora_h3.py +228 -0
- tokenizer.json +3 -0
- tokenizer_config.json +32 -0
- training_config.json +13 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,6 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
checkpoint-105/tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
checkpoint-210/tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
| 38 |
+
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language:
|
| 3 |
+
- en
|
| 4 |
+
library_name: peft
|
| 5 |
+
pipeline_tag: text-generation
|
| 6 |
+
license: apache-2.0
|
| 7 |
+
base_model: Qwen/Qwen3.5-0.8B
|
| 8 |
+
tags:
|
| 9 |
+
- lora
|
| 10 |
+
- sft
|
| 11 |
+
- trl
|
| 12 |
+
- script-generation
|
| 13 |
+
- minimax-h3
|
| 14 |
+
- video-generation
|
| 15 |
+
---
|
| 16 |
+
|
| 17 |
+
# H3-ScriptGen — MiniMax-H3 FL2VA scriptwriting LoRA
|
| 18 |
+
|
| 19 |
+
A PEFT LoRA adapter on **Qwen/Qwen3.5-0.8B** that writes **stage/camera directions for MiniMax H3** — one FL2VA scene beat per request, in the exact field structure the H3 video pipeline consumes (`ACTION`, `SHOT`, `STORYBOARD_PROMPT`, `H3_MODE: FL2VA`, `H3_VIDEO_PROMPT`, `overall_soundscape`, `non_diegetic_music`, `DURATION`). Each beat maps 1:1 to a storyboard still + one ~5 s H3 FL2V clip.
|
| 20 |
+
|
| 21 |
+
This is the **merged** adapter: it was **continue-trained from the previous `final/` adapter** (story craft + TVTropes) on 836 H3-format SFT rows, so it keeps the old screenplay/trope knowledge and adds the MiniMax-H3 prompt format on top. Per the project's own guidance, that continue-train is the "practical merge of skills" (see `docs/H3_FORMAT_README.md`) — it is *not* a weighted merge of two separately-trained LoRAs.
|
| 22 |
+
|
| 23 |
+
## Contents
|
| 24 |
+
|
| 25 |
+
| Artifact | Description |
|
| 26 |
+
|---|---|
|
| 27 |
+
| `adapter_model.safetensors` + `adapter_config.json` | **The merged adapter (final, epoch 2)** — load with PEFT |
|
| 28 |
+
| `tokenizer_config.json`, `tokenizer.json`, `chat_template.jinja` | Qwen3.5 tokenizer + chat template (from base) |
|
| 29 |
+
| `training_config.json` | Training metadata (`init_from: …/final`, base, hyperparams) |
|
| 30 |
+
| `checkpoint-105/` | Epoch-1 checkpoint (full trainer state, resumable) |
|
| 31 |
+
| `checkpoint-210/` | Epoch-2 checkpoint (== root adapter; full trainer state) |
|
| 32 |
+
| `scripts/` | `train_script_lora_h3.py`, `build_sft_from_scriptlib.py`, SFT dataset (`train_dataset.full.jsonl`, 836 rows) + seed examples |
|
| 33 |
+
| `docs/` | MiniMax H3 prompt guides (`VIDEO_PROMPT_base-en.txt`, `VIDEO_PROMPT_ref-en.txt`), `h3_prompt_format.py` (runtime field builders), `H3_FORMAT_README.md` |
|
| 34 |
+
|
| 35 |
+
## Base model
|
| 36 |
+
|
| 37 |
+
- **`Qwen/Qwen3.5-0.8B`** (Apache-2.0), 0.8B params, causal LM.
|
| 38 |
+
- LoRA: `r=16`, `alpha=32`, `dropout=0.1`, target modules `q/k/v/o_proj` + `gate/up/down_proj` (193 tensors, 193 = standard PEFT layout).
|
| 39 |
+
|
| 40 |
+
## Training
|
| 41 |
+
|
| 42 |
+
| Setting | Value |
|
| 43 |
+
|---|---|
|
| 44 |
+
| Format | `minimax-h3-fl2va-v1` (SFT, chat template) |
|
| 45 |
+
| Init | Continue-train from `models/script-lora/final` adapter |
|
| 46 |
+
| Data | `train_dataset.full.jsonl` — 836 rows from 102 screenplays (`scriptlib`) + TVTropes seeds + hand-written H3 examples |
|
| 47 |
+
| Epochs / steps | 2 / 210 |
|
| 48 |
+
| Learning rate | 1e-4 (cosine decay) |
|
| 49 |
+
| Max seq len | 1536 |
|
| 50 |
+
| Optimizer | AdamW (non-fused, XPU) |
|
| 51 |
+
| Device | Intel Arc A770 (XPU) |
|
| 52 |
+
|
| 53 |
+
Final metrics (from training log): `train_loss 0.7535`, final-step `mean_token_accuracy 0.8932`; token accuracy ranged ~0.86–0.91 over the run. `checkpoint-105` (epoch 1) and `checkpoint-210` (epoch 2) are both included; the root `adapter_model.safetensors` is identical to `checkpoint-210`.
|
| 54 |
+
|
| 55 |
+
## Output format (one beat)
|
| 56 |
+
|
| 57 |
+
```text
|
| 58 |
+
## SCENE {N} — {SLUGLINE}
|
| 59 |
+
ACTION: <1–2 sentences of visual action for ~5 s>
|
| 60 |
+
DIALOGUE — {NAME}: <line> (at most 1 line, or omit if silent)
|
| 61 |
+
SHOT: <camera type + optional amplitude + speed, natural English>
|
| 62 |
+
STORYBOARD_PROMPT: <self-contained still-image prompt; no camera timeline>
|
| 63 |
+
H3_MODE: FL2VA
|
| 64 |
+
H3_VIDEO_PROMPT:
|
| 65 |
+
How the reference pictures align with the target video — Picture 1 (from Shot 1) aligns with the 0.00-second mark of the target video; Picture 2 (from Shot 1) aligns with the 5.00-second mark of the target video.
|
| 66 |
+
|
| 67 |
+
integrated_multimodal_description: [Shot 1] Live-action, cinematic, <opening composition matching the storyboard>. <continuous motion path Picture 1 → Picture 2; camera motion as natural English>. <dialogue as: the {name} (S1) says: <d>[English] line here</d>>
|
| 68 |
+
|
| 69 |
+
overall_soundscape: <ambience / physical sounds, or N/A>
|
| 70 |
+
|
| 71 |
+
non_diegetic_music: <audience-only score, or N/A>
|
| 72 |
+
LORA: <image-lora:strength, or "none">
|
| 73 |
+
AUDIO: <post-process sfx/music note, or "none">
|
| 74 |
+
DURATION: 5
|
| 75 |
+
```
|
| 76 |
+
|
| 77 |
+
The `h3_video_prompt` and `storyboard_prompt` fields feed directly into the MiniMax H3 FL2V pipeline (storyboard panel N → panel N+1, `zvideo_h3_storyboard_fl2v`).
|
| 78 |
+
|
| 79 |
+
## Usage
|
| 80 |
+
|
| 81 |
+
```python
|
| 82 |
+
from peft import PeftModel
|
| 83 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 84 |
+
|
| 85 |
+
base = "Qwen/Qwen3.5-0.8B"
|
| 86 |
+
tok = AutoTokenizer.from_pretrained(base)
|
| 87 |
+
model = AutoModelForCausalLM.from_pretrained(base, torch_dtype="bfloat16")
|
| 88 |
+
model = PeftModel.from_pretrained(model, "woodfireind/H3-ScriptGen")
|
| 89 |
+
|
| 90 |
+
messages = [
|
| 91 |
+
{"role": "system", "content": "You write ONE MiniMax-H3 FL2VA scene beat for Backlot."},
|
| 92 |
+
{"role": "user", "content": "Premise: A courier delivers a package through a neon alley in the rain.\nWrite SCENE 1 now."},
|
| 93 |
+
]
|
| 94 |
+
text = tok.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
| 95 |
+
out = tok.generate(tok(text, return_tensors="pt").input_ids, max_new_tokens=512)
|
| 96 |
+
print(tok.decode(out[0]))
|
| 97 |
+
```
|
| 98 |
+
|
| 99 |
+
The adapter also loads on llama.cpp / vLLM servers that support PEFT LoRA adapters on the same base model.
|
| 100 |
+
|
| 101 |
+
## Limitations
|
| 102 |
+
|
| 103 |
+
- **Small base (0.8B)** — strong on structure/format adherence; weaker than larger models on nuance, and token accuracy is ~0.9, so occasional malformed fields are expected. Validate output with `docs/h3_prompt_format.py` (`parse_scene_h3_fields`).
|
| 104 |
+
- **Text-only.** This adapter only produces prompt text. Producing video still requires the MiniMax H3 stack (GGUF DiT + VAE + text encoder); on this project's local stack the H3 pipeline has **no audio** (audio VAE dropped) and cut timing can drift ±2 s.
|
| 105 |
+
- **H3 prompt rules are exacting.** `H3_VIDEO_PROMPT` must keep the FL2VA alignment line, `<d>[Language] …</d>` dialogue tags, and speaker `(S1)` IDs. See `docs/VIDEO_PROMPT_base-en.txt`.
|
| 106 |
+
- **Training-data provenance.** The SFT set was built from an internal 102-screenplay corpus + TVTropes metadata + hand-written examples. Review rights before commercial redistribution of generated content.
|
| 107 |
+
- The H3 prompt-field structure follows MiniMax's public H3 prompt guides; using it to generate videos is subject to the MiniMax H3 Community License Agreement.
|
| 108 |
+
|
| 109 |
+
## License
|
| 110 |
+
|
| 111 |
+
Adapter weights are Apache-2.0 (matching the Qwen3.5-0.8B base). Training data is from an internal screenplay corpus — see provenance note above.
|
adapter_config.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"alora_invocation_tokens": null,
|
| 3 |
+
"alpha_pattern": {},
|
| 4 |
+
"arrow_config": null,
|
| 5 |
+
"auto_mapping": null,
|
| 6 |
+
"base_model_name_or_path": "Qwen/Qwen3.5-0.8B",
|
| 7 |
+
"bias": "none",
|
| 8 |
+
"corda_config": null,
|
| 9 |
+
"ensure_weight_tying": false,
|
| 10 |
+
"eva_config": null,
|
| 11 |
+
"exclude_modules": null,
|
| 12 |
+
"fan_in_fan_out": false,
|
| 13 |
+
"inference_mode": true,
|
| 14 |
+
"init_lora_weights": true,
|
| 15 |
+
"layer_replication": null,
|
| 16 |
+
"layers_pattern": null,
|
| 17 |
+
"layers_to_transform": null,
|
| 18 |
+
"loftq_config": {},
|
| 19 |
+
"lora_alpha": 32,
|
| 20 |
+
"lora_bias": false,
|
| 21 |
+
"lora_dropout": 0.1,
|
| 22 |
+
"lora_ga_config": null,
|
| 23 |
+
"megatron_config": null,
|
| 24 |
+
"megatron_core": "megatron.core",
|
| 25 |
+
"modules_to_save": null,
|
| 26 |
+
"peft_type": "LORA",
|
| 27 |
+
"peft_version": "0.19.1",
|
| 28 |
+
"qalora_group_size": 16,
|
| 29 |
+
"r": 16,
|
| 30 |
+
"rank_pattern": {},
|
| 31 |
+
"revision": null,
|
| 32 |
+
"target_modules": [
|
| 33 |
+
"o_proj",
|
| 34 |
+
"v_proj",
|
| 35 |
+
"down_proj",
|
| 36 |
+
"gate_proj",
|
| 37 |
+
"up_proj",
|
| 38 |
+
"k_proj",
|
| 39 |
+
"q_proj"
|
| 40 |
+
],
|
| 41 |
+
"target_parameters": null,
|
| 42 |
+
"task_type": "CAUSAL_LM",
|
| 43 |
+
"trainable_token_indices": null,
|
| 44 |
+
"use_bdlora": null,
|
| 45 |
+
"use_dora": false,
|
| 46 |
+
"use_qalora": false,
|
| 47 |
+
"use_rslora": false
|
| 48 |
+
}
|
adapter_model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5dba84793abf0374625ad8328e5feb343eadf311fdc3bf412593e1de5c7824e8
|
| 3 |
+
size 25584224
|
chat_template.jinja
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{%- set image_count = namespace(value=0) %}
|
| 2 |
+
{%- set video_count = namespace(value=0) %}
|
| 3 |
+
{%- macro render_content(content, do_vision_count, is_system_content=false) %}
|
| 4 |
+
{%- if content is string %}
|
| 5 |
+
{{- content }}
|
| 6 |
+
{%- elif content is iterable and content is not mapping %}
|
| 7 |
+
{%- for item in content %}
|
| 8 |
+
{%- if 'image' in item or 'image_url' in item or item.type == 'image' %}
|
| 9 |
+
{%- if is_system_content %}
|
| 10 |
+
{{- raise_exception('System message cannot contain images.') }}
|
| 11 |
+
{%- endif %}
|
| 12 |
+
{%- if do_vision_count %}
|
| 13 |
+
{%- set image_count.value = image_count.value + 1 %}
|
| 14 |
+
{%- endif %}
|
| 15 |
+
{%- if add_vision_id %}
|
| 16 |
+
{{- 'Picture ' ~ image_count.value ~ ': ' }}
|
| 17 |
+
{%- endif %}
|
| 18 |
+
{{- '<|vision_start|><|image_pad|><|vision_end|>' }}
|
| 19 |
+
{%- elif 'video' in item or item.type == 'video' %}
|
| 20 |
+
{%- if is_system_content %}
|
| 21 |
+
{{- raise_exception('System message cannot contain videos.') }}
|
| 22 |
+
{%- endif %}
|
| 23 |
+
{%- if do_vision_count %}
|
| 24 |
+
{%- set video_count.value = video_count.value + 1 %}
|
| 25 |
+
{%- endif %}
|
| 26 |
+
{%- if add_vision_id %}
|
| 27 |
+
{{- 'Video ' ~ video_count.value ~ ': ' }}
|
| 28 |
+
{%- endif %}
|
| 29 |
+
{{- '<|vision_start|><|video_pad|><|vision_end|>' }}
|
| 30 |
+
{%- elif 'text' in item %}
|
| 31 |
+
{{- item.text }}
|
| 32 |
+
{%- else %}
|
| 33 |
+
{{- raise_exception('Unexpected item type in content.') }}
|
| 34 |
+
{%- endif %}
|
| 35 |
+
{%- endfor %}
|
| 36 |
+
{%- elif content is none or content is undefined %}
|
| 37 |
+
{{- '' }}
|
| 38 |
+
{%- else %}
|
| 39 |
+
{{- raise_exception('Unexpected content type.') }}
|
| 40 |
+
{%- endif %}
|
| 41 |
+
{%- endmacro %}
|
| 42 |
+
{%- if not messages %}
|
| 43 |
+
{{- raise_exception('No messages provided.') }}
|
| 44 |
+
{%- endif %}
|
| 45 |
+
{%- if tools and tools is iterable and tools is not mapping %}
|
| 46 |
+
{{- '<|im_start|>system\n' }}
|
| 47 |
+
{{- "# Tools\n\nYou have access to the following functions:\n\n<tools>" }}
|
| 48 |
+
{%- for tool in tools %}
|
| 49 |
+
{{- "\n" }}
|
| 50 |
+
{{- tool | tojson }}
|
| 51 |
+
{%- endfor %}
|
| 52 |
+
{{- "\n</tools>" }}
|
| 53 |
+
{{- '\n\nIf you choose to call a function ONLY reply in the following format with NO suffix:\n\n<tool_call>\n<function=example_function_name>\n<parameter=example_parameter_1>\nvalue_1\n</parameter>\n<parameter=example_parameter_2>\nThis is the value for the second parameter\nthat can span\nmultiple lines\n</parameter>\n</function>\n</tool_call>\n\n<IMPORTANT>\nReminder:\n- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags\n- Required parameters MUST be specified\n- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after\n- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls\n</IMPORTANT>' }}
|
| 54 |
+
{%- if messages[0].role == 'system' %}
|
| 55 |
+
{%- set content = render_content(messages[0].content, false, true)|trim %}
|
| 56 |
+
{%- if content %}
|
| 57 |
+
{{- '\n\n' + content }}
|
| 58 |
+
{%- endif %}
|
| 59 |
+
{%- endif %}
|
| 60 |
+
{{- '<|im_end|>\n' }}
|
| 61 |
+
{%- else %}
|
| 62 |
+
{%- if messages[0].role == 'system' %}
|
| 63 |
+
{%- set content = render_content(messages[0].content, false, true)|trim %}
|
| 64 |
+
{{- '<|im_start|>system\n' + content + '<|im_end|>\n' }}
|
| 65 |
+
{%- endif %}
|
| 66 |
+
{%- endif %}
|
| 67 |
+
{%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}
|
| 68 |
+
{%- for message in messages[::-1] %}
|
| 69 |
+
{%- set index = (messages|length - 1) - loop.index0 %}
|
| 70 |
+
{%- if ns.multi_step_tool and message.role == "user" %}
|
| 71 |
+
{%- set content = render_content(message.content, false)|trim %}
|
| 72 |
+
{%- if not(content.startswith('<tool_response>') and content.endswith('</tool_response>')) %}
|
| 73 |
+
{%- set ns.multi_step_tool = false %}
|
| 74 |
+
{%- set ns.last_query_index = index %}
|
| 75 |
+
{%- endif %}
|
| 76 |
+
{%- endif %}
|
| 77 |
+
{%- endfor %}
|
| 78 |
+
{%- if ns.multi_step_tool %}
|
| 79 |
+
{{- raise_exception('No user query found in messages.') }}
|
| 80 |
+
{%- endif %}
|
| 81 |
+
{%- for message in messages %}
|
| 82 |
+
{%- set content = render_content(message.content, true)|trim %}
|
| 83 |
+
{%- if message.role == "system" %}
|
| 84 |
+
{%- if not loop.first %}
|
| 85 |
+
{{- raise_exception('System message must be at the beginning.') }}
|
| 86 |
+
{%- endif %}
|
| 87 |
+
{%- elif message.role == "user" %}
|
| 88 |
+
{{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }}
|
| 89 |
+
{%- elif message.role == "assistant" %}
|
| 90 |
+
{%- set reasoning_content = '' %}
|
| 91 |
+
{%- if message.reasoning_content is string %}
|
| 92 |
+
{%- set reasoning_content = message.reasoning_content %}
|
| 93 |
+
{%- else %}
|
| 94 |
+
{%- if '</think>' in content %}
|
| 95 |
+
{%- set reasoning_content = content.split('</think>')[0].rstrip('\n').split('<think>')[-1].lstrip('\n') %}
|
| 96 |
+
{%- set content = content.split('</think>')[-1].lstrip('\n') %}
|
| 97 |
+
{%- endif %}
|
| 98 |
+
{%- endif %}
|
| 99 |
+
{%- set reasoning_content = reasoning_content|trim %}
|
| 100 |
+
{%- if loop.index0 > ns.last_query_index %}
|
| 101 |
+
{{- '<|im_start|>' + message.role + '\n<think>\n' + reasoning_content + '\n</think>\n\n' + content }}
|
| 102 |
+
{%- else %}
|
| 103 |
+
{{- '<|im_start|>' + message.role + '\n' + content }}
|
| 104 |
+
{%- endif %}
|
| 105 |
+
{%- if message.tool_calls and message.tool_calls is iterable and message.tool_calls is not mapping %}
|
| 106 |
+
{%- for tool_call in message.tool_calls %}
|
| 107 |
+
{%- if tool_call.function is defined %}
|
| 108 |
+
{%- set tool_call = tool_call.function %}
|
| 109 |
+
{%- endif %}
|
| 110 |
+
{%- if loop.first %}
|
| 111 |
+
{%- if content|trim %}
|
| 112 |
+
{{- '\n\n<tool_call>\n<function=' + tool_call.name + '>\n' }}
|
| 113 |
+
{%- else %}
|
| 114 |
+
{{- '<tool_call>\n<function=' + tool_call.name + '>\n' }}
|
| 115 |
+
{%- endif %}
|
| 116 |
+
{%- else %}
|
| 117 |
+
{{- '\n<tool_call>\n<function=' + tool_call.name + '>\n' }}
|
| 118 |
+
{%- endif %}
|
| 119 |
+
{%- if tool_call.arguments is defined %}
|
| 120 |
+
{%- for args_name, args_value in tool_call.arguments|items %}
|
| 121 |
+
{{- '<parameter=' + args_name + '>\n' }}
|
| 122 |
+
{%- set args_value = args_value | tojson | safe if args_value is mapping or (args_value is sequence and args_value is not string) else args_value | string %}
|
| 123 |
+
{{- args_value }}
|
| 124 |
+
{{- '\n</parameter>\n' }}
|
| 125 |
+
{%- endfor %}
|
| 126 |
+
{%- endif %}
|
| 127 |
+
{{- '</function>\n</tool_call>' }}
|
| 128 |
+
{%- endfor %}
|
| 129 |
+
{%- endif %}
|
| 130 |
+
{{- '<|im_end|>\n' }}
|
| 131 |
+
{%- elif message.role == "tool" %}
|
| 132 |
+
{%- if loop.previtem and loop.previtem.role != "tool" %}
|
| 133 |
+
{{- '<|im_start|>user' }}
|
| 134 |
+
{%- endif %}
|
| 135 |
+
{{- '\n<tool_response>\n' }}
|
| 136 |
+
{{- content }}
|
| 137 |
+
{{- '\n</tool_response>' }}
|
| 138 |
+
{%- if not loop.last and loop.nextitem.role != "tool" %}
|
| 139 |
+
{{- '<|im_end|>\n' }}
|
| 140 |
+
{%- elif loop.last %}
|
| 141 |
+
{{- '<|im_end|>\n' }}
|
| 142 |
+
{%- endif %}
|
| 143 |
+
{%- else %}
|
| 144 |
+
{{- raise_exception('Unexpected message role.') }}
|
| 145 |
+
{%- endif %}
|
| 146 |
+
{%- endfor %}
|
| 147 |
+
{%- if add_generation_prompt %}
|
| 148 |
+
{{- '<|im_start|>assistant\n' }}
|
| 149 |
+
{%- if enable_thinking is defined and enable_thinking is true %}
|
| 150 |
+
{{- '<think>\n' }}
|
| 151 |
+
{%- else %}
|
| 152 |
+
{{- '<think>\n\n</think>\n\n' }}
|
| 153 |
+
{%- endif %}
|
| 154 |
+
{%- endif %}
|
checkpoint-105/README.md
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
base_model: Qwen/Qwen3.5-0.8B
|
| 3 |
+
library_name: peft
|
| 4 |
+
pipeline_tag: text-generation
|
| 5 |
+
tags:
|
| 6 |
+
- base_model:adapter:Qwen/Qwen3.5-0.8B
|
| 7 |
+
- lora
|
| 8 |
+
- sft
|
| 9 |
+
- transformers
|
| 10 |
+
- trl
|
| 11 |
+
---
|
| 12 |
+
|
| 13 |
+
# Model Card for Model ID
|
| 14 |
+
|
| 15 |
+
<!-- Provide a quick summary of what the model is/does. -->
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
## Model Details
|
| 20 |
+
|
| 21 |
+
### Model Description
|
| 22 |
+
|
| 23 |
+
<!-- Provide a longer summary of what this model is. -->
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
- **Developed by:** [More Information Needed]
|
| 28 |
+
- **Funded by [optional]:** [More Information Needed]
|
| 29 |
+
- **Shared by [optional]:** [More Information Needed]
|
| 30 |
+
- **Model type:** [More Information Needed]
|
| 31 |
+
- **Language(s) (NLP):** [More Information Needed]
|
| 32 |
+
- **License:** [More Information Needed]
|
| 33 |
+
- **Finetuned from model [optional]:** [More Information Needed]
|
| 34 |
+
|
| 35 |
+
### Model Sources [optional]
|
| 36 |
+
|
| 37 |
+
<!-- Provide the basic links for the model. -->
|
| 38 |
+
|
| 39 |
+
- **Repository:** [More Information Needed]
|
| 40 |
+
- **Paper [optional]:** [More Information Needed]
|
| 41 |
+
- **Demo [optional]:** [More Information Needed]
|
| 42 |
+
|
| 43 |
+
## Uses
|
| 44 |
+
|
| 45 |
+
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
| 46 |
+
|
| 47 |
+
### Direct Use
|
| 48 |
+
|
| 49 |
+
<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
|
| 50 |
+
|
| 51 |
+
[More Information Needed]
|
| 52 |
+
|
| 53 |
+
### Downstream Use [optional]
|
| 54 |
+
|
| 55 |
+
<!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
|
| 56 |
+
|
| 57 |
+
[More Information Needed]
|
| 58 |
+
|
| 59 |
+
### Out-of-Scope Use
|
| 60 |
+
|
| 61 |
+
<!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
|
| 62 |
+
|
| 63 |
+
[More Information Needed]
|
| 64 |
+
|
| 65 |
+
## Bias, Risks, and Limitations
|
| 66 |
+
|
| 67 |
+
<!-- This section is meant to convey both technical and sociotechnical limitations. -->
|
| 68 |
+
|
| 69 |
+
[More Information Needed]
|
| 70 |
+
|
| 71 |
+
### Recommendations
|
| 72 |
+
|
| 73 |
+
<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
|
| 74 |
+
|
| 75 |
+
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
|
| 76 |
+
|
| 77 |
+
## How to Get Started with the Model
|
| 78 |
+
|
| 79 |
+
Use the code below to get started with the model.
|
| 80 |
+
|
| 81 |
+
[More Information Needed]
|
| 82 |
+
|
| 83 |
+
## Training Details
|
| 84 |
+
|
| 85 |
+
### Training Data
|
| 86 |
+
|
| 87 |
+
<!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
|
| 88 |
+
|
| 89 |
+
[More Information Needed]
|
| 90 |
+
|
| 91 |
+
### Training Procedure
|
| 92 |
+
|
| 93 |
+
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
|
| 94 |
+
|
| 95 |
+
#### Preprocessing [optional]
|
| 96 |
+
|
| 97 |
+
[More Information Needed]
|
| 98 |
+
|
| 99 |
+
|
| 100 |
+
#### Training Hyperparameters
|
| 101 |
+
|
| 102 |
+
- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
|
| 103 |
+
|
| 104 |
+
#### Speeds, Sizes, Times [optional]
|
| 105 |
+
|
| 106 |
+
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
| 107 |
+
|
| 108 |
+
[More Information Needed]
|
| 109 |
+
|
| 110 |
+
## Evaluation
|
| 111 |
+
|
| 112 |
+
<!-- This section describes the evaluation protocols and provides the results. -->
|
| 113 |
+
|
| 114 |
+
### Testing Data, Factors & Metrics
|
| 115 |
+
|
| 116 |
+
#### Testing Data
|
| 117 |
+
|
| 118 |
+
<!-- This should link to a Dataset Card if possible. -->
|
| 119 |
+
|
| 120 |
+
[More Information Needed]
|
| 121 |
+
|
| 122 |
+
#### Factors
|
| 123 |
+
|
| 124 |
+
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
| 125 |
+
|
| 126 |
+
[More Information Needed]
|
| 127 |
+
|
| 128 |
+
#### Metrics
|
| 129 |
+
|
| 130 |
+
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
| 131 |
+
|
| 132 |
+
[More Information Needed]
|
| 133 |
+
|
| 134 |
+
### Results
|
| 135 |
+
|
| 136 |
+
[More Information Needed]
|
| 137 |
+
|
| 138 |
+
#### Summary
|
| 139 |
+
|
| 140 |
+
|
| 141 |
+
|
| 142 |
+
## Model Examination [optional]
|
| 143 |
+
|
| 144 |
+
<!-- Relevant interpretability work for the model goes here -->
|
| 145 |
+
|
| 146 |
+
[More Information Needed]
|
| 147 |
+
|
| 148 |
+
## Environmental Impact
|
| 149 |
+
|
| 150 |
+
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
| 151 |
+
|
| 152 |
+
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
|
| 153 |
+
|
| 154 |
+
- **Hardware Type:** [More Information Needed]
|
| 155 |
+
- **Hours used:** [More Information Needed]
|
| 156 |
+
- **Cloud Provider:** [More Information Needed]
|
| 157 |
+
- **Compute Region:** [More Information Needed]
|
| 158 |
+
- **Carbon Emitted:** [More Information Needed]
|
| 159 |
+
|
| 160 |
+
## Technical Specifications [optional]
|
| 161 |
+
|
| 162 |
+
### Model Architecture and Objective
|
| 163 |
+
|
| 164 |
+
[More Information Needed]
|
| 165 |
+
|
| 166 |
+
### Compute Infrastructure
|
| 167 |
+
|
| 168 |
+
[More Information Needed]
|
| 169 |
+
|
| 170 |
+
#### Hardware
|
| 171 |
+
|
| 172 |
+
[More Information Needed]
|
| 173 |
+
|
| 174 |
+
#### Software
|
| 175 |
+
|
| 176 |
+
[More Information Needed]
|
| 177 |
+
|
| 178 |
+
## Citation [optional]
|
| 179 |
+
|
| 180 |
+
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
| 181 |
+
|
| 182 |
+
**BibTeX:**
|
| 183 |
+
|
| 184 |
+
[More Information Needed]
|
| 185 |
+
|
| 186 |
+
**APA:**
|
| 187 |
+
|
| 188 |
+
[More Information Needed]
|
| 189 |
+
|
| 190 |
+
## Glossary [optional]
|
| 191 |
+
|
| 192 |
+
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
| 193 |
+
|
| 194 |
+
[More Information Needed]
|
| 195 |
+
|
| 196 |
+
## More Information [optional]
|
| 197 |
+
|
| 198 |
+
[More Information Needed]
|
| 199 |
+
|
| 200 |
+
## Model Card Authors [optional]
|
| 201 |
+
|
| 202 |
+
[More Information Needed]
|
| 203 |
+
|
| 204 |
+
## Model Card Contact
|
| 205 |
+
|
| 206 |
+
[More Information Needed]
|
| 207 |
+
### Framework versions
|
| 208 |
+
|
| 209 |
+
- PEFT 0.19.1
|
checkpoint-105/adapter_config.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"alora_invocation_tokens": null,
|
| 3 |
+
"alpha_pattern": {},
|
| 4 |
+
"arrow_config": null,
|
| 5 |
+
"auto_mapping": null,
|
| 6 |
+
"base_model_name_or_path": "Qwen/Qwen3.5-0.8B",
|
| 7 |
+
"bias": "none",
|
| 8 |
+
"corda_config": null,
|
| 9 |
+
"ensure_weight_tying": false,
|
| 10 |
+
"eva_config": null,
|
| 11 |
+
"exclude_modules": null,
|
| 12 |
+
"fan_in_fan_out": false,
|
| 13 |
+
"inference_mode": true,
|
| 14 |
+
"init_lora_weights": true,
|
| 15 |
+
"layer_replication": null,
|
| 16 |
+
"layers_pattern": null,
|
| 17 |
+
"layers_to_transform": null,
|
| 18 |
+
"loftq_config": {},
|
| 19 |
+
"lora_alpha": 32,
|
| 20 |
+
"lora_bias": false,
|
| 21 |
+
"lora_dropout": 0.1,
|
| 22 |
+
"lora_ga_config": null,
|
| 23 |
+
"megatron_config": null,
|
| 24 |
+
"megatron_core": "megatron.core",
|
| 25 |
+
"modules_to_save": null,
|
| 26 |
+
"peft_type": "LORA",
|
| 27 |
+
"peft_version": "0.19.1",
|
| 28 |
+
"qalora_group_size": 16,
|
| 29 |
+
"r": 16,
|
| 30 |
+
"rank_pattern": {},
|
| 31 |
+
"revision": null,
|
| 32 |
+
"target_modules": [
|
| 33 |
+
"o_proj",
|
| 34 |
+
"v_proj",
|
| 35 |
+
"down_proj",
|
| 36 |
+
"gate_proj",
|
| 37 |
+
"up_proj",
|
| 38 |
+
"k_proj",
|
| 39 |
+
"q_proj"
|
| 40 |
+
],
|
| 41 |
+
"target_parameters": null,
|
| 42 |
+
"task_type": "CAUSAL_LM",
|
| 43 |
+
"trainable_token_indices": null,
|
| 44 |
+
"use_bdlora": null,
|
| 45 |
+
"use_dora": false,
|
| 46 |
+
"use_qalora": false,
|
| 47 |
+
"use_rslora": false
|
| 48 |
+
}
|
checkpoint-105/adapter_model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:dd3b673026ea73a55ee009bfdcbea58b935adc815de87426b44712eab848ec1a
|
| 3 |
+
size 25584224
|
checkpoint-105/chat_template.jinja
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{%- set image_count = namespace(value=0) %}
|
| 2 |
+
{%- set video_count = namespace(value=0) %}
|
| 3 |
+
{%- macro render_content(content, do_vision_count, is_system_content=false) %}
|
| 4 |
+
{%- if content is string %}
|
| 5 |
+
{{- content }}
|
| 6 |
+
{%- elif content is iterable and content is not mapping %}
|
| 7 |
+
{%- for item in content %}
|
| 8 |
+
{%- if 'image' in item or 'image_url' in item or item.type == 'image' %}
|
| 9 |
+
{%- if is_system_content %}
|
| 10 |
+
{{- raise_exception('System message cannot contain images.') }}
|
| 11 |
+
{%- endif %}
|
| 12 |
+
{%- if do_vision_count %}
|
| 13 |
+
{%- set image_count.value = image_count.value + 1 %}
|
| 14 |
+
{%- endif %}
|
| 15 |
+
{%- if add_vision_id %}
|
| 16 |
+
{{- 'Picture ' ~ image_count.value ~ ': ' }}
|
| 17 |
+
{%- endif %}
|
| 18 |
+
{{- '<|vision_start|><|image_pad|><|vision_end|>' }}
|
| 19 |
+
{%- elif 'video' in item or item.type == 'video' %}
|
| 20 |
+
{%- if is_system_content %}
|
| 21 |
+
{{- raise_exception('System message cannot contain videos.') }}
|
| 22 |
+
{%- endif %}
|
| 23 |
+
{%- if do_vision_count %}
|
| 24 |
+
{%- set video_count.value = video_count.value + 1 %}
|
| 25 |
+
{%- endif %}
|
| 26 |
+
{%- if add_vision_id %}
|
| 27 |
+
{{- 'Video ' ~ video_count.value ~ ': ' }}
|
| 28 |
+
{%- endif %}
|
| 29 |
+
{{- '<|vision_start|><|video_pad|><|vision_end|>' }}
|
| 30 |
+
{%- elif 'text' in item %}
|
| 31 |
+
{{- item.text }}
|
| 32 |
+
{%- else %}
|
| 33 |
+
{{- raise_exception('Unexpected item type in content.') }}
|
| 34 |
+
{%- endif %}
|
| 35 |
+
{%- endfor %}
|
| 36 |
+
{%- elif content is none or content is undefined %}
|
| 37 |
+
{{- '' }}
|
| 38 |
+
{%- else %}
|
| 39 |
+
{{- raise_exception('Unexpected content type.') }}
|
| 40 |
+
{%- endif %}
|
| 41 |
+
{%- endmacro %}
|
| 42 |
+
{%- if not messages %}
|
| 43 |
+
{{- raise_exception('No messages provided.') }}
|
| 44 |
+
{%- endif %}
|
| 45 |
+
{%- if tools and tools is iterable and tools is not mapping %}
|
| 46 |
+
{{- '<|im_start|>system\n' }}
|
| 47 |
+
{{- "# Tools\n\nYou have access to the following functions:\n\n<tools>" }}
|
| 48 |
+
{%- for tool in tools %}
|
| 49 |
+
{{- "\n" }}
|
| 50 |
+
{{- tool | tojson }}
|
| 51 |
+
{%- endfor %}
|
| 52 |
+
{{- "\n</tools>" }}
|
| 53 |
+
{{- '\n\nIf you choose to call a function ONLY reply in the following format with NO suffix:\n\n<tool_call>\n<function=example_function_name>\n<parameter=example_parameter_1>\nvalue_1\n</parameter>\n<parameter=example_parameter_2>\nThis is the value for the second parameter\nthat can span\nmultiple lines\n</parameter>\n</function>\n</tool_call>\n\n<IMPORTANT>\nReminder:\n- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags\n- Required parameters MUST be specified\n- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after\n- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls\n</IMPORTANT>' }}
|
| 54 |
+
{%- if messages[0].role == 'system' %}
|
| 55 |
+
{%- set content = render_content(messages[0].content, false, true)|trim %}
|
| 56 |
+
{%- if content %}
|
| 57 |
+
{{- '\n\n' + content }}
|
| 58 |
+
{%- endif %}
|
| 59 |
+
{%- endif %}
|
| 60 |
+
{{- '<|im_end|>\n' }}
|
| 61 |
+
{%- else %}
|
| 62 |
+
{%- if messages[0].role == 'system' %}
|
| 63 |
+
{%- set content = render_content(messages[0].content, false, true)|trim %}
|
| 64 |
+
{{- '<|im_start|>system\n' + content + '<|im_end|>\n' }}
|
| 65 |
+
{%- endif %}
|
| 66 |
+
{%- endif %}
|
| 67 |
+
{%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}
|
| 68 |
+
{%- for message in messages[::-1] %}
|
| 69 |
+
{%- set index = (messages|length - 1) - loop.index0 %}
|
| 70 |
+
{%- if ns.multi_step_tool and message.role == "user" %}
|
| 71 |
+
{%- set content = render_content(message.content, false)|trim %}
|
| 72 |
+
{%- if not(content.startswith('<tool_response>') and content.endswith('</tool_response>')) %}
|
| 73 |
+
{%- set ns.multi_step_tool = false %}
|
| 74 |
+
{%- set ns.last_query_index = index %}
|
| 75 |
+
{%- endif %}
|
| 76 |
+
{%- endif %}
|
| 77 |
+
{%- endfor %}
|
| 78 |
+
{%- if ns.multi_step_tool %}
|
| 79 |
+
{{- raise_exception('No user query found in messages.') }}
|
| 80 |
+
{%- endif %}
|
| 81 |
+
{%- for message in messages %}
|
| 82 |
+
{%- set content = render_content(message.content, true)|trim %}
|
| 83 |
+
{%- if message.role == "system" %}
|
| 84 |
+
{%- if not loop.first %}
|
| 85 |
+
{{- raise_exception('System message must be at the beginning.') }}
|
| 86 |
+
{%- endif %}
|
| 87 |
+
{%- elif message.role == "user" %}
|
| 88 |
+
{{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }}
|
| 89 |
+
{%- elif message.role == "assistant" %}
|
| 90 |
+
{%- set reasoning_content = '' %}
|
| 91 |
+
{%- if message.reasoning_content is string %}
|
| 92 |
+
{%- set reasoning_content = message.reasoning_content %}
|
| 93 |
+
{%- else %}
|
| 94 |
+
{%- if '</think>' in content %}
|
| 95 |
+
{%- set reasoning_content = content.split('</think>')[0].rstrip('\n').split('<think>')[-1].lstrip('\n') %}
|
| 96 |
+
{%- set content = content.split('</think>')[-1].lstrip('\n') %}
|
| 97 |
+
{%- endif %}
|
| 98 |
+
{%- endif %}
|
| 99 |
+
{%- set reasoning_content = reasoning_content|trim %}
|
| 100 |
+
{%- if loop.index0 > ns.last_query_index %}
|
| 101 |
+
{{- '<|im_start|>' + message.role + '\n<think>\n' + reasoning_content + '\n</think>\n\n' + content }}
|
| 102 |
+
{%- else %}
|
| 103 |
+
{{- '<|im_start|>' + message.role + '\n' + content }}
|
| 104 |
+
{%- endif %}
|
| 105 |
+
{%- if message.tool_calls and message.tool_calls is iterable and message.tool_calls is not mapping %}
|
| 106 |
+
{%- for tool_call in message.tool_calls %}
|
| 107 |
+
{%- if tool_call.function is defined %}
|
| 108 |
+
{%- set tool_call = tool_call.function %}
|
| 109 |
+
{%- endif %}
|
| 110 |
+
{%- if loop.first %}
|
| 111 |
+
{%- if content|trim %}
|
| 112 |
+
{{- '\n\n<tool_call>\n<function=' + tool_call.name + '>\n' }}
|
| 113 |
+
{%- else %}
|
| 114 |
+
{{- '<tool_call>\n<function=' + tool_call.name + '>\n' }}
|
| 115 |
+
{%- endif %}
|
| 116 |
+
{%- else %}
|
| 117 |
+
{{- '\n<tool_call>\n<function=' + tool_call.name + '>\n' }}
|
| 118 |
+
{%- endif %}
|
| 119 |
+
{%- if tool_call.arguments is defined %}
|
| 120 |
+
{%- for args_name, args_value in tool_call.arguments|items %}
|
| 121 |
+
{{- '<parameter=' + args_name + '>\n' }}
|
| 122 |
+
{%- set args_value = args_value | tojson | safe if args_value is mapping or (args_value is sequence and args_value is not string) else args_value | string %}
|
| 123 |
+
{{- args_value }}
|
| 124 |
+
{{- '\n</parameter>\n' }}
|
| 125 |
+
{%- endfor %}
|
| 126 |
+
{%- endif %}
|
| 127 |
+
{{- '</function>\n</tool_call>' }}
|
| 128 |
+
{%- endfor %}
|
| 129 |
+
{%- endif %}
|
| 130 |
+
{{- '<|im_end|>\n' }}
|
| 131 |
+
{%- elif message.role == "tool" %}
|
| 132 |
+
{%- if loop.previtem and loop.previtem.role != "tool" %}
|
| 133 |
+
{{- '<|im_start|>user' }}
|
| 134 |
+
{%- endif %}
|
| 135 |
+
{{- '\n<tool_response>\n' }}
|
| 136 |
+
{{- content }}
|
| 137 |
+
{{- '\n</tool_response>' }}
|
| 138 |
+
{%- if not loop.last and loop.nextitem.role != "tool" %}
|
| 139 |
+
{{- '<|im_end|>\n' }}
|
| 140 |
+
{%- elif loop.last %}
|
| 141 |
+
{{- '<|im_end|>\n' }}
|
| 142 |
+
{%- endif %}
|
| 143 |
+
{%- else %}
|
| 144 |
+
{{- raise_exception('Unexpected message role.') }}
|
| 145 |
+
{%- endif %}
|
| 146 |
+
{%- endfor %}
|
| 147 |
+
{%- if add_generation_prompt %}
|
| 148 |
+
{{- '<|im_start|>assistant\n' }}
|
| 149 |
+
{%- if enable_thinking is defined and enable_thinking is true %}
|
| 150 |
+
{{- '<think>\n' }}
|
| 151 |
+
{%- else %}
|
| 152 |
+
{{- '<think>\n\n</think>\n\n' }}
|
| 153 |
+
{%- endif %}
|
| 154 |
+
{%- endif %}
|
checkpoint-105/optimizer.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8605c535c870fd4dadbea8ecfc73c1268bfcb108a31fa3becfb4e046c49f3fca
|
| 3 |
+
size 51279371
|
checkpoint-105/rng_state.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:deadce9a155836e6949e0b359c5ba9b77362fff19dd52d804c722c9623ee4bca
|
| 3 |
+
size 14391
|
checkpoint-105/scheduler.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:03ea2004117e0d96c5f48fd4e4e3c761dffe6f617e85f27097c66b820b6c792e
|
| 3 |
+
size 1465
|
checkpoint-105/tokenizer.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:06b9509352d2af50381ab2247e083b80d32d5c0aba91c272ca9ff729b6a0e523
|
| 3 |
+
size 19989325
|
checkpoint-105/tokenizer_config.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_prefix_space": false,
|
| 3 |
+
"audio_bos_token": "<|audio_start|>",
|
| 4 |
+
"audio_eos_token": "<|audio_end|>",
|
| 5 |
+
"audio_token": "<|audio_pad|>",
|
| 6 |
+
"backend": "tokenizers",
|
| 7 |
+
"bos_token": null,
|
| 8 |
+
"clean_up_tokenization_spaces": false,
|
| 9 |
+
"eos_token": "<|im_end|>",
|
| 10 |
+
"errors": "replace",
|
| 11 |
+
"image_token": "<|image_pad|>",
|
| 12 |
+
"is_local": false,
|
| 13 |
+
"local_files_only": false,
|
| 14 |
+
"model_max_length": 262144,
|
| 15 |
+
"model_specific_special_tokens": {
|
| 16 |
+
"audio_bos_token": "<|audio_start|>",
|
| 17 |
+
"audio_eos_token": "<|audio_end|>",
|
| 18 |
+
"audio_token": "<|audio_pad|>",
|
| 19 |
+
"image_token": "<|image_pad|>",
|
| 20 |
+
"video_token": "<|video_pad|>",
|
| 21 |
+
"vision_bos_token": "<|vision_start|>",
|
| 22 |
+
"vision_eos_token": "<|vision_end|>"
|
| 23 |
+
},
|
| 24 |
+
"pad_token": "<|endoftext|>",
|
| 25 |
+
"pretokenize_regex": "(?i:'s|'t|'re|'ve|'m|'ll|'d)|[^\\r\\n\\p{L}\\p{N}]?[\\p{L}\\p{M}]+|\\p{N}| ?[^\\s\\p{L}\\p{M}\\p{N}]+[\\r\\n]*|\\s*[\\r\\n]+|\\s+(?!\\S)|\\s+",
|
| 26 |
+
"split_special_tokens": false,
|
| 27 |
+
"tokenizer_class": "Qwen2Tokenizer",
|
| 28 |
+
"unk_token": null,
|
| 29 |
+
"video_token": "<|video_pad|>",
|
| 30 |
+
"vision_bos_token": "<|vision_start|>",
|
| 31 |
+
"vision_eos_token": "<|vision_end|>"
|
| 32 |
+
}
|
checkpoint-105/trainer_state.json
ADDED
|
@@ -0,0 +1,244 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"best_global_step": null,
|
| 3 |
+
"best_metric": null,
|
| 4 |
+
"best_model_checkpoint": null,
|
| 5 |
+
"epoch": 1.0,
|
| 6 |
+
"eval_steps": 500,
|
| 7 |
+
"global_step": 105,
|
| 8 |
+
"is_hyper_param_search": false,
|
| 9 |
+
"is_local_process_zero": true,
|
| 10 |
+
"is_world_process_zero": true,
|
| 11 |
+
"log_history": [
|
| 12 |
+
{
|
| 13 |
+
"entropy": 2.1651801258325576,
|
| 14 |
+
"epoch": 0.04784688995215311,
|
| 15 |
+
"grad_norm": 4.052286148071289,
|
| 16 |
+
"learning_rate": 9.80952380952381e-05,
|
| 17 |
+
"loss": 2.560974884033203,
|
| 18 |
+
"mean_token_accuracy": 0.5812613397836686,
|
| 19 |
+
"num_tokens": 22163.0,
|
| 20 |
+
"step": 5
|
| 21 |
+
},
|
| 22 |
+
{
|
| 23 |
+
"entropy": 1.7820561587810517,
|
| 24 |
+
"epoch": 0.09569377990430622,
|
| 25 |
+
"grad_norm": 3.3570611476898193,
|
| 26 |
+
"learning_rate": 9.571428571428573e-05,
|
| 27 |
+
"loss": 1.5557975769042969,
|
| 28 |
+
"mean_token_accuracy": 0.7120864883065223,
|
| 29 |
+
"num_tokens": 44774.0,
|
| 30 |
+
"step": 10
|
| 31 |
+
},
|
| 32 |
+
{
|
| 33 |
+
"entropy": 0.9664318569004535,
|
| 34 |
+
"epoch": 0.14354066985645933,
|
| 35 |
+
"grad_norm": 2.2438340187072754,
|
| 36 |
+
"learning_rate": 9.333333333333334e-05,
|
| 37 |
+
"loss": 1.0039640426635743,
|
| 38 |
+
"mean_token_accuracy": 0.8314489215612412,
|
| 39 |
+
"num_tokens": 68554.0,
|
| 40 |
+
"step": 15
|
| 41 |
+
},
|
| 42 |
+
{
|
| 43 |
+
"entropy": 0.7952521093189716,
|
| 44 |
+
"epoch": 0.19138755980861244,
|
| 45 |
+
"grad_norm": 1.4970792531967163,
|
| 46 |
+
"learning_rate": 9.095238095238096e-05,
|
| 47 |
+
"loss": 0.9054213523864746,
|
| 48 |
+
"mean_token_accuracy": 0.8527463525533676,
|
| 49 |
+
"num_tokens": 92672.0,
|
| 50 |
+
"step": 20
|
| 51 |
+
},
|
| 52 |
+
{
|
| 53 |
+
"entropy": 0.7521916493773461,
|
| 54 |
+
"epoch": 0.23923444976076555,
|
| 55 |
+
"grad_norm": 1.1931730508804321,
|
| 56 |
+
"learning_rate": 8.857142857142857e-05,
|
| 57 |
+
"loss": 0.8049167633056641,
|
| 58 |
+
"mean_token_accuracy": 0.8651137307286263,
|
| 59 |
+
"num_tokens": 115556.0,
|
| 60 |
+
"step": 25
|
| 61 |
+
},
|
| 62 |
+
{
|
| 63 |
+
"entropy": 0.8046777091920376,
|
| 64 |
+
"epoch": 0.28708133971291866,
|
| 65 |
+
"grad_norm": 1.1074719429016113,
|
| 66 |
+
"learning_rate": 8.61904761904762e-05,
|
| 67 |
+
"loss": 0.8548135757446289,
|
| 68 |
+
"mean_token_accuracy": 0.8603784069418907,
|
| 69 |
+
"num_tokens": 140637.0,
|
| 70 |
+
"step": 30
|
| 71 |
+
},
|
| 72 |
+
{
|
| 73 |
+
"entropy": 0.6400977578014135,
|
| 74 |
+
"epoch": 0.3349282296650718,
|
| 75 |
+
"grad_norm": 0.9381627440452576,
|
| 76 |
+
"learning_rate": 8.380952380952382e-05,
|
| 77 |
+
"loss": 0.6987390518188477,
|
| 78 |
+
"mean_token_accuracy": 0.8840002715587616,
|
| 79 |
+
"num_tokens": 164217.0,
|
| 80 |
+
"step": 35
|
| 81 |
+
},
|
| 82 |
+
{
|
| 83 |
+
"entropy": 0.6654842033982277,
|
| 84 |
+
"epoch": 0.3827751196172249,
|
| 85 |
+
"grad_norm": 2.1283178329467773,
|
| 86 |
+
"learning_rate": 8.142857142857143e-05,
|
| 87 |
+
"loss": 0.7857039928436279,
|
| 88 |
+
"mean_token_accuracy": 0.8724030137062073,
|
| 89 |
+
"num_tokens": 186852.0,
|
| 90 |
+
"step": 40
|
| 91 |
+
},
|
| 92 |
+
{
|
| 93 |
+
"entropy": 0.619146254658699,
|
| 94 |
+
"epoch": 0.430622009569378,
|
| 95 |
+
"grad_norm": 0.8456487059593201,
|
| 96 |
+
"learning_rate": 7.904761904761905e-05,
|
| 97 |
+
"loss": 0.6680184364318847,
|
| 98 |
+
"mean_token_accuracy": 0.8887932941317558,
|
| 99 |
+
"num_tokens": 210073.0,
|
| 100 |
+
"step": 45
|
| 101 |
+
},
|
| 102 |
+
{
|
| 103 |
+
"entropy": 0.6058806985616684,
|
| 104 |
+
"epoch": 0.4784688995215311,
|
| 105 |
+
"grad_norm": 0.8580911159515381,
|
| 106 |
+
"learning_rate": 7.666666666666667e-05,
|
| 107 |
+
"loss": 0.6658339977264405,
|
| 108 |
+
"mean_token_accuracy": 0.8919811978936195,
|
| 109 |
+
"num_tokens": 233395.0,
|
| 110 |
+
"step": 50
|
| 111 |
+
},
|
| 112 |
+
{
|
| 113 |
+
"entropy": 0.6354636650532484,
|
| 114 |
+
"epoch": 0.5263157894736842,
|
| 115 |
+
"grad_norm": 0.9746028780937195,
|
| 116 |
+
"learning_rate": 7.428571428571429e-05,
|
| 117 |
+
"loss": 0.728534460067749,
|
| 118 |
+
"mean_token_accuracy": 0.8858045786619186,
|
| 119 |
+
"num_tokens": 256677.0,
|
| 120 |
+
"step": 55
|
| 121 |
+
},
|
| 122 |
+
{
|
| 123 |
+
"entropy": 0.5936117857694626,
|
| 124 |
+
"epoch": 0.5741626794258373,
|
| 125 |
+
"grad_norm": 0.9922609925270081,
|
| 126 |
+
"learning_rate": 7.19047619047619e-05,
|
| 127 |
+
"loss": 0.6770713806152344,
|
| 128 |
+
"mean_token_accuracy": 0.8887649178504944,
|
| 129 |
+
"num_tokens": 278351.0,
|
| 130 |
+
"step": 60
|
| 131 |
+
},
|
| 132 |
+
{
|
| 133 |
+
"entropy": 0.6688867088407278,
|
| 134 |
+
"epoch": 0.6220095693779905,
|
| 135 |
+
"grad_norm": 0.9844464659690857,
|
| 136 |
+
"learning_rate": 6.952380952380952e-05,
|
| 137 |
+
"loss": 0.7745152950286865,
|
| 138 |
+
"mean_token_accuracy": 0.8777409210801125,
|
| 139 |
+
"num_tokens": 303271.0,
|
| 140 |
+
"step": 65
|
| 141 |
+
},
|
| 142 |
+
{
|
| 143 |
+
"entropy": 0.7457825832068921,
|
| 144 |
+
"epoch": 0.6698564593301436,
|
| 145 |
+
"grad_norm": 0.9128448367118835,
|
| 146 |
+
"learning_rate": 6.714285714285714e-05,
|
| 147 |
+
"loss": 0.8470640182495117,
|
| 148 |
+
"mean_token_accuracy": 0.8637880578637123,
|
| 149 |
+
"num_tokens": 328315.0,
|
| 150 |
+
"step": 70
|
| 151 |
+
},
|
| 152 |
+
{
|
| 153 |
+
"entropy": 0.6116038627922535,
|
| 154 |
+
"epoch": 0.7177033492822966,
|
| 155 |
+
"grad_norm": 0.9624145030975342,
|
| 156 |
+
"learning_rate": 6.476190476190477e-05,
|
| 157 |
+
"loss": 0.6843190670013428,
|
| 158 |
+
"mean_token_accuracy": 0.8896616101264954,
|
| 159 |
+
"num_tokens": 351963.0,
|
| 160 |
+
"step": 75
|
| 161 |
+
},
|
| 162 |
+
{
|
| 163 |
+
"entropy": 0.622330765798688,
|
| 164 |
+
"epoch": 0.7655502392344498,
|
| 165 |
+
"grad_norm": 0.9209601879119873,
|
| 166 |
+
"learning_rate": 6.238095238095239e-05,
|
| 167 |
+
"loss": 0.6767851829528808,
|
| 168 |
+
"mean_token_accuracy": 0.8867631480097771,
|
| 169 |
+
"num_tokens": 375023.0,
|
| 170 |
+
"step": 80
|
| 171 |
+
},
|
| 172 |
+
{
|
| 173 |
+
"entropy": 0.6198485180735588,
|
| 174 |
+
"epoch": 0.8133971291866029,
|
| 175 |
+
"grad_norm": 0.946159303188324,
|
| 176 |
+
"learning_rate": 6e-05,
|
| 177 |
+
"loss": 0.6652565956115722,
|
| 178 |
+
"mean_token_accuracy": 0.8853679791092872,
|
| 179 |
+
"num_tokens": 399277.0,
|
| 180 |
+
"step": 85
|
| 181 |
+
},
|
| 182 |
+
{
|
| 183 |
+
"entropy": 0.5564446035772562,
|
| 184 |
+
"epoch": 0.861244019138756,
|
| 185 |
+
"grad_norm": 0.8137181401252747,
|
| 186 |
+
"learning_rate": 5.761904761904762e-05,
|
| 187 |
+
"loss": 0.6248233795166016,
|
| 188 |
+
"mean_token_accuracy": 0.8972864270210266,
|
| 189 |
+
"num_tokens": 421249.0,
|
| 190 |
+
"step": 90
|
| 191 |
+
},
|
| 192 |
+
{
|
| 193 |
+
"entropy": 0.5795138332992792,
|
| 194 |
+
"epoch": 0.9090909090909091,
|
| 195 |
+
"grad_norm": 0.851652204990387,
|
| 196 |
+
"learning_rate": 5.5238095238095244e-05,
|
| 197 |
+
"loss": 0.6658082008361816,
|
| 198 |
+
"mean_token_accuracy": 0.8966752380132675,
|
| 199 |
+
"num_tokens": 444070.0,
|
| 200 |
+
"step": 95
|
| 201 |
+
},
|
| 202 |
+
{
|
| 203 |
+
"entropy": 0.6267214026302099,
|
| 204 |
+
"epoch": 0.9569377990430622,
|
| 205 |
+
"grad_norm": 0.8740034103393555,
|
| 206 |
+
"learning_rate": 5.285714285714286e-05,
|
| 207 |
+
"loss": 0.7174222946166993,
|
| 208 |
+
"mean_token_accuracy": 0.880531644821167,
|
| 209 |
+
"num_tokens": 467253.0,
|
| 210 |
+
"step": 100
|
| 211 |
+
},
|
| 212 |
+
{
|
| 213 |
+
"entropy": 0.6104649793770578,
|
| 214 |
+
"epoch": 1.0,
|
| 215 |
+
"grad_norm": 1.397324800491333,
|
| 216 |
+
"learning_rate": 5.047619047619048e-05,
|
| 217 |
+
"loss": 0.723299789428711,
|
| 218 |
+
"mean_token_accuracy": 0.8877596159776052,
|
| 219 |
+
"num_tokens": 489018.0,
|
| 220 |
+
"step": 105
|
| 221 |
+
}
|
| 222 |
+
],
|
| 223 |
+
"logging_steps": 5,
|
| 224 |
+
"max_steps": 210,
|
| 225 |
+
"num_input_tokens_seen": 0,
|
| 226 |
+
"num_train_epochs": 2,
|
| 227 |
+
"save_steps": 500,
|
| 228 |
+
"stateful_callbacks": {
|
| 229 |
+
"TrainerControl": {
|
| 230 |
+
"args": {
|
| 231 |
+
"should_epoch_stop": false,
|
| 232 |
+
"should_evaluate": false,
|
| 233 |
+
"should_log": false,
|
| 234 |
+
"should_save": true,
|
| 235 |
+
"should_training_stop": false
|
| 236 |
+
},
|
| 237 |
+
"attributes": {}
|
| 238 |
+
}
|
| 239 |
+
},
|
| 240 |
+
"total_flos": 1480266593471232.0,
|
| 241 |
+
"train_batch_size": 1,
|
| 242 |
+
"trial_name": null,
|
| 243 |
+
"trial_params": null
|
| 244 |
+
}
|
checkpoint-105/training_args.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3d7f1960e9dbaf314c7e9b04bfe8d6b254d09770f3dd0af5f28a54c56991b5cd
|
| 3 |
+
size 5713
|
checkpoint-210/README.md
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
base_model: Qwen/Qwen3.5-0.8B
|
| 3 |
+
library_name: peft
|
| 4 |
+
pipeline_tag: text-generation
|
| 5 |
+
tags:
|
| 6 |
+
- base_model:adapter:Qwen/Qwen3.5-0.8B
|
| 7 |
+
- lora
|
| 8 |
+
- sft
|
| 9 |
+
- transformers
|
| 10 |
+
- trl
|
| 11 |
+
---
|
| 12 |
+
|
| 13 |
+
# Model Card for Model ID
|
| 14 |
+
|
| 15 |
+
<!-- Provide a quick summary of what the model is/does. -->
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
## Model Details
|
| 20 |
+
|
| 21 |
+
### Model Description
|
| 22 |
+
|
| 23 |
+
<!-- Provide a longer summary of what this model is. -->
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
- **Developed by:** [More Information Needed]
|
| 28 |
+
- **Funded by [optional]:** [More Information Needed]
|
| 29 |
+
- **Shared by [optional]:** [More Information Needed]
|
| 30 |
+
- **Model type:** [More Information Needed]
|
| 31 |
+
- **Language(s) (NLP):** [More Information Needed]
|
| 32 |
+
- **License:** [More Information Needed]
|
| 33 |
+
- **Finetuned from model [optional]:** [More Information Needed]
|
| 34 |
+
|
| 35 |
+
### Model Sources [optional]
|
| 36 |
+
|
| 37 |
+
<!-- Provide the basic links for the model. -->
|
| 38 |
+
|
| 39 |
+
- **Repository:** [More Information Needed]
|
| 40 |
+
- **Paper [optional]:** [More Information Needed]
|
| 41 |
+
- **Demo [optional]:** [More Information Needed]
|
| 42 |
+
|
| 43 |
+
## Uses
|
| 44 |
+
|
| 45 |
+
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
| 46 |
+
|
| 47 |
+
### Direct Use
|
| 48 |
+
|
| 49 |
+
<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
|
| 50 |
+
|
| 51 |
+
[More Information Needed]
|
| 52 |
+
|
| 53 |
+
### Downstream Use [optional]
|
| 54 |
+
|
| 55 |
+
<!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
|
| 56 |
+
|
| 57 |
+
[More Information Needed]
|
| 58 |
+
|
| 59 |
+
### Out-of-Scope Use
|
| 60 |
+
|
| 61 |
+
<!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
|
| 62 |
+
|
| 63 |
+
[More Information Needed]
|
| 64 |
+
|
| 65 |
+
## Bias, Risks, and Limitations
|
| 66 |
+
|
| 67 |
+
<!-- This section is meant to convey both technical and sociotechnical limitations. -->
|
| 68 |
+
|
| 69 |
+
[More Information Needed]
|
| 70 |
+
|
| 71 |
+
### Recommendations
|
| 72 |
+
|
| 73 |
+
<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
|
| 74 |
+
|
| 75 |
+
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
|
| 76 |
+
|
| 77 |
+
## How to Get Started with the Model
|
| 78 |
+
|
| 79 |
+
Use the code below to get started with the model.
|
| 80 |
+
|
| 81 |
+
[More Information Needed]
|
| 82 |
+
|
| 83 |
+
## Training Details
|
| 84 |
+
|
| 85 |
+
### Training Data
|
| 86 |
+
|
| 87 |
+
<!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
|
| 88 |
+
|
| 89 |
+
[More Information Needed]
|
| 90 |
+
|
| 91 |
+
### Training Procedure
|
| 92 |
+
|
| 93 |
+
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
|
| 94 |
+
|
| 95 |
+
#### Preprocessing [optional]
|
| 96 |
+
|
| 97 |
+
[More Information Needed]
|
| 98 |
+
|
| 99 |
+
|
| 100 |
+
#### Training Hyperparameters
|
| 101 |
+
|
| 102 |
+
- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
|
| 103 |
+
|
| 104 |
+
#### Speeds, Sizes, Times [optional]
|
| 105 |
+
|
| 106 |
+
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
| 107 |
+
|
| 108 |
+
[More Information Needed]
|
| 109 |
+
|
| 110 |
+
## Evaluation
|
| 111 |
+
|
| 112 |
+
<!-- This section describes the evaluation protocols and provides the results. -->
|
| 113 |
+
|
| 114 |
+
### Testing Data, Factors & Metrics
|
| 115 |
+
|
| 116 |
+
#### Testing Data
|
| 117 |
+
|
| 118 |
+
<!-- This should link to a Dataset Card if possible. -->
|
| 119 |
+
|
| 120 |
+
[More Information Needed]
|
| 121 |
+
|
| 122 |
+
#### Factors
|
| 123 |
+
|
| 124 |
+
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
| 125 |
+
|
| 126 |
+
[More Information Needed]
|
| 127 |
+
|
| 128 |
+
#### Metrics
|
| 129 |
+
|
| 130 |
+
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
| 131 |
+
|
| 132 |
+
[More Information Needed]
|
| 133 |
+
|
| 134 |
+
### Results
|
| 135 |
+
|
| 136 |
+
[More Information Needed]
|
| 137 |
+
|
| 138 |
+
#### Summary
|
| 139 |
+
|
| 140 |
+
|
| 141 |
+
|
| 142 |
+
## Model Examination [optional]
|
| 143 |
+
|
| 144 |
+
<!-- Relevant interpretability work for the model goes here -->
|
| 145 |
+
|
| 146 |
+
[More Information Needed]
|
| 147 |
+
|
| 148 |
+
## Environmental Impact
|
| 149 |
+
|
| 150 |
+
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
| 151 |
+
|
| 152 |
+
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
|
| 153 |
+
|
| 154 |
+
- **Hardware Type:** [More Information Needed]
|
| 155 |
+
- **Hours used:** [More Information Needed]
|
| 156 |
+
- **Cloud Provider:** [More Information Needed]
|
| 157 |
+
- **Compute Region:** [More Information Needed]
|
| 158 |
+
- **Carbon Emitted:** [More Information Needed]
|
| 159 |
+
|
| 160 |
+
## Technical Specifications [optional]
|
| 161 |
+
|
| 162 |
+
### Model Architecture and Objective
|
| 163 |
+
|
| 164 |
+
[More Information Needed]
|
| 165 |
+
|
| 166 |
+
### Compute Infrastructure
|
| 167 |
+
|
| 168 |
+
[More Information Needed]
|
| 169 |
+
|
| 170 |
+
#### Hardware
|
| 171 |
+
|
| 172 |
+
[More Information Needed]
|
| 173 |
+
|
| 174 |
+
#### Software
|
| 175 |
+
|
| 176 |
+
[More Information Needed]
|
| 177 |
+
|
| 178 |
+
## Citation [optional]
|
| 179 |
+
|
| 180 |
+
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
| 181 |
+
|
| 182 |
+
**BibTeX:**
|
| 183 |
+
|
| 184 |
+
[More Information Needed]
|
| 185 |
+
|
| 186 |
+
**APA:**
|
| 187 |
+
|
| 188 |
+
[More Information Needed]
|
| 189 |
+
|
| 190 |
+
## Glossary [optional]
|
| 191 |
+
|
| 192 |
+
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
| 193 |
+
|
| 194 |
+
[More Information Needed]
|
| 195 |
+
|
| 196 |
+
## More Information [optional]
|
| 197 |
+
|
| 198 |
+
[More Information Needed]
|
| 199 |
+
|
| 200 |
+
## Model Card Authors [optional]
|
| 201 |
+
|
| 202 |
+
[More Information Needed]
|
| 203 |
+
|
| 204 |
+
## Model Card Contact
|
| 205 |
+
|
| 206 |
+
[More Information Needed]
|
| 207 |
+
### Framework versions
|
| 208 |
+
|
| 209 |
+
- PEFT 0.19.1
|
checkpoint-210/adapter_config.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"alora_invocation_tokens": null,
|
| 3 |
+
"alpha_pattern": {},
|
| 4 |
+
"arrow_config": null,
|
| 5 |
+
"auto_mapping": null,
|
| 6 |
+
"base_model_name_or_path": "Qwen/Qwen3.5-0.8B",
|
| 7 |
+
"bias": "none",
|
| 8 |
+
"corda_config": null,
|
| 9 |
+
"ensure_weight_tying": false,
|
| 10 |
+
"eva_config": null,
|
| 11 |
+
"exclude_modules": null,
|
| 12 |
+
"fan_in_fan_out": false,
|
| 13 |
+
"inference_mode": true,
|
| 14 |
+
"init_lora_weights": true,
|
| 15 |
+
"layer_replication": null,
|
| 16 |
+
"layers_pattern": null,
|
| 17 |
+
"layers_to_transform": null,
|
| 18 |
+
"loftq_config": {},
|
| 19 |
+
"lora_alpha": 32,
|
| 20 |
+
"lora_bias": false,
|
| 21 |
+
"lora_dropout": 0.1,
|
| 22 |
+
"lora_ga_config": null,
|
| 23 |
+
"megatron_config": null,
|
| 24 |
+
"megatron_core": "megatron.core",
|
| 25 |
+
"modules_to_save": null,
|
| 26 |
+
"peft_type": "LORA",
|
| 27 |
+
"peft_version": "0.19.1",
|
| 28 |
+
"qalora_group_size": 16,
|
| 29 |
+
"r": 16,
|
| 30 |
+
"rank_pattern": {},
|
| 31 |
+
"revision": null,
|
| 32 |
+
"target_modules": [
|
| 33 |
+
"o_proj",
|
| 34 |
+
"v_proj",
|
| 35 |
+
"down_proj",
|
| 36 |
+
"gate_proj",
|
| 37 |
+
"up_proj",
|
| 38 |
+
"k_proj",
|
| 39 |
+
"q_proj"
|
| 40 |
+
],
|
| 41 |
+
"target_parameters": null,
|
| 42 |
+
"task_type": "CAUSAL_LM",
|
| 43 |
+
"trainable_token_indices": null,
|
| 44 |
+
"use_bdlora": null,
|
| 45 |
+
"use_dora": false,
|
| 46 |
+
"use_qalora": false,
|
| 47 |
+
"use_rslora": false
|
| 48 |
+
}
|
checkpoint-210/adapter_model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5dba84793abf0374625ad8328e5feb343eadf311fdc3bf412593e1de5c7824e8
|
| 3 |
+
size 25584224
|
checkpoint-210/chat_template.jinja
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{%- set image_count = namespace(value=0) %}
|
| 2 |
+
{%- set video_count = namespace(value=0) %}
|
| 3 |
+
{%- macro render_content(content, do_vision_count, is_system_content=false) %}
|
| 4 |
+
{%- if content is string %}
|
| 5 |
+
{{- content }}
|
| 6 |
+
{%- elif content is iterable and content is not mapping %}
|
| 7 |
+
{%- for item in content %}
|
| 8 |
+
{%- if 'image' in item or 'image_url' in item or item.type == 'image' %}
|
| 9 |
+
{%- if is_system_content %}
|
| 10 |
+
{{- raise_exception('System message cannot contain images.') }}
|
| 11 |
+
{%- endif %}
|
| 12 |
+
{%- if do_vision_count %}
|
| 13 |
+
{%- set image_count.value = image_count.value + 1 %}
|
| 14 |
+
{%- endif %}
|
| 15 |
+
{%- if add_vision_id %}
|
| 16 |
+
{{- 'Picture ' ~ image_count.value ~ ': ' }}
|
| 17 |
+
{%- endif %}
|
| 18 |
+
{{- '<|vision_start|><|image_pad|><|vision_end|>' }}
|
| 19 |
+
{%- elif 'video' in item or item.type == 'video' %}
|
| 20 |
+
{%- if is_system_content %}
|
| 21 |
+
{{- raise_exception('System message cannot contain videos.') }}
|
| 22 |
+
{%- endif %}
|
| 23 |
+
{%- if do_vision_count %}
|
| 24 |
+
{%- set video_count.value = video_count.value + 1 %}
|
| 25 |
+
{%- endif %}
|
| 26 |
+
{%- if add_vision_id %}
|
| 27 |
+
{{- 'Video ' ~ video_count.value ~ ': ' }}
|
| 28 |
+
{%- endif %}
|
| 29 |
+
{{- '<|vision_start|><|video_pad|><|vision_end|>' }}
|
| 30 |
+
{%- elif 'text' in item %}
|
| 31 |
+
{{- item.text }}
|
| 32 |
+
{%- else %}
|
| 33 |
+
{{- raise_exception('Unexpected item type in content.') }}
|
| 34 |
+
{%- endif %}
|
| 35 |
+
{%- endfor %}
|
| 36 |
+
{%- elif content is none or content is undefined %}
|
| 37 |
+
{{- '' }}
|
| 38 |
+
{%- else %}
|
| 39 |
+
{{- raise_exception('Unexpected content type.') }}
|
| 40 |
+
{%- endif %}
|
| 41 |
+
{%- endmacro %}
|
| 42 |
+
{%- if not messages %}
|
| 43 |
+
{{- raise_exception('No messages provided.') }}
|
| 44 |
+
{%- endif %}
|
| 45 |
+
{%- if tools and tools is iterable and tools is not mapping %}
|
| 46 |
+
{{- '<|im_start|>system\n' }}
|
| 47 |
+
{{- "# Tools\n\nYou have access to the following functions:\n\n<tools>" }}
|
| 48 |
+
{%- for tool in tools %}
|
| 49 |
+
{{- "\n" }}
|
| 50 |
+
{{- tool | tojson }}
|
| 51 |
+
{%- endfor %}
|
| 52 |
+
{{- "\n</tools>" }}
|
| 53 |
+
{{- '\n\nIf you choose to call a function ONLY reply in the following format with NO suffix:\n\n<tool_call>\n<function=example_function_name>\n<parameter=example_parameter_1>\nvalue_1\n</parameter>\n<parameter=example_parameter_2>\nThis is the value for the second parameter\nthat can span\nmultiple lines\n</parameter>\n</function>\n</tool_call>\n\n<IMPORTANT>\nReminder:\n- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags\n- Required parameters MUST be specified\n- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after\n- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls\n</IMPORTANT>' }}
|
| 54 |
+
{%- if messages[0].role == 'system' %}
|
| 55 |
+
{%- set content = render_content(messages[0].content, false, true)|trim %}
|
| 56 |
+
{%- if content %}
|
| 57 |
+
{{- '\n\n' + content }}
|
| 58 |
+
{%- endif %}
|
| 59 |
+
{%- endif %}
|
| 60 |
+
{{- '<|im_end|>\n' }}
|
| 61 |
+
{%- else %}
|
| 62 |
+
{%- if messages[0].role == 'system' %}
|
| 63 |
+
{%- set content = render_content(messages[0].content, false, true)|trim %}
|
| 64 |
+
{{- '<|im_start|>system\n' + content + '<|im_end|>\n' }}
|
| 65 |
+
{%- endif %}
|
| 66 |
+
{%- endif %}
|
| 67 |
+
{%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}
|
| 68 |
+
{%- for message in messages[::-1] %}
|
| 69 |
+
{%- set index = (messages|length - 1) - loop.index0 %}
|
| 70 |
+
{%- if ns.multi_step_tool and message.role == "user" %}
|
| 71 |
+
{%- set content = render_content(message.content, false)|trim %}
|
| 72 |
+
{%- if not(content.startswith('<tool_response>') and content.endswith('</tool_response>')) %}
|
| 73 |
+
{%- set ns.multi_step_tool = false %}
|
| 74 |
+
{%- set ns.last_query_index = index %}
|
| 75 |
+
{%- endif %}
|
| 76 |
+
{%- endif %}
|
| 77 |
+
{%- endfor %}
|
| 78 |
+
{%- if ns.multi_step_tool %}
|
| 79 |
+
{{- raise_exception('No user query found in messages.') }}
|
| 80 |
+
{%- endif %}
|
| 81 |
+
{%- for message in messages %}
|
| 82 |
+
{%- set content = render_content(message.content, true)|trim %}
|
| 83 |
+
{%- if message.role == "system" %}
|
| 84 |
+
{%- if not loop.first %}
|
| 85 |
+
{{- raise_exception('System message must be at the beginning.') }}
|
| 86 |
+
{%- endif %}
|
| 87 |
+
{%- elif message.role == "user" %}
|
| 88 |
+
{{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }}
|
| 89 |
+
{%- elif message.role == "assistant" %}
|
| 90 |
+
{%- set reasoning_content = '' %}
|
| 91 |
+
{%- if message.reasoning_content is string %}
|
| 92 |
+
{%- set reasoning_content = message.reasoning_content %}
|
| 93 |
+
{%- else %}
|
| 94 |
+
{%- if '</think>' in content %}
|
| 95 |
+
{%- set reasoning_content = content.split('</think>')[0].rstrip('\n').split('<think>')[-1].lstrip('\n') %}
|
| 96 |
+
{%- set content = content.split('</think>')[-1].lstrip('\n') %}
|
| 97 |
+
{%- endif %}
|
| 98 |
+
{%- endif %}
|
| 99 |
+
{%- set reasoning_content = reasoning_content|trim %}
|
| 100 |
+
{%- if loop.index0 > ns.last_query_index %}
|
| 101 |
+
{{- '<|im_start|>' + message.role + '\n<think>\n' + reasoning_content + '\n</think>\n\n' + content }}
|
| 102 |
+
{%- else %}
|
| 103 |
+
{{- '<|im_start|>' + message.role + '\n' + content }}
|
| 104 |
+
{%- endif %}
|
| 105 |
+
{%- if message.tool_calls and message.tool_calls is iterable and message.tool_calls is not mapping %}
|
| 106 |
+
{%- for tool_call in message.tool_calls %}
|
| 107 |
+
{%- if tool_call.function is defined %}
|
| 108 |
+
{%- set tool_call = tool_call.function %}
|
| 109 |
+
{%- endif %}
|
| 110 |
+
{%- if loop.first %}
|
| 111 |
+
{%- if content|trim %}
|
| 112 |
+
{{- '\n\n<tool_call>\n<function=' + tool_call.name + '>\n' }}
|
| 113 |
+
{%- else %}
|
| 114 |
+
{{- '<tool_call>\n<function=' + tool_call.name + '>\n' }}
|
| 115 |
+
{%- endif %}
|
| 116 |
+
{%- else %}
|
| 117 |
+
{{- '\n<tool_call>\n<function=' + tool_call.name + '>\n' }}
|
| 118 |
+
{%- endif %}
|
| 119 |
+
{%- if tool_call.arguments is defined %}
|
| 120 |
+
{%- for args_name, args_value in tool_call.arguments|items %}
|
| 121 |
+
{{- '<parameter=' + args_name + '>\n' }}
|
| 122 |
+
{%- set args_value = args_value | tojson | safe if args_value is mapping or (args_value is sequence and args_value is not string) else args_value | string %}
|
| 123 |
+
{{- args_value }}
|
| 124 |
+
{{- '\n</parameter>\n' }}
|
| 125 |
+
{%- endfor %}
|
| 126 |
+
{%- endif %}
|
| 127 |
+
{{- '</function>\n</tool_call>' }}
|
| 128 |
+
{%- endfor %}
|
| 129 |
+
{%- endif %}
|
| 130 |
+
{{- '<|im_end|>\n' }}
|
| 131 |
+
{%- elif message.role == "tool" %}
|
| 132 |
+
{%- if loop.previtem and loop.previtem.role != "tool" %}
|
| 133 |
+
{{- '<|im_start|>user' }}
|
| 134 |
+
{%- endif %}
|
| 135 |
+
{{- '\n<tool_response>\n' }}
|
| 136 |
+
{{- content }}
|
| 137 |
+
{{- '\n</tool_response>' }}
|
| 138 |
+
{%- if not loop.last and loop.nextitem.role != "tool" %}
|
| 139 |
+
{{- '<|im_end|>\n' }}
|
| 140 |
+
{%- elif loop.last %}
|
| 141 |
+
{{- '<|im_end|>\n' }}
|
| 142 |
+
{%- endif %}
|
| 143 |
+
{%- else %}
|
| 144 |
+
{{- raise_exception('Unexpected message role.') }}
|
| 145 |
+
{%- endif %}
|
| 146 |
+
{%- endfor %}
|
| 147 |
+
{%- if add_generation_prompt %}
|
| 148 |
+
{{- '<|im_start|>assistant\n' }}
|
| 149 |
+
{%- if enable_thinking is defined and enable_thinking is true %}
|
| 150 |
+
{{- '<think>\n' }}
|
| 151 |
+
{%- else %}
|
| 152 |
+
{{- '<think>\n\n</think>\n\n' }}
|
| 153 |
+
{%- endif %}
|
| 154 |
+
{%- endif %}
|
checkpoint-210/optimizer.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7462cc577846cc1bf071aa19dbfb0b1a78314e97b33469f214d0e64f499d71dc
|
| 3 |
+
size 51279371
|
checkpoint-210/rng_state.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4974ec239c2549be074e373710a60afc21f5391b070d9ef1191de9ebbccf9639
|
| 3 |
+
size 14391
|
checkpoint-210/scheduler.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a8a1b08a2c5178eb0492aca442a5dd9ddab5562077a63adcf0344f0d74d3a30c
|
| 3 |
+
size 1465
|
checkpoint-210/tokenizer.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:06b9509352d2af50381ab2247e083b80d32d5c0aba91c272ca9ff729b6a0e523
|
| 3 |
+
size 19989325
|
checkpoint-210/tokenizer_config.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_prefix_space": false,
|
| 3 |
+
"audio_bos_token": "<|audio_start|>",
|
| 4 |
+
"audio_eos_token": "<|audio_end|>",
|
| 5 |
+
"audio_token": "<|audio_pad|>",
|
| 6 |
+
"backend": "tokenizers",
|
| 7 |
+
"bos_token": null,
|
| 8 |
+
"clean_up_tokenization_spaces": false,
|
| 9 |
+
"eos_token": "<|im_end|>",
|
| 10 |
+
"errors": "replace",
|
| 11 |
+
"image_token": "<|image_pad|>",
|
| 12 |
+
"is_local": false,
|
| 13 |
+
"local_files_only": false,
|
| 14 |
+
"model_max_length": 262144,
|
| 15 |
+
"model_specific_special_tokens": {
|
| 16 |
+
"audio_bos_token": "<|audio_start|>",
|
| 17 |
+
"audio_eos_token": "<|audio_end|>",
|
| 18 |
+
"audio_token": "<|audio_pad|>",
|
| 19 |
+
"image_token": "<|image_pad|>",
|
| 20 |
+
"video_token": "<|video_pad|>",
|
| 21 |
+
"vision_bos_token": "<|vision_start|>",
|
| 22 |
+
"vision_eos_token": "<|vision_end|>"
|
| 23 |
+
},
|
| 24 |
+
"pad_token": "<|endoftext|>",
|
| 25 |
+
"pretokenize_regex": "(?i:'s|'t|'re|'ve|'m|'ll|'d)|[^\\r\\n\\p{L}\\p{N}]?[\\p{L}\\p{M}]+|\\p{N}| ?[^\\s\\p{L}\\p{M}\\p{N}]+[\\r\\n]*|\\s*[\\r\\n]+|\\s+(?!\\S)|\\s+",
|
| 26 |
+
"split_special_tokens": false,
|
| 27 |
+
"tokenizer_class": "Qwen2Tokenizer",
|
| 28 |
+
"unk_token": null,
|
| 29 |
+
"video_token": "<|video_pad|>",
|
| 30 |
+
"vision_bos_token": "<|vision_start|>",
|
| 31 |
+
"vision_eos_token": "<|vision_end|>"
|
| 32 |
+
}
|
checkpoint-210/trainer_state.json
ADDED
|
@@ -0,0 +1,454 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"best_global_step": null,
|
| 3 |
+
"best_metric": null,
|
| 4 |
+
"best_model_checkpoint": null,
|
| 5 |
+
"epoch": 2.0,
|
| 6 |
+
"eval_steps": 500,
|
| 7 |
+
"global_step": 210,
|
| 8 |
+
"is_hyper_param_search": false,
|
| 9 |
+
"is_local_process_zero": true,
|
| 10 |
+
"is_world_process_zero": true,
|
| 11 |
+
"log_history": [
|
| 12 |
+
{
|
| 13 |
+
"entropy": 2.1651801258325576,
|
| 14 |
+
"epoch": 0.04784688995215311,
|
| 15 |
+
"grad_norm": 4.052286148071289,
|
| 16 |
+
"learning_rate": 9.80952380952381e-05,
|
| 17 |
+
"loss": 2.560974884033203,
|
| 18 |
+
"mean_token_accuracy": 0.5812613397836686,
|
| 19 |
+
"num_tokens": 22163.0,
|
| 20 |
+
"step": 5
|
| 21 |
+
},
|
| 22 |
+
{
|
| 23 |
+
"entropy": 1.7820561587810517,
|
| 24 |
+
"epoch": 0.09569377990430622,
|
| 25 |
+
"grad_norm": 3.3570611476898193,
|
| 26 |
+
"learning_rate": 9.571428571428573e-05,
|
| 27 |
+
"loss": 1.5557975769042969,
|
| 28 |
+
"mean_token_accuracy": 0.7120864883065223,
|
| 29 |
+
"num_tokens": 44774.0,
|
| 30 |
+
"step": 10
|
| 31 |
+
},
|
| 32 |
+
{
|
| 33 |
+
"entropy": 0.9664318569004535,
|
| 34 |
+
"epoch": 0.14354066985645933,
|
| 35 |
+
"grad_norm": 2.2438340187072754,
|
| 36 |
+
"learning_rate": 9.333333333333334e-05,
|
| 37 |
+
"loss": 1.0039640426635743,
|
| 38 |
+
"mean_token_accuracy": 0.8314489215612412,
|
| 39 |
+
"num_tokens": 68554.0,
|
| 40 |
+
"step": 15
|
| 41 |
+
},
|
| 42 |
+
{
|
| 43 |
+
"entropy": 0.7952521093189716,
|
| 44 |
+
"epoch": 0.19138755980861244,
|
| 45 |
+
"grad_norm": 1.4970792531967163,
|
| 46 |
+
"learning_rate": 9.095238095238096e-05,
|
| 47 |
+
"loss": 0.9054213523864746,
|
| 48 |
+
"mean_token_accuracy": 0.8527463525533676,
|
| 49 |
+
"num_tokens": 92672.0,
|
| 50 |
+
"step": 20
|
| 51 |
+
},
|
| 52 |
+
{
|
| 53 |
+
"entropy": 0.7521916493773461,
|
| 54 |
+
"epoch": 0.23923444976076555,
|
| 55 |
+
"grad_norm": 1.1931730508804321,
|
| 56 |
+
"learning_rate": 8.857142857142857e-05,
|
| 57 |
+
"loss": 0.8049167633056641,
|
| 58 |
+
"mean_token_accuracy": 0.8651137307286263,
|
| 59 |
+
"num_tokens": 115556.0,
|
| 60 |
+
"step": 25
|
| 61 |
+
},
|
| 62 |
+
{
|
| 63 |
+
"entropy": 0.8046777091920376,
|
| 64 |
+
"epoch": 0.28708133971291866,
|
| 65 |
+
"grad_norm": 1.1074719429016113,
|
| 66 |
+
"learning_rate": 8.61904761904762e-05,
|
| 67 |
+
"loss": 0.8548135757446289,
|
| 68 |
+
"mean_token_accuracy": 0.8603784069418907,
|
| 69 |
+
"num_tokens": 140637.0,
|
| 70 |
+
"step": 30
|
| 71 |
+
},
|
| 72 |
+
{
|
| 73 |
+
"entropy": 0.6400977578014135,
|
| 74 |
+
"epoch": 0.3349282296650718,
|
| 75 |
+
"grad_norm": 0.9381627440452576,
|
| 76 |
+
"learning_rate": 8.380952380952382e-05,
|
| 77 |
+
"loss": 0.6987390518188477,
|
| 78 |
+
"mean_token_accuracy": 0.8840002715587616,
|
| 79 |
+
"num_tokens": 164217.0,
|
| 80 |
+
"step": 35
|
| 81 |
+
},
|
| 82 |
+
{
|
| 83 |
+
"entropy": 0.6654842033982277,
|
| 84 |
+
"epoch": 0.3827751196172249,
|
| 85 |
+
"grad_norm": 2.1283178329467773,
|
| 86 |
+
"learning_rate": 8.142857142857143e-05,
|
| 87 |
+
"loss": 0.7857039928436279,
|
| 88 |
+
"mean_token_accuracy": 0.8724030137062073,
|
| 89 |
+
"num_tokens": 186852.0,
|
| 90 |
+
"step": 40
|
| 91 |
+
},
|
| 92 |
+
{
|
| 93 |
+
"entropy": 0.619146254658699,
|
| 94 |
+
"epoch": 0.430622009569378,
|
| 95 |
+
"grad_norm": 0.8456487059593201,
|
| 96 |
+
"learning_rate": 7.904761904761905e-05,
|
| 97 |
+
"loss": 0.6680184364318847,
|
| 98 |
+
"mean_token_accuracy": 0.8887932941317558,
|
| 99 |
+
"num_tokens": 210073.0,
|
| 100 |
+
"step": 45
|
| 101 |
+
},
|
| 102 |
+
{
|
| 103 |
+
"entropy": 0.6058806985616684,
|
| 104 |
+
"epoch": 0.4784688995215311,
|
| 105 |
+
"grad_norm": 0.8580911159515381,
|
| 106 |
+
"learning_rate": 7.666666666666667e-05,
|
| 107 |
+
"loss": 0.6658339977264405,
|
| 108 |
+
"mean_token_accuracy": 0.8919811978936195,
|
| 109 |
+
"num_tokens": 233395.0,
|
| 110 |
+
"step": 50
|
| 111 |
+
},
|
| 112 |
+
{
|
| 113 |
+
"entropy": 0.6354636650532484,
|
| 114 |
+
"epoch": 0.5263157894736842,
|
| 115 |
+
"grad_norm": 0.9746028780937195,
|
| 116 |
+
"learning_rate": 7.428571428571429e-05,
|
| 117 |
+
"loss": 0.728534460067749,
|
| 118 |
+
"mean_token_accuracy": 0.8858045786619186,
|
| 119 |
+
"num_tokens": 256677.0,
|
| 120 |
+
"step": 55
|
| 121 |
+
},
|
| 122 |
+
{
|
| 123 |
+
"entropy": 0.5936117857694626,
|
| 124 |
+
"epoch": 0.5741626794258373,
|
| 125 |
+
"grad_norm": 0.9922609925270081,
|
| 126 |
+
"learning_rate": 7.19047619047619e-05,
|
| 127 |
+
"loss": 0.6770713806152344,
|
| 128 |
+
"mean_token_accuracy": 0.8887649178504944,
|
| 129 |
+
"num_tokens": 278351.0,
|
| 130 |
+
"step": 60
|
| 131 |
+
},
|
| 132 |
+
{
|
| 133 |
+
"entropy": 0.6688867088407278,
|
| 134 |
+
"epoch": 0.6220095693779905,
|
| 135 |
+
"grad_norm": 0.9844464659690857,
|
| 136 |
+
"learning_rate": 6.952380952380952e-05,
|
| 137 |
+
"loss": 0.7745152950286865,
|
| 138 |
+
"mean_token_accuracy": 0.8777409210801125,
|
| 139 |
+
"num_tokens": 303271.0,
|
| 140 |
+
"step": 65
|
| 141 |
+
},
|
| 142 |
+
{
|
| 143 |
+
"entropy": 0.7457825832068921,
|
| 144 |
+
"epoch": 0.6698564593301436,
|
| 145 |
+
"grad_norm": 0.9128448367118835,
|
| 146 |
+
"learning_rate": 6.714285714285714e-05,
|
| 147 |
+
"loss": 0.8470640182495117,
|
| 148 |
+
"mean_token_accuracy": 0.8637880578637123,
|
| 149 |
+
"num_tokens": 328315.0,
|
| 150 |
+
"step": 70
|
| 151 |
+
},
|
| 152 |
+
{
|
| 153 |
+
"entropy": 0.6116038627922535,
|
| 154 |
+
"epoch": 0.7177033492822966,
|
| 155 |
+
"grad_norm": 0.9624145030975342,
|
| 156 |
+
"learning_rate": 6.476190476190477e-05,
|
| 157 |
+
"loss": 0.6843190670013428,
|
| 158 |
+
"mean_token_accuracy": 0.8896616101264954,
|
| 159 |
+
"num_tokens": 351963.0,
|
| 160 |
+
"step": 75
|
| 161 |
+
},
|
| 162 |
+
{
|
| 163 |
+
"entropy": 0.622330765798688,
|
| 164 |
+
"epoch": 0.7655502392344498,
|
| 165 |
+
"grad_norm": 0.9209601879119873,
|
| 166 |
+
"learning_rate": 6.238095238095239e-05,
|
| 167 |
+
"loss": 0.6767851829528808,
|
| 168 |
+
"mean_token_accuracy": 0.8867631480097771,
|
| 169 |
+
"num_tokens": 375023.0,
|
| 170 |
+
"step": 80
|
| 171 |
+
},
|
| 172 |
+
{
|
| 173 |
+
"entropy": 0.6198485180735588,
|
| 174 |
+
"epoch": 0.8133971291866029,
|
| 175 |
+
"grad_norm": 0.946159303188324,
|
| 176 |
+
"learning_rate": 6e-05,
|
| 177 |
+
"loss": 0.6652565956115722,
|
| 178 |
+
"mean_token_accuracy": 0.8853679791092872,
|
| 179 |
+
"num_tokens": 399277.0,
|
| 180 |
+
"step": 85
|
| 181 |
+
},
|
| 182 |
+
{
|
| 183 |
+
"entropy": 0.5564446035772562,
|
| 184 |
+
"epoch": 0.861244019138756,
|
| 185 |
+
"grad_norm": 0.8137181401252747,
|
| 186 |
+
"learning_rate": 5.761904761904762e-05,
|
| 187 |
+
"loss": 0.6248233795166016,
|
| 188 |
+
"mean_token_accuracy": 0.8972864270210266,
|
| 189 |
+
"num_tokens": 421249.0,
|
| 190 |
+
"step": 90
|
| 191 |
+
},
|
| 192 |
+
{
|
| 193 |
+
"entropy": 0.5795138332992792,
|
| 194 |
+
"epoch": 0.9090909090909091,
|
| 195 |
+
"grad_norm": 0.851652204990387,
|
| 196 |
+
"learning_rate": 5.5238095238095244e-05,
|
| 197 |
+
"loss": 0.6658082008361816,
|
| 198 |
+
"mean_token_accuracy": 0.8966752380132675,
|
| 199 |
+
"num_tokens": 444070.0,
|
| 200 |
+
"step": 95
|
| 201 |
+
},
|
| 202 |
+
{
|
| 203 |
+
"entropy": 0.6267214026302099,
|
| 204 |
+
"epoch": 0.9569377990430622,
|
| 205 |
+
"grad_norm": 0.8740034103393555,
|
| 206 |
+
"learning_rate": 5.285714285714286e-05,
|
| 207 |
+
"loss": 0.7174222946166993,
|
| 208 |
+
"mean_token_accuracy": 0.880531644821167,
|
| 209 |
+
"num_tokens": 467253.0,
|
| 210 |
+
"step": 100
|
| 211 |
+
},
|
| 212 |
+
{
|
| 213 |
+
"entropy": 0.6104649793770578,
|
| 214 |
+
"epoch": 1.0,
|
| 215 |
+
"grad_norm": 1.397324800491333,
|
| 216 |
+
"learning_rate": 5.047619047619048e-05,
|
| 217 |
+
"loss": 0.723299789428711,
|
| 218 |
+
"mean_token_accuracy": 0.8877596159776052,
|
| 219 |
+
"num_tokens": 489018.0,
|
| 220 |
+
"step": 105
|
| 221 |
+
},
|
| 222 |
+
{
|
| 223 |
+
"entropy": 0.6409125056117773,
|
| 224 |
+
"epoch": 1.0478468899521531,
|
| 225 |
+
"grad_norm": 0.7727960348129272,
|
| 226 |
+
"learning_rate": 4.80952380952381e-05,
|
| 227 |
+
"loss": 0.646695899963379,
|
| 228 |
+
"mean_token_accuracy": 0.8852975755929947,
|
| 229 |
+
"num_tokens": 513248.0,
|
| 230 |
+
"step": 110
|
| 231 |
+
},
|
| 232 |
+
{
|
| 233 |
+
"entropy": 0.5359640445560216,
|
| 234 |
+
"epoch": 1.0956937799043063,
|
| 235 |
+
"grad_norm": 0.7002193927764893,
|
| 236 |
+
"learning_rate": 4.5714285714285716e-05,
|
| 237 |
+
"loss": 0.5828539848327636,
|
| 238 |
+
"mean_token_accuracy": 0.9033631831407547,
|
| 239 |
+
"num_tokens": 536083.0,
|
| 240 |
+
"step": 115
|
| 241 |
+
},
|
| 242 |
+
{
|
| 243 |
+
"entropy": 0.5877869483083487,
|
| 244 |
+
"epoch": 1.1435406698564594,
|
| 245 |
+
"grad_norm": 0.8519774079322815,
|
| 246 |
+
"learning_rate": 4.3333333333333334e-05,
|
| 247 |
+
"loss": 0.6564444065093994,
|
| 248 |
+
"mean_token_accuracy": 0.8940910667181015,
|
| 249 |
+
"num_tokens": 559396.0,
|
| 250 |
+
"step": 120
|
| 251 |
+
},
|
| 252 |
+
{
|
| 253 |
+
"entropy": 0.5784575771540403,
|
| 254 |
+
"epoch": 1.1913875598086126,
|
| 255 |
+
"grad_norm": 0.8621901273727417,
|
| 256 |
+
"learning_rate": 4.095238095238095e-05,
|
| 257 |
+
"loss": 0.6363758087158203,
|
| 258 |
+
"mean_token_accuracy": 0.8952302411198616,
|
| 259 |
+
"num_tokens": 582746.0,
|
| 260 |
+
"step": 125
|
| 261 |
+
},
|
| 262 |
+
{
|
| 263 |
+
"entropy": 0.6027569387108087,
|
| 264 |
+
"epoch": 1.2392344497607655,
|
| 265 |
+
"grad_norm": 0.9358822703361511,
|
| 266 |
+
"learning_rate": 3.857142857142858e-05,
|
| 267 |
+
"loss": 0.6765194416046143,
|
| 268 |
+
"mean_token_accuracy": 0.8874293357133866,
|
| 269 |
+
"num_tokens": 606214.0,
|
| 270 |
+
"step": 130
|
| 271 |
+
},
|
| 272 |
+
{
|
| 273 |
+
"entropy": 0.611118633300066,
|
| 274 |
+
"epoch": 1.2870813397129186,
|
| 275 |
+
"grad_norm": 0.8267807960510254,
|
| 276 |
+
"learning_rate": 3.619047619047619e-05,
|
| 277 |
+
"loss": 0.6723567008972168,
|
| 278 |
+
"mean_token_accuracy": 0.8883729502558708,
|
| 279 |
+
"num_tokens": 630076.0,
|
| 280 |
+
"step": 135
|
| 281 |
+
},
|
| 282 |
+
{
|
| 283 |
+
"entropy": 0.5769705072045326,
|
| 284 |
+
"epoch": 1.3349282296650717,
|
| 285 |
+
"grad_norm": 0.7842361927032471,
|
| 286 |
+
"learning_rate": 3.380952380952381e-05,
|
| 287 |
+
"loss": 0.6243512630462646,
|
| 288 |
+
"mean_token_accuracy": 0.8933283373713493,
|
| 289 |
+
"num_tokens": 653859.0,
|
| 290 |
+
"step": 140
|
| 291 |
+
},
|
| 292 |
+
{
|
| 293 |
+
"entropy": 0.6102541331201792,
|
| 294 |
+
"epoch": 1.3827751196172249,
|
| 295 |
+
"grad_norm": 0.8129627704620361,
|
| 296 |
+
"learning_rate": 3.142857142857143e-05,
|
| 297 |
+
"loss": 0.6874077796936036,
|
| 298 |
+
"mean_token_accuracy": 0.8832434669137001,
|
| 299 |
+
"num_tokens": 677327.0,
|
| 300 |
+
"step": 145
|
| 301 |
+
},
|
| 302 |
+
{
|
| 303 |
+
"entropy": 0.6099541481584311,
|
| 304 |
+
"epoch": 1.430622009569378,
|
| 305 |
+
"grad_norm": 0.7526546716690063,
|
| 306 |
+
"learning_rate": 2.9047619047619052e-05,
|
| 307 |
+
"loss": 0.6641890048980713,
|
| 308 |
+
"mean_token_accuracy": 0.8834606483578682,
|
| 309 |
+
"num_tokens": 701682.0,
|
| 310 |
+
"step": 150
|
| 311 |
+
},
|
| 312 |
+
{
|
| 313 |
+
"entropy": 0.6001380123198032,
|
| 314 |
+
"epoch": 1.4784688995215312,
|
| 315 |
+
"grad_norm": 0.8635663986206055,
|
| 316 |
+
"learning_rate": 2.6666666666666667e-05,
|
| 317 |
+
"loss": 0.6789334774017334,
|
| 318 |
+
"mean_token_accuracy": 0.8867474034428596,
|
| 319 |
+
"num_tokens": 725375.0,
|
| 320 |
+
"step": 155
|
| 321 |
+
},
|
| 322 |
+
{
|
| 323 |
+
"entropy": 0.6042792610824108,
|
| 324 |
+
"epoch": 1.526315789473684,
|
| 325 |
+
"grad_norm": 0.8883793354034424,
|
| 326 |
+
"learning_rate": 2.4285714285714288e-05,
|
| 327 |
+
"loss": 0.6333177089691162,
|
| 328 |
+
"mean_token_accuracy": 0.8881407305598259,
|
| 329 |
+
"num_tokens": 748854.0,
|
| 330 |
+
"step": 160
|
| 331 |
+
},
|
| 332 |
+
{
|
| 333 |
+
"entropy": 0.524115451797843,
|
| 334 |
+
"epoch": 1.5741626794258372,
|
| 335 |
+
"grad_norm": 0.7244672775268555,
|
| 336 |
+
"learning_rate": 2.1904761904761906e-05,
|
| 337 |
+
"loss": 0.5796619892120362,
|
| 338 |
+
"mean_token_accuracy": 0.9032144501805306,
|
| 339 |
+
"num_tokens": 771536.0,
|
| 340 |
+
"step": 165
|
| 341 |
+
},
|
| 342 |
+
{
|
| 343 |
+
"entropy": 0.5471004392951727,
|
| 344 |
+
"epoch": 1.6220095693779903,
|
| 345 |
+
"grad_norm": 0.8835629224777222,
|
| 346 |
+
"learning_rate": 1.9523809523809524e-05,
|
| 347 |
+
"loss": 0.6003574371337891,
|
| 348 |
+
"mean_token_accuracy": 0.8971484303474426,
|
| 349 |
+
"num_tokens": 793900.0,
|
| 350 |
+
"step": 170
|
| 351 |
+
},
|
| 352 |
+
{
|
| 353 |
+
"entropy": 0.6230863776057959,
|
| 354 |
+
"epoch": 1.6698564593301435,
|
| 355 |
+
"grad_norm": 0.8581238389015198,
|
| 356 |
+
"learning_rate": 1.7142857142857145e-05,
|
| 357 |
+
"loss": 0.7287740707397461,
|
| 358 |
+
"mean_token_accuracy": 0.8850353598594666,
|
| 359 |
+
"num_tokens": 818273.0,
|
| 360 |
+
"step": 175
|
| 361 |
+
},
|
| 362 |
+
{
|
| 363 |
+
"entropy": 0.5712798546999693,
|
| 364 |
+
"epoch": 1.7177033492822966,
|
| 365 |
+
"grad_norm": 0.8643863797187805,
|
| 366 |
+
"learning_rate": 1.4761904761904763e-05,
|
| 367 |
+
"loss": 0.6351244926452637,
|
| 368 |
+
"mean_token_accuracy": 0.8935175597667694,
|
| 369 |
+
"num_tokens": 841778.0,
|
| 370 |
+
"step": 180
|
| 371 |
+
},
|
| 372 |
+
{
|
| 373 |
+
"entropy": 0.5254735369235277,
|
| 374 |
+
"epoch": 1.7655502392344498,
|
| 375 |
+
"grad_norm": 0.9475647807121277,
|
| 376 |
+
"learning_rate": 1.2380952380952381e-05,
|
| 377 |
+
"loss": 0.5964117527008057,
|
| 378 |
+
"mean_token_accuracy": 0.9012993037700653,
|
| 379 |
+
"num_tokens": 864591.0,
|
| 380 |
+
"step": 185
|
| 381 |
+
},
|
| 382 |
+
{
|
| 383 |
+
"entropy": 0.5567632585763931,
|
| 384 |
+
"epoch": 1.813397129186603,
|
| 385 |
+
"grad_norm": 0.7951871156692505,
|
| 386 |
+
"learning_rate": 1e-05,
|
| 387 |
+
"loss": 0.5931246280670166,
|
| 388 |
+
"mean_token_accuracy": 0.897057680785656,
|
| 389 |
+
"num_tokens": 887876.0,
|
| 390 |
+
"step": 190
|
| 391 |
+
},
|
| 392 |
+
{
|
| 393 |
+
"entropy": 0.6068938117474317,
|
| 394 |
+
"epoch": 1.861244019138756,
|
| 395 |
+
"grad_norm": 0.8280668258666992,
|
| 396 |
+
"learning_rate": 7.6190476190476205e-06,
|
| 397 |
+
"loss": 0.676881980895996,
|
| 398 |
+
"mean_token_accuracy": 0.8875841274857521,
|
| 399 |
+
"num_tokens": 912470.0,
|
| 400 |
+
"step": 195
|
| 401 |
+
},
|
| 402 |
+
{
|
| 403 |
+
"entropy": 0.49752707965672016,
|
| 404 |
+
"epoch": 1.9090909090909092,
|
| 405 |
+
"grad_norm": 0.8685581684112549,
|
| 406 |
+
"learning_rate": 5.2380952380952384e-06,
|
| 407 |
+
"loss": 0.5316107749938965,
|
| 408 |
+
"mean_token_accuracy": 0.9095863461494446,
|
| 409 |
+
"num_tokens": 934358.0,
|
| 410 |
+
"step": 200
|
| 411 |
+
},
|
| 412 |
+
{
|
| 413 |
+
"entropy": 0.5345557902008296,
|
| 414 |
+
"epoch": 1.9569377990430623,
|
| 415 |
+
"grad_norm": 0.9313185214996338,
|
| 416 |
+
"learning_rate": 2.8571428571428573e-06,
|
| 417 |
+
"loss": 0.5797445774078369,
|
| 418 |
+
"mean_token_accuracy": 0.9045627474784851,
|
| 419 |
+
"num_tokens": 956852.0,
|
| 420 |
+
"step": 205
|
| 421 |
+
},
|
| 422 |
+
{
|
| 423 |
+
"entropy": 0.5808272701170709,
|
| 424 |
+
"epoch": 2.0,
|
| 425 |
+
"grad_norm": 1.4462640285491943,
|
| 426 |
+
"learning_rate": 4.761904761904763e-07,
|
| 427 |
+
"loss": 0.6747049331665039,
|
| 428 |
+
"mean_token_accuracy": 0.893244668841362,
|
| 429 |
+
"num_tokens": 978036.0,
|
| 430 |
+
"step": 210
|
| 431 |
+
}
|
| 432 |
+
],
|
| 433 |
+
"logging_steps": 5,
|
| 434 |
+
"max_steps": 210,
|
| 435 |
+
"num_input_tokens_seen": 0,
|
| 436 |
+
"num_train_epochs": 2,
|
| 437 |
+
"save_steps": 500,
|
| 438 |
+
"stateful_callbacks": {
|
| 439 |
+
"TrainerControl": {
|
| 440 |
+
"args": {
|
| 441 |
+
"should_epoch_stop": false,
|
| 442 |
+
"should_evaluate": false,
|
| 443 |
+
"should_log": false,
|
| 444 |
+
"should_save": true,
|
| 445 |
+
"should_training_stop": true
|
| 446 |
+
},
|
| 447 |
+
"attributes": {}
|
| 448 |
+
}
|
| 449 |
+
},
|
| 450 |
+
"total_flos": 2960533186942464.0,
|
| 451 |
+
"train_batch_size": 1,
|
| 452 |
+
"trial_name": null,
|
| 453 |
+
"trial_params": null
|
| 454 |
+
}
|
checkpoint-210/training_args.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3d7f1960e9dbaf314c7e9b04bfe8d6b254d09770f3dd0af5f28a54c56991b5cd
|
| 3 |
+
size 5713
|
docs/H3_FORMAT_README.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Script-LoRA → MiniMax H3 format
|
| 2 |
+
|
| 3 |
+
## Data locations
|
| 4 |
+
|
| 5 |
+
| Path | Role |
|
| 6 |
+
|------|------|
|
| 7 |
+
| `../scriptlib/` | **102 screenplays** (`.txt`) — original training library |
|
| 8 |
+
| `../TVTropesData/` | Trope/title tables for scenario variety |
|
| 9 |
+
| `../final/` | Existing PEFT adapter (story craft + tropes, classic screenplay style) |
|
| 10 |
+
| `train_dataset.jsonl` | Hand-written H3 seed examples |
|
| 11 |
+
| `train_dataset.full.jsonl` | Built from scriptlib (+ tropes + seed) |
|
| 12 |
+
|
| 13 |
+
## Recommended path (continue-train, not merge-from-scratch)
|
| 14 |
+
|
| 15 |
+
The existing `final/` adapter already holds script + TVTropes knowledge. You do
|
| 16 |
+
**not** need a LoRA merge of two adapters unless you train a separate format-only
|
| 17 |
+
adapter. Prefer:
|
| 18 |
+
|
| 19 |
+
```bash
|
| 20 |
+
cd /home/bbear/Documents/OlympusServer/models/script-lora/h3-format
|
| 21 |
+
|
| 22 |
+
# Use the OlympusServer venv (system python lacks datasets/trl/peft)
|
| 23 |
+
VENV=/home/bbear/Documents/OlympusServer/.venv/bin/python
|
| 24 |
+
|
| 25 |
+
# 1) Build SFT rows from scriptlib (rewrite + premise) + TVTropes seeds
|
| 26 |
+
$VENV build_sft_from_scriptlib.py \
|
| 27 |
+
--include-seed \
|
| 28 |
+
--chunks-per-script 4 \
|
| 29 |
+
--tropes 80 \
|
| 30 |
+
--out train_dataset.full.jsonl
|
| 31 |
+
|
| 32 |
+
# 2) Continue-train from final/ → h3-v1 (does not overwrite final/)
|
| 33 |
+
# This host: torch is XPU-only → use --device xpu (not cuda)
|
| 34 |
+
$VENV train_script_lora_h3.py \
|
| 35 |
+
--dataset train_dataset.full.jsonl \
|
| 36 |
+
--init-from ../final \
|
| 37 |
+
--epochs 2 \
|
| 38 |
+
--lr 1e-4 \
|
| 39 |
+
--device xpu
|
| 40 |
+
```
|
| 41 |
+
|
| 42 |
+
Output: `../h3-v1/`. Point the generation slot at that adapter after validation.
|
| 43 |
+
|
| 44 |
+
### Why not “merge” alone?
|
| 45 |
+
|
| 46 |
+
- **Weighted LoRA merge** needs two trained adapters. Today you have one (`final/`).
|
| 47 |
+
- **Continue-train** from `final/` on H3-format chat data is the practical merge of
|
| 48 |
+
*skills*: old weights + new format supervision.
|
| 49 |
+
- Optional later: train a thin format-only LoRA and `add_weighted_adapter` with `final/`.
|
| 50 |
+
|
| 51 |
+
## Runtime (already live without retrain)
|
| 52 |
+
|
| 53 |
+
Backlot system prompts emit H3 FL2VA fields regardless of adapter:
|
| 54 |
+
|
| 55 |
+
- `backend/services/h3_prompt_format.py`
|
| 56 |
+
- `/generate/script`, `/generate/script/scene` → `h3_video_prompt`, `storyboard_prompt`
|
| 57 |
+
|
| 58 |
+
Guides: `optimization/h3-shrink/docs/VIDEO_PROMPT_{base,ref}-en.txt`
|
docs/VIDEO_PROMPT_base-en.txt
ADDED
|
@@ -0,0 +1,222 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Video Prompt Writing Guide (T2VA / I2VA / FL2VA / L2VA)
|
| 2 |
+
|
| 3 |
+
## 1. Task Overview
|
| 4 |
+
|
| 5 |
+
- **T2VA**: Builds a complete audiovisual timeline from text.
|
| 6 |
+
- **I2VA**: T2VA body + first-frame instruction + a visual path that develops forward from the first frame.
|
| 7 |
+
- **FL2VA**: T2VA body + first-and-last-frame instruction + a continuous path from the first frame to the last frame.
|
| 8 |
+
- **L2VA**: T2VA body + last-frame instruction + a path that converges from a plausible preceding state to the last frame.
|
| 9 |
+
|
| 10 |
+
## 2. Final Prompt Structure
|
| 11 |
+
|
| 12 |
+
### 2.1 Part One Is the Instruction
|
| 13 |
+
|
| 14 |
+
**T2VA** has no image-alignment instruction and begins directly with the three core fields.
|
| 15 |
+
|
| 16 |
+
**I2VA** always uses:
|
| 17 |
+
|
| 18 |
+
```text
|
| 19 |
+
For the target video, at 0.00 seconds into the target video, <Picture 1> (from [Shot 1]) is fully referenced.
|
| 20 |
+
```
|
| 21 |
+
|
| 22 |
+
**FL2VA** always uses:
|
| 23 |
+
|
| 24 |
+
```text
|
| 25 |
+
How the reference pictures align with the target video — Picture 1 (from Shot 1) aligns with the 0.00-second mark of the target video; Picture 2 (from Shot N) aligns with the S.SS-second mark of the target video.
|
| 26 |
+
```
|
| 27 |
+
|
| 28 |
+
**L2VA** always uses:
|
| 29 |
+
|
| 30 |
+
```text
|
| 31 |
+
How the reference pictures align with the target video — <Picture 1> (from [Shot N]) aligns with the S.SS-second mark of the target video.
|
| 32 |
+
```
|
| 33 |
+
|
| 34 |
+
Here, `N` is the index of the actual final shot, and `S.SS` is the effective video duration formatted to exactly two decimal places. The instruction must be the first line of the final prompt, followed by one blank line before the core fields.
|
| 35 |
+
|
| 36 |
+
### 2.2 Part Two Contains the Three Core Fields
|
| 37 |
+
|
| 38 |
+
```text
|
| 39 |
+
integrated_multimodal_description: [Shot 1] ...
|
| 40 |
+
|
| 41 |
+
overall_soundscape: ...
|
| 42 |
+
|
| 43 |
+
non_diegetic_music: ...
|
| 44 |
+
```
|
| 45 |
+
|
| 46 |
+
- **integrated_multimodal_description**: Describes visuals, actions, shots, speakers, dialogue, singing, and diegetic audio along the timeline.
|
| 47 |
+
- **overall_soundscape**: Summarizes ambient sound, physical action sounds, and non-verbal human sounds across the entire video.
|
| 48 |
+
- **non_diegetic_music**: Describes background music that the characters cannot hear and only the audience can hear.
|
| 49 |
+
|
| 50 |
+
## 3. How to Incorporate Keyframes into the Multimodal Description
|
| 51 |
+
|
| 52 |
+
### 3.1 I2VA: Begin from the Image and Develop Forward
|
| 53 |
+
|
| 54 |
+
`<Picture 1>` is the actual first frame of the video at 0.00 seconds and belongs to `[Shot 1]`. The description should first establish the style, subjects, composition, and scene anchors in the image, then describe the next action. Character identity, clothing, colors, key objects, and spatial relationships should remain consistent.
|
| 55 |
+
|
| 56 |
+
Recommended structure: **first-frame anchor → action onset → continuous development → result or reaction**.
|
| 57 |
+
|
| 58 |
+
### 3.2 FL2VA: Describe the Path Between the First and Last Frames
|
| 59 |
+
|
| 60 |
+
Picture 1 is the opening, and Picture 2 is the ending. Focus on how the subject moves, how poses change, how objects are manipulated, how the composition evolves, and how the scene or lighting transitions.
|
| 61 |
+
|
| 62 |
+
FL2VA generally favors a single shot so the model can interpolate continuously from the first frame to the last frame. Use multiple shots only when they are explicitly specified. The last frame must be reached by the final `[Shot N]` at the end of the video.
|
| 63 |
+
|
| 64 |
+
Recommended structure: **first-frame state → observable intermediate changes → progressively narrowing differences → last-frame state**.
|
| 65 |
+
|
| 66 |
+
### 3.3 L2VA: Infer the Opening and Land on the Image at the End
|
| 67 |
+
|
| 68 |
+
`<Picture 1>` is the final frame of the video and belongs to the last `[Shot N]`; it does not inherently belong to Shot 1. Infer a plausible earlier state from the user's intent and the last frame, then describe how the characters, objects, camera, and scene gradually approach the reference image.
|
| 69 |
+
|
| 70 |
+
Recommended structure: **plausible preceding state → explicit action and transition path → gradual convergence in the final shot → last-frame landing**.
|
| 71 |
+
|
| 72 |
+
## 4. How to Write the Three Shared Core Sections
|
| 73 |
+
|
| 74 |
+
### 4.1 Develop the Multimodal Description Along the Timeline
|
| 75 |
+
|
| 76 |
+
`integrated_multimodal_description` is the main body of the rewritten prompt. Every detail should correspond to something visible or audible: visual style, initial composition, subject appearance and position, scene and key props, actions and reactions, shot changes, spoken language, and synchronized diegetic sound.
|
| 77 |
+
|
| 78 |
+
At the beginning of `[Shot 1]`, state the overall style and initial composition. Common styles include `Cinematic`, `live-action`, `2D-animated`, `3D CG`, `claymation`, `watercolor`, and `vintage film`. For keyframe tasks, derive the style from the reference image; for T2VA, select it from the user's text.
|
| 79 |
+
|
| 80 |
+
```text
|
| 81 |
+
[Shot 1] Live-action, cinematic, a medium-wide shot frames...
|
| 82 |
+
```
|
| 83 |
+
|
| 84 |
+
### 4.2 Shots and Cuts
|
| 85 |
+
|
| 86 |
+
Do not add a timestamp to the first shot. Use sequential shot numbers for later shots, and begin each one with a strictly increasing cut time that falls within the video duration:
|
| 87 |
+
|
| 88 |
+
```text
|
| 89 |
+
[Shot 2] At 00:03.500, the camera cuts to...
|
| 90 |
+
```
|
| 91 |
+
|
| 92 |
+
For ordinary cuts, use `the camera cuts to`, `the shot cuts to`, `the shot transitions to`, `the shot changes to`, or `the shot switches to`. When explicitly requested by the user, cross-dissolve, fade, or wipe may also be used. A cut should introduce new information about the subject, space, state, viewpoint, or time. If only the distance or a slight angle needs to change, prefer camera motion.
|
| 93 |
+
|
| 94 |
+
### 4.3 Camera Motion: Motion Type + Amplitude + Speed
|
| 95 |
+
|
| 96 |
+
A complete camera-motion expression has three dimensions: the **motion type** defines how the camera moves, **amplitude** defines the range of compositional change, and **speed** defines the pacing of that change. Add amplitude and speed only when they are meaningful; medium amplitude and normal speed are usually omitted.
|
| 97 |
+
|
| 98 |
+
| Dimension | Available Expression | Description |
|
| 99 |
+
|-|-|-|
|
| 100 |
+
| Motion type | `Zoom In / Zoom Out` | The focal length changes while the camera body remains stationary |
|
| 101 |
+
| Motion type | `Push In / Pull Out` | The camera moves forward / backward |
|
| 102 |
+
| Motion type | `Pan Left / Pan Right` | The camera remains in place while the lens pivots horizontally |
|
| 103 |
+
| Motion type | `Truck Left / Truck Right` | The camera translates horizontally |
|
| 104 |
+
| Motion type | `Tilt Up / Tilt Down` | The camera remains in place while the lens pivots vertically |
|
| 105 |
+
| Motion type | `Pedestal Up / Pedestal Down` | The entire camera moves upward / downward |
|
| 106 |
+
| Motion type | `Arc Shot` | The camera moves in an arc around the subject |
|
| 107 |
+
| Motion type | `Tracking Shot` | The camera follows a moving subject |
|
| 108 |
+
| Motion type | `Static Shot` | The camera position and lens remain still |
|
| 109 |
+
| Motion type | `Shake Slightly / Shake Strongly` | Slight / strong camera shake |
|
| 110 |
+
| Motion type | `POV` | The subject's point of view |
|
| 111 |
+
| Motion type | `Roll Clockwise / Roll Counterclockwise` | The camera rolls clockwise / counterclockwise around the lens axis |
|
| 112 |
+
| Amplitude | `with small amplitude` | Small-range change |
|
| 113 |
+
| Amplitude | `with large amplitude` | Large-range change |
|
| 114 |
+
| Speed | `at slow speed` | Slow movement |
|
| 115 |
+
| Speed | `at fast speed` | Fast movement |
|
| 116 |
+
|
| 117 |
+
Camera motion should be written as a natural English action within the shot, rather than stacked as separate labels at the end of a sentence:
|
| 118 |
+
|
| 119 |
+
```text
|
| 120 |
+
The camera pushes in with small amplitude at slow speed toward the folded letter in her hands.
|
| 121 |
+
The camera pans right with large amplitude at fast speed, revealing the open doorway.
|
| 122 |
+
The camera holds a static shot as the runner exits the frame.
|
| 123 |
+
```
|
| 124 |
+
|
| 125 |
+
### 4.4 Speakers, Dialogue, and Singing
|
| 126 |
+
|
| 127 |
+
Subjects who speak, sing, or produce an off-screen human voice use stable IDs such as `(S1)` and `(S2)`. When multiple already-numbered speakers speak or sing together, use a compound ID such as `(S1,S2)`. A speaker keeps the same ID across shots; characters who never vocalize receive no speaker ID.
|
| 128 |
+
|
| 129 |
+
When a speaker first appears, provide enough information from the visual and audio context to establish a stable identity, such as character type, age, gender, whether the person is on-screen, pitch, timbre, speaking rate, or accent. Place the speaker's identifying phrase, ID, action, and delivery outside `<d>`. Inside `<d>`, include only the language tag and the actual user-provided spoken content. Preserve every original word and punctuation mark verbatim; do not translate or rewrite them.
|
| 130 |
+
|
| 131 |
+
```text
|
| 132 |
+
The young woman with a quiet, breathy voice (S1) says: <d>[English] I get off at the next station.</d>
|
| 133 |
+
The two children (S1,S2) shout together, <d>[English] Wait for us!</d>
|
| 134 |
+
```
|
| 135 |
+
|
| 136 |
+
For voiceover, use the exact phrase `says in an off-screen voiceover`. Immediately after every voiceover `<d>` block, state that the corresponding on-screen character's lips remain closed:
|
| 137 |
+
|
| 138 |
+
```text
|
| 139 |
+
The man (S1) says in an off-screen voiceover: <d>[English] I still remember that road.</d> while his lips remain completely closed.
|
| 140 |
+
```
|
| 141 |
+
|
| 142 |
+
When the same line of dialogue or lyrics crosses a cut, use `<scenetrans>` at the connecting points in both parts and explicitly state that the audio continues across the cut. Use `<cutoff>` when speech is truncated by the end of the video. Continuity may be expressed with `continues seamlessly across the cut`, `continues uninterrupted into the next shot`, `carries over from the previous shot`, or `remains audible across the transition`.
|
| 143 |
+
|
| 144 |
+
### 4.5 On-Screen Text
|
| 145 |
+
|
| 146 |
+
Place any banner, sign, label, subtitle, or neon text that is actually visible on screen in English double quotation marks. Preserve the original text and punctuation verbatim, without translation.
|
| 147 |
+
|
| 148 |
+
```text
|
| 149 |
+
A red neon sign reading "营业中" glows above the doorway.
|
| 150 |
+
```
|
| 151 |
+
|
| 152 |
+
### 4.6 overall_soundscape
|
| 153 |
+
|
| 154 |
+
Use 1–4 English sentences in one continuous paragraph to summarize the ambient sound, physical action sounds, and non-verbal human sounds across the full video, such as wind, rain, traffic, footsteps, fabric movement, impacts, breathing, laughter, or panting. Dialogue, singing, and diegetic music already belong in the multimodal description and should not be repeated here. Use `N/A` only when the user explicitly requests complete silence throughout the video.
|
| 155 |
+
|
| 156 |
+
```text
|
| 157 |
+
overall_soundscape: Steady rain taps against the café windows while low room ambience continues underneath. The entrance bell rings once, followed by wet footsteps and the soft scrape of a chair.
|
| 158 |
+
```
|
| 159 |
+
|
| 160 |
+
### 4.7 non_diegetic_music
|
| 161 |
+
|
| 162 |
+
Use 1–3 English sentences to describe background music that the characters cannot hear and only the audience can hear. Focus on instrumentation, speed, rhythm, and dynamic changes; do not use abstract mood words or explain the emotional function of the score. Singing, instruments, radio, television, or phone music audible to the characters are diegetic events and should appear in the multimodal description. Use `N/A` when there is no non-diegetic music.
|
| 163 |
+
|
| 164 |
+
```text
|
| 165 |
+
non_diegetic_music: Sparse piano notes at a slow tempo, joined by sustained low strings that gradually increase in volume before fading out.
|
| 166 |
+
```
|
| 167 |
+
|
| 168 |
+
## 5. Cases
|
| 169 |
+
|
| 170 |
+
### Case 1: T2VA
|
| 171 |
+
|
| 172 |
+
With no reference image, construct the complete timeline directly from the text. You may add scene, character, action, and sound details that remain consistent with the user's intent.
|
| 173 |
+
|
| 174 |
+
```text
|
| 175 |
+
integrated_multimodal_description: [Shot 1] Live-action, cinematic, a medium-wide shot frames a baker opening the shutters of a small street bakery before sunrise. The camera pushes in with small amplitude at slow speed as the middle-aged baker with a calm, slightly raspy voice (S1) places a fresh loaf on the wooden counter and says: <d>[English] First batch of the morning.</d> [Shot 2] At 00:05.000, the camera cuts to a close-up of steam rising from the sliced bread while the baker's final words carry over from the previous shot.
|
| 176 |
+
|
| 177 |
+
overall_soundscape: Wooden shutters scrape open over a quiet street as trays clink softly inside the bakery. The doorbell rings once, followed by light footsteps and the crisp sound of bread being sliced.
|
| 178 |
+
|
| 179 |
+
non_diegetic_music: A soft acoustic-guitar pattern at a moderate tempo, joined by sparse upright-bass notes and a gentle fade at the end.
|
| 180 |
+
```
|
| 181 |
+
|
| 182 |
+
### Case 2: I2VA
|
| 183 |
+
|
| 184 |
+
Write the first-frame instruction first, then use the subject, composition, and scene in Picture 1 as the starting point of Shot 1 before describing how the scene continues to develop.
|
| 185 |
+
|
| 186 |
+
```text
|
| 187 |
+
For the target video, at 0.00 seconds into the target video, <Picture 1> (from [Shot 1]) is fully referenced.
|
| 188 |
+
|
| 189 |
+
integrated_multimodal_description: [Shot 1] Live-action, cinematic, the young woman shown in <Picture 1> remains beside the rain-covered train window, preserving her appearance, clothing, seat position, and the carriage layout. The camera trucks right with small amplitude at slow speed as she lifts her gaze from the folded letter toward the passing city lights. Her reflection moves across the glass while the quiet, breathy young woman (S1) says: <d>[English] I get off at the next station.</d> She folds the letter along its existing crease.
|
| 190 |
+
|
| 191 |
+
overall_soundscape: The train wheels produce a steady metallic rhythm beneath a low ventilation hum. Rain ticks against the window while paper rustles softly in her hands.
|
| 192 |
+
|
| 193 |
+
non_diegetic_music: Sustained cello notes at a slow tempo with widely spaced piano tones, gradually decreasing in volume.
|
| 194 |
+
```
|
| 195 |
+
|
| 196 |
+
### Case 3: FL2VA
|
| 197 |
+
|
| 198 |
+
The two images anchor the opening and ending respectively. The body should not repeat two static image descriptions; instead, it should supply the motion path that connects them. The following example is an eight-second single shot.
|
| 199 |
+
|
| 200 |
+
```text
|
| 201 |
+
How the reference pictures align with the target video — Picture 1 (from Shot 1) aligns with the 0.00-second mark of the target video; Picture 2 (from Shot 1) aligns with the 8.00-second mark of the target video.
|
| 202 |
+
|
| 203 |
+
integrated_multimodal_description: [Shot 1] Live-action, cinematic, a rain-soaked cyclist begins in the position and framing established by Picture 1, holding a closed black umbrella beside a silver bicycle. The camera pulls out with small amplitude at slow speed as she releases the bicycle handle, raises the umbrella above her shoulder, and presses the runner upward until the canopy opens. Water rolls from the expanding fabric while she steps beneath it, rotates the handle into the final angle, and settles into the pose, spacing, and composition established by Picture 2 at the end of the shot.
|
| 204 |
+
|
| 205 |
+
overall_soundscape: Rain falls steadily on the pavement, followed by the metallic click of the umbrella runner and the soft snap of the canopy opening. Water drips from the bicycle frame as distant traffic passes.
|
| 206 |
+
|
| 207 |
+
non_diegetic_music: N/A
|
| 208 |
+
```
|
| 209 |
+
|
| 210 |
+
### Case 4: L2VA
|
| 211 |
+
|
| 212 |
+
The image anchors only the final moment. First establish a compatible earlier state, then let the actions, object states, and composition gradually land on Picture 1 in the final shot. The following example is a six-second single shot.
|
| 213 |
+
|
| 214 |
+
```text
|
| 215 |
+
How the reference pictures align with the target video — <Picture 1> (from [Shot 1]) aligns with the 6.00-second mark of the target video.
|
| 216 |
+
|
| 217 |
+
integrated_multimodal_description: [Shot 1] Live-action, cinematic, a close shot begins with an intact drinking glass near the edge of a dark wooden table, while the same hand and sleeve visible in <Picture 1> approach from the right. The camera pushes in with small amplitude at slow speed as the fingertips strike the rim. The glass tips, falls, and hits the floor with a sharp impact; cracks spread through it as fragments slide outward. Toward the end, the moving pieces lose momentum and settle into the exact broken arrangement, hand position, camera angle, lighting, and final composition established by <Picture 1>.
|
| 218 |
+
|
| 219 |
+
overall_soundscape: Fingertips tap the glass before it scrapes across the tabletop, falls, and breaks with a sharp crash. Small fragments scatter and gradually stop sliding across the floor.
|
| 220 |
+
|
| 221 |
+
non_diegetic_music: A low electronic pulse at a slow tempo, ending immediately after the glass breaks.
|
| 222 |
+
```
|
docs/VIDEO_PROMPT_ref-en.txt
ADDED
|
@@ -0,0 +1,341 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Full-Reference Mode Rewrite Output Format Guide
|
| 2 |
+
|
| 3 |
+
This guide explains how rewrite outputs are organized and written in full-reference mode.
|
| 4 |
+
|
| 5 |
+
Write all six rewrite sections in English. Preserve the original language only for dialogue and lyrics inside `<d>` and for text visibly present in the scene.
|
| 6 |
+
|
| 7 |
+
**Description detail:** Make `detailed_description` as detailed and explicit as possible. For each shot, clearly establish the current composition, subject appearance and position, environment and lighting, actions and state changes, camera movement, current sound, and the points where referenced content actually appears or takes effect. Avoid reducing the description to a plot summary or a list of reference relationships.
|
| 8 |
+
|
| 9 |
+
> The basic formats for shots, camera movement, speakers, dialogue, and ordinary sound are shared with the Video Prompt Writing Guide (T2VA / I2VA / FL2VA / L2VA). This guide focuses on the reference labels, analysis sections, and format differences specific to full-reference mode.
|
| 10 |
+
|
| 11 |
+
## 1. Overall Structure
|
| 12 |
+
|
| 13 |
+
A complete rewrite output consists of six sections in the following order:
|
| 14 |
+
|
| 15 |
+
| Section | Purpose |
|
| 16 |
+
| --- | --- |
|
| 17 |
+
| `subject_definitions` | Defines referenced content and its reference labels |
|
| 18 |
+
| `summary` | Summarizes the task type, target video, and main reference relationships |
|
| 19 |
+
| `retention_analysis` | Describes how referenced content is preserved, transferred, or reused |
|
| 20 |
+
| `detailed_description` | Describes visuals, actions, shots, sound, and dialogue in playback order |
|
| 21 |
+
| `overall_soundscape` | Summarizes ambience and physical sounds |
|
| 22 |
+
| `non_diegetic_music` | Describes background music audible only to the audience |
|
| 23 |
+
|
| 24 |
+
## 2. Reference Labels and Definitions (`subject_definitions`)
|
| 25 |
+
|
| 26 |
+
Full-reference rewrites use four types of labels to identify the source and role of referenced content:
|
| 27 |
+
|
| 28 |
+
| Label | Meaning |
|
| 29 |
+
| --- | --- |
|
| 30 |
+
| `<Subject N>` | Visible content abstracted from reference assets that can be reused or modified in the target video |
|
| 31 |
+
| `<Picture N>` | A reference image used as a concrete target frame or shot-planning anchor |
|
| 32 |
+
| `<Video N>` | A reference video that provides an editing source, continuation starting point, or whole-video temporal structure |
|
| 33 |
+
| `<Audio N>` | An audio signal that is copied or referenced |
|
| 34 |
+
|
| 35 |
+
> Once a reference label is assigned to a piece of content, it keeps the same meaning across `subject_definitions`, `summary`, `retention_analysis`, `detailed_description`, and the audio sections.
|
| 36 |
+
|
| 37 |
+
`subject_definitions` defines each piece of referenced content that must be tracked separately later, such as a person, an environment, a source video's structure, or an audio track. Give each item its own line and explain what its label denotes, its reference role, and the main features to follow; name the corresponding source asset when its provenance needs to be made explicit. If `<Picture N>` or `<Video N>` only identifies the source of another referenced item and will not be analyzed or used separately later, cite it inside that item's definition without adding a separate line. `retention_analysis` records where each referenced item appears and whether it is fully preserved, partially preserved, transferred, or reused.
|
| 38 |
+
|
| 39 |
+
### 2.1 `<Subject N>`
|
| 40 |
+
|
| 41 |
+
`<Subject N>` is used for reusable visible content, including:
|
| 42 |
+
|
| 43 |
+
- People, animals, or objects
|
| 44 |
+
- Scenes, backgrounds, or environments
|
| 45 |
+
- Clothing, props, interfaces, or visual effects
|
| 46 |
+
- Styles, actions, expressions, or poses
|
| 47 |
+
|
| 48 |
+
It represents a content unit that will actually be used in the target video, rather than the source file itself. One subject may be defined by multiple reference assets, and one reference asset may provide multiple subjects.
|
| 49 |
+
|
| 50 |
+
```text
|
| 51 |
+
<Subject 1> is the young woman in <Picture 1>, with long dark hair, a blue cardigan, and a thin silver necklace.
|
| 52 |
+
```
|
| 53 |
+
|
| 54 |
+
When the same subject comes from multiple assets, combine the sources and state what each asset provides:
|
| 55 |
+
|
| 56 |
+
```text
|
| 57 |
+
<Subject 1> is the woman whose appearance comes from <Picture 1> and whose walking motion comes from <Video 1>.
|
| 58 |
+
```
|
| 59 |
+
|
| 60 |
+
### 2.2 `<Picture N>`
|
| 61 |
+
|
| 62 |
+
Use a standalone `<Picture N>` when the reference image itself serves as a shot's first frame, keyframe, last frame, edited keyframe, or composition anchor:
|
| 63 |
+
|
| 64 |
+
```text
|
| 65 |
+
<Picture 2> is the first frame of [Shot 1], showing a woman seated beside a café window.
|
| 66 |
+
```
|
| 67 |
+
|
| 68 |
+
If an image is used only to define a character, scene, costume, or style, do not create a standalone picture entry. Instead, cite the image source inside the corresponding `<Subject N>` definition.
|
| 69 |
+
|
| 70 |
+
When an image acts as a storyboard or shot-planning reference, state which shots it maps to and what planning information it provides:
|
| 71 |
+
|
| 72 |
+
```text
|
| 73 |
+
<Picture 3> is a storyboard reference for [Shot 1] and [Shot 2], defining their viewpoint, subject placement, and shot order.
|
| 74 |
+
```
|
| 75 |
+
|
| 76 |
+
### 2.3 `<Video N>`
|
| 77 |
+
|
| 78 |
+
`<Video N>` is reserved for whole-video relationships, such as:
|
| 79 |
+
|
| 80 |
+
- Editing an original video
|
| 81 |
+
- Continuing from the end of an original video
|
| 82 |
+
- Referencing the original video's camera movement, cuts, rhythm, or temporal structure
|
| 83 |
+
|
| 84 |
+
```text
|
| 85 |
+
<Video 1> is the source video for the target video edit.
|
| 86 |
+
```
|
| 87 |
+
|
| 88 |
+
If a person, object, scene, action, or effect from a reference video is reused as visible content, it still belongs under `<Subject N>`. `<Video N>` identifies the asset or structural source and does not replace subject labels.
|
| 89 |
+
|
| 90 |
+
### 2.4 `<Audio N>`
|
| 91 |
+
|
| 92 |
+
`<Audio N>` represents a standalone audio asset or an enabled synchronized audio track from a reference video. Common uses include:
|
| 93 |
+
|
| 94 |
+
- Copying all or part of an audio signal
|
| 95 |
+
- Referencing a background-music style
|
| 96 |
+
- Referencing a speaker's voice timbre and delivery
|
| 97 |
+
- Using dialogue, lyrics, or sound effects from the original audio
|
| 98 |
+
- Referencing beat, rhythm, or audio continuity
|
| 99 |
+
|
| 100 |
+
When an `<Audio N>` explicitly corresponds to a target speaker, reuse that speaker's global ID in the definition: write `<Subject N> (Sx)` when the speaker maps to a defined subject, or use a stable voice description followed by `(Sx)` otherwise. The ID comes from the target video's global speaker order and is not independently assigned or renumbered in the audio definition. See Section 5.4 for the speaker-numbering rules:
|
| 101 |
+
|
| 102 |
+
```text
|
| 103 |
+
<Audio 1> is the voice-timbre reference for <Subject 1> (S1).
|
| 104 |
+
```
|
| 105 |
+
|
| 106 |
+
When one audio asset serves multiple roles, describe those roles in one natural sentence rather than creating additional subsections.
|
| 107 |
+
|
| 108 |
+
### 2.5 Visual and Audio Tracks from the Same Reference Video
|
| 109 |
+
|
| 110 |
+
`<Video N>` and `<Audio N>` are numbered independently. Each index indicates only the label's order within its own category and does not encode a pairing between the two categories. The same reference video may therefore correspond to `<Video 1>` and `<Audio 2>`; different indices do not prevent them from coming from the same source asset.
|
| 111 |
+
|
| 112 |
+
An ordinary reference video does not create `<Audio N>` merely because the file contains sound.
|
| 113 |
+
|
| 114 |
+
An `<Audio N>` definition primarily states the audio's role and does not have to name the `<Video N>` it comes from. State the shared source only when needed to remove provenance ambiguity, for example:
|
| 115 |
+
|
| 116 |
+
```text
|
| 117 |
+
<Video 1> is the source video for the target video edit.
|
| 118 |
+
<Audio 2> is the synchronized audio track of <Video 1> and is reused in the target video.
|
| 119 |
+
```
|
| 120 |
+
|
| 121 |
+
## 3. `summary`
|
| 122 |
+
|
| 123 |
+
This section uses one short English paragraph to summarize the target video and its reference relationships. It begins with a square-bracketed task-type prefix:
|
| 124 |
+
|
| 125 |
+
```text
|
| 126 |
+
[reference generation] ...
|
| 127 |
+
[video editing + reference generation + audio reuse] ...
|
| 128 |
+
```
|
| 129 |
+
|
| 130 |
+
Choose task types according to the actual role each reference asset plays in the target video:
|
| 131 |
+
|
| 132 |
+
| Task type | When to use it |
|
| 133 |
+
| --- | --- |
|
| 134 |
+
| `keyframe completion` | An image serves as the target video's first frame, keyframe, last frame, edited keyframe, or another concrete frame anchor |
|
| 135 |
+
| `reference generation` | An image, video, or audio asset provides generation guidance for a character, scene, style, action, camera movement, storyboard, and so on, without serving as a concrete frame or as the source video being edited or continued |
|
| 136 |
+
| `video editing` | An existing source video is directly modified; editing an image or generating between still keyframes does not belong to this type |
|
| 137 |
+
| `video continuation` | New content continues, extends, resumes, or transitions from an existing source video |
|
| 138 |
+
| `audio reuse` | The same audio signal is reused in full or in part |
|
| 139 |
+
| `audio reference` | The audio signal is not copied directly; only its music style, timbre, dialogue or lyric content, sound-effect texture, beat, or continuity is referenced |
|
| 140 |
+
|
| 141 |
+
When a task satisfies multiple relationships, combine the task types with ` + ` and do not repeat a type. For example, continuing from a source video while using an image as the last frame is written as `[video continuation + keyframe completion]`. Editing a source video while retaining its original audio may be written as `[video editing + audio reuse]`.
|
| 142 |
+
|
| 143 |
+
The mere presence of video or audio does not automatically create a corresponding task type. If a reference video provides only camera movement, cuts, or rhythm, it normally belongs to `reference generation`. Use `video editing` or `video continuation` only when that video is directly edited or continued.
|
| 144 |
+
|
| 145 |
+
When editing a source video, use `audio reuse` as well if its original audio remains audible. When continuing a source video without directly copying the audio signal, use `audio reference` if the new audio only continues the original track's audible characteristics.
|
| 146 |
+
|
| 147 |
+
The summary uses the previously defined `<Subject N>`, `<Picture N>`, `<Video N>`, and `<Audio N>` labels to describe the main subjects, shot flow, and roles of the reference assets. Do not introduce new reference labels in this section.
|
| 148 |
+
|
| 149 |
+
For video-editing tasks, begin the summary after the task-type prefix with:
|
| 150 |
+
|
| 151 |
+
```text
|
| 152 |
+
The target video is an edited version of <Video 1>.
|
| 153 |
+
```
|
| 154 |
+
|
| 155 |
+
## 4. `retention_analysis`
|
| 156 |
+
|
| 157 |
+
This section describes how each piece of referenced content is preserved, transferred, copied, or referenced in the target video. Use one line for each reference label and preserve the meaning established in `subject_definitions`.
|
| 158 |
+
|
| 159 |
+
### 4.1 Visible Content
|
| 160 |
+
|
| 161 |
+
`<Subject N>`, `<Picture N>`, and `<Video N>` use the following relationship markers. These markers are fixed English values in the output format:
|
| 162 |
+
|
| 163 |
+
| Relationship marker | Meaning |
|
| 164 |
+
| --- | --- |
|
| 165 |
+
| `fully_preserved` | The defined role of the referenced content is fully preserved |
|
| 166 |
+
| `partially_preserved` | The referenced content is still used, but some defined characteristics are changed or only partially retained |
|
| 167 |
+
| `attribute_transfer` | Referenced characteristics are transferred to a different identifiable target subject |
|
| 168 |
+
| `weak_reference` | Only broad similarity in style, category, composition, or atmosphere is retained |
|
| 169 |
+
|
| 170 |
+
Subject entry:
|
| 171 |
+
|
| 172 |
+
```text
|
| 173 |
+
<Subject 1> (appears in [Shot 1], [Shot 3]): fully_preserved - ...
|
| 174 |
+
```
|
| 175 |
+
|
| 176 |
+
Picture entry:
|
| 177 |
+
|
| 178 |
+
```text
|
| 179 |
+
<Picture 2> ([Shot 1] first frame): fully_preserved - ...
|
| 180 |
+
```
|
| 181 |
+
|
| 182 |
+
Video-structure entry:
|
| 183 |
+
|
| 184 |
+
```text
|
| 185 |
+
<Video 1> (cut and pacing structure): weak_reference - ...
|
| 186 |
+
```
|
| 187 |
+
|
| 188 |
+
### 4.2 Audio
|
| 189 |
+
|
| 190 |
+
`<Audio N>` uses the following relationship markers:
|
| 191 |
+
|
| 192 |
+
| Relationship marker | Meaning |
|
| 193 |
+
| --- | --- |
|
| 194 |
+
| `fully_copy` | The complete source audio serves as the target video's complete final audio track |
|
| 195 |
+
| `partially_copy` | Only part of the timeline or selected audio layers are copied, or other sounds are added, removed, or replaced after copying |
|
| 196 |
+
| `reference` | The signal is not copied directly; only timbre, rhythm, music style, dialogue content, or sound texture is referenced |
|
| 197 |
+
| `weak_reference` | Only broad similarity in category or atmosphere is retained |
|
| 198 |
+
|
| 199 |
+
```text
|
| 200 |
+
<Audio 1>: fully_copy - <Audio 1> is reused 1:1 as the target video's complete final audio track.
|
| 201 |
+
```
|
| 202 |
+
|
| 203 |
+
```text
|
| 204 |
+
<Audio 2>: reference - the target speaker follows <Audio 2>'s voice timbre and measured delivery without copying the original signal.
|
| 205 |
+
```
|
| 206 |
+
|
| 207 |
+
Choose each relationship marker only within the reference role already defined for that label in `subject_definitions`. Do not treat newly added actions, backgrounds, or plot events in the target video as losses of reference fidelity.
|
| 208 |
+
|
| 209 |
+
## 5. `detailed_description`
|
| 210 |
+
|
| 211 |
+
This is the main body of a full-reference rewrite. It describes visuals, actions, sound, and dialogue shot by shot in target-video playback order and inserts reference labels where they apply.
|
| 212 |
+
|
| 213 |
+
### 5.1 Basic Format
|
| 214 |
+
|
| 215 |
+
The basic format follows the Video Prompt Writing Guide (T2VA / I2VA / FL2VA / L2VA):
|
| 216 |
+
|
| 217 |
+
- Write the body in English. Preserve the original language of dialogue, lyrics, and visible text.
|
| 218 |
+
- `[Shot 1]` marks the opening shot and has no timestamp. Later shots use `[Shot N] At MM:SS.mmm, ...` to mark cut times.
|
| 219 |
+
- Write camera movement as natural English within the current shot, including movement type, amplitude, and speed when they need to be expressed.
|
| 220 |
+
- Give vocal sources stable `(S1)`, `(S2)`, and subsequent IDs. Write dialogue and lyrics as `<d>[Language] ...</d>`.
|
| 221 |
+
- Use `<scenetrans>`, `<cutoff>`, and the corresponding continuity descriptions for dialogue crossing a cut, speech truncated by the video ending, and continuous audio across shots.
|
| 222 |
+
|
| 223 |
+
For complete rules and examples covering camera vocabulary, group speech, voice-over, dialogue across cuts, and visible text, see the Video Prompt Writing Guide (T2VA / I2VA / FL2VA / L2VA).
|
| 224 |
+
|
| 225 |
+
### 5.2 Full-Reference Mode Differences
|
| 226 |
+
|
| 227 |
+
| Dimension | T2VA | Full-reference mode |
|
| 228 |
+
| --- | --- | --- |
|
| 229 |
+
| Main field | `integrated_multimodal_description` | `detailed_description` |
|
| 230 |
+
| Style opening | Written after `[Shot 1]` | Established in one or two English sentences before `[Shot 1]` |
|
| 231 |
+
| Reference information | Does not use full-reference labels | Inserts `<Subject N>`, `<Picture N>`, `<Video N>`, and `<Audio N>` at their first appearance and where their roles apply |
|
| 232 |
+
| Audio relationships | Describes the target video's own sound | Cites `<Audio N>` in the corresponding shot or audio phase and states whether the signal is copied or referenced |
|
| 233 |
+
|
| 234 |
+
Opening example:
|
| 235 |
+
|
| 236 |
+
```text
|
| 237 |
+
The target video is in a cinematic, literary music-video style with soft lighting and a slightly desaturated color palette.
|
| 238 |
+
[Shot 1] The scene opens in a crowded urban street...
|
| 239 |
+
[Shot 2] At 00:09.000, the shot cuts to an extreme close-up...
|
| 240 |
+
```
|
| 241 |
+
|
| 242 |
+
For generation tasks, `detailed_description` is normally 350-500 English words. Dialogue-dense content prioritizes fitting the complete spoken timeline rather than mechanically reaching a word count. Video-editing descriptions scale with the complexity of the source video and do not have to follow the generation-task range. A single shot does not automatically justify a shorter description; distribute detail across multiple shots according to their information load.
|
| 243 |
+
|
| 244 |
+
### 5.3 Using Reference Labels in Shots
|
| 245 |
+
|
| 246 |
+
At the first clear appearance of an important `<Subject N>`, describe its referenced characteristics, position in the frame, and current action within what is actually visible in the shot. Continue using the same label in later shots without redefining what the label represents.
|
| 247 |
+
|
| 248 |
+
Use natural phrasing for concrete frame anchors:
|
| 249 |
+
|
| 250 |
+
```text
|
| 251 |
+
the shot begins from <Picture 1>
|
| 252 |
+
the shot's keyframe corresponds to <Picture 2>
|
| 253 |
+
the shot ends on <Picture 3>
|
| 254 |
+
```
|
| 255 |
+
|
| 256 |
+
When editing or continuing an original video, cite `<Video N>` naturally where its source state, structure, or continuation relationship applies. Cite `<Audio N>` in the shot or semantic phase where the audio relationship is active.
|
| 257 |
+
|
| 258 |
+
### 5.4 Speakers, Audio Sources, and Dialogue
|
| 259 |
+
|
| 260 |
+
The basic speaker-ID and `<d>` formats follow T2VA. When a referenced subject physically speaks, retain both the visual reference label and the speaker ID:
|
| 261 |
+
|
| 262 |
+
```text
|
| 263 |
+
<Subject 2> (S1) turns toward the woman and says, <d>[English] Last summer, I went to my grandfather's house. He talked about you.</d>
|
| 264 |
+
```
|
| 265 |
+
|
| 266 |
+
`<Subject N>` identifies the referenced subject, while `(Sx)` identifies the actual speaker. When the subject speaks, write `<Subject N> (Sx)`. If the same subject speaks off-screen, keep the same form and mark it as `off-screen`. When the speaker does not correspond to a defined subject, use a stable voice description followed by `(Sx)`.
|
| 267 |
+
|
| 268 |
+
When verbal content is only a cue within a directly reused BGM or complete soundtrack, and no person, character, narrator, or other independent vocal source physically produces it, use `<Audio N>` as the audible source and do not invent an additional `(Sx)`. If a concrete person, character, narrator, or other independent vocal source produces the voice, assign and reuse `(Sx)` for that source:
|
| 269 |
+
|
| 270 |
+
```text
|
| 271 |
+
When <Audio 1> reaches the phrase <d>[English] I'm lonely lonely lonely lonely lonely I'm lonely</d>, <Subject 1> performs the corresponding hand gesture without becoming a separate speaker source.
|
| 272 |
+
```
|
| 273 |
+
|
| 274 |
+
When dialogue, narration, or lyrics from reference audio are directly reused, or when the input prompt explicitly requests their reperformance, preserve the exact source words and original language inside `<d>`. Write `[unclear]` for unintelligible spans instead of guessing or paraphrasing them. Standardize punctuation to the basic written marks needed to express the sentence, such as `,`, `.`, `?`, and `!`; remove repeated tildes, emoji, bullets, and repeated or decorative punctuation. End complete statements, questions, and exclamations with `.`, `?`, or `!` respectively before `</d>`.
|
| 275 |
+
|
| 276 |
+
When only timbre, rhythm, emotion, or delivery is referenced, do not carry the original dialogue from the reference audio into the target video.
|
| 277 |
+
|
| 278 |
+
Assign `(Sx)` once according to the order of actual vocal events in the target video. Reuse the corresponding ID at every actual vocal event in `detailed_description`; an `<Audio N>` definition bound to a target speaker in `subject_definitions` also reuses the same `(Sx)` but never assigns a new one independently. Do not write `(Sx)` in `retention_analysis`. Verbal cues that exist only within a directly reused BGM or complete soundtrack use `<Audio N>`; voices physically produced by a concrete person, character, narrator, or other independent vocal source use `(Sx)`.
|
| 279 |
+
|
| 280 |
+
## 6. `overall_soundscape` and `non_diegetic_music`
|
| 281 |
+
|
| 282 |
+
The definitions of these two sound categories follow the Video Prompt Writing Guide (T2VA / I2VA / FL2VA / L2VA).
|
| 283 |
+
|
| 284 |
+
`overall_soundscape` summarizes ambience and physical sounds across the full video. Dialogue, singing, and sound events synchronized to a particular shot remain in `detailed_description`:
|
| 285 |
+
|
| 286 |
+
```text
|
| 287 |
+
overall_soundscape: Quiet indoor room tone and a low ventilation hum continue throughout the video.
|
| 288 |
+
```
|
| 289 |
+
|
| 290 |
+
`non_diegetic_music` describes background music that the characters cannot hear and that is audible only to the audience. When music is present, state its instrumentation, tempo, and dynamic development:
|
| 291 |
+
|
| 292 |
+
```text
|
| 293 |
+
non_diegetic_music: A restrained solo-piano score at a slow tempo, with sustained low cello underneath and no swell.
|
| 294 |
+
```
|
| 295 |
+
|
| 296 |
+
When reference audio is used, state its copy or reference relationship only in the section that matches the audible layer: ambience and sound effects belong in `overall_soundscape`, while audience-only score belongs in `non_diegetic_music`. If the same audio provides both kinds of content, describe the corresponding relationship in each section:
|
| 297 |
+
|
| 298 |
+
```text
|
| 299 |
+
overall_soundscape: The copied ambience layer from <Audio 1> continues throughout the target video.
|
| 300 |
+
non_diegetic_music: <Audio 2> is directly reused as the complete audience-only score.
|
| 301 |
+
```
|
| 302 |
+
|
| 303 |
+
Write complete dialogue and lyrics only inside `<d>` in `detailed_description`; do not repeat them in these two sections.
|
| 304 |
+
|
| 305 |
+
## 7. Complete Example
|
| 306 |
+
|
| 307 |
+
<details>
|
| 308 |
+
<summary>Show the complete example</summary>
|
| 309 |
+
|
| 310 |
+
```text
|
| 311 |
+
subject_definitions:
|
| 312 |
+
<Subject 1> is the coffee-shop environment in <Picture 1>, featuring an exposed brick wall, an orange tufted sofa with patterned pillows, a neon sign, and a wooden coffee table.
|
| 313 |
+
<Subject 2> is the fluffy white Samoyed in <Picture 2>, <Picture 3>, and <Picture 4>, with thick white fur, pointed ears, a dark nose, and a curved tail.
|
| 314 |
+
<Subject 3> is the young blonde woman in <Video 1>, with long blonde hair and a light-pink button-down shirt with rolled-up sleeves.
|
| 315 |
+
<Subject 4> is the young man in <Video 2>, with short wavy brown hair and a dark-grey hoodie with drawstrings.
|
| 316 |
+
<Audio 1> is the voice-timbre reference for <Subject 3> (S1), containing a spoken English vocal layer.
|
| 317 |
+
|
| 318 |
+
summary:
|
| 319 |
+
[reference generation + audio reference] The target video shows <Subject 3> eating a cookie in <Subject 1>. <Subject 4> enters with <Subject 2>, which lunges toward the cookie. The three-shot exchange uses <Audio 1> as the voice-timbre reference for <Subject 3> and ends with a canned audience laugh.
|
| 320 |
+
|
| 321 |
+
retention_analysis:
|
| 322 |
+
<Subject 1> (appears in [Shot 1], [Shot 2], [Shot 3]): fully_preserved - the exposed brick wall, orange tufted sofa, patterned pillows, neon sign, and wooden coffee table are retained.
|
| 323 |
+
<Subject 2> (appears in [Shot 1], [Shot 2]): fully_preserved - the Samoyed's thick white fur, pointed ears, dark nose, and curved tail are retained.
|
| 324 |
+
<Subject 3> (appears in [Shot 1], [Shot 2], [Shot 3]): fully_preserved - the blonde woman's identity, long hair, and light-pink shirt are retained.
|
| 325 |
+
<Subject 4> (appears in [Shot 1], [Shot 2]): fully_preserved - the young man's short wavy brown hair and dark-grey hoodie are retained.
|
| 326 |
+
<Audio 1>: reference - its vocal timbre guides the dialogue delivery of <Subject 3> without copying the original signal.
|
| 327 |
+
|
| 328 |
+
detailed_description:
|
| 329 |
+
The target video uses a realistic multi-camera sitcom style with warm indoor lighting.
|
| 330 |
+
[Shot 1] A medium shot establishes <Subject 1>, the coffee shop with its exposed brick wall, orange tufted sofa, patterned pillows, neon sign, and wooden coffee table. <Subject 3> (S1), the young woman with long blonde hair and a light-pink button-down shirt with rolled-up sleeves, sits on the sofa holding a chocolate-chip cookie. From the left, <Subject 4>, the young man with short wavy brown hair and a dark-grey hoodie with drawstrings, enters holding the leash of <Subject 2>, the thick-furred white Samoyed with pointed ears, a dark nose, and a curved tail. The dog lunges toward the cookie and pulls the leash taut. <Subject 3> (S1) jerks her hand back and, using the clear youthful voice timbre referenced from <Audio 1>, exclaims with light annoyance, <d>[English] Hey! Watch your dog!</d> She closes her lips and guards the cookie while <Subject 4> pulls the dog back.
|
| 331 |
+
[Shot 2] At 00:03.000, the shot cuts to a close-up of <Subject 4> (S2), the young man in the dark-grey hoodie from Shot 1, sitting beside <Subject 3> on the sofa and holding <Subject 2> securely in his arms. <Subject 4> (S2) says in a casual young male voice with a playful tone and an easy conversational pace, <d>[English] He just likes cookies more than me.</d> He closes his mouth into an apologetic smile and strokes the dog's thick white fur.
|
| 332 |
+
[Shot 3] At 00:05.000, the shot cuts to a close-up of <Subject 3> (S1), the blonde woman in the light-pink shirt from Shot 1. Her annoyance softens as she looks toward the Samoyed. <Subject 3> (S1) replies in the same clear youthful voice referenced from <Audio 1> with an amused cadence, <d>[English] Well, he has good taste at least.</d> She smiles and raises the cookie in a small toast-like gesture. A classic canned audience laugh begins immediately after the line and continues through the final frame.
|
| 333 |
+
|
| 334 |
+
overall_soundscape:
|
| 335 |
+
Soft indoor coffee-shop room tone continues throughout the scene.
|
| 336 |
+
|
| 337 |
+
non_diegetic_music:
|
| 338 |
+
N/A
|
| 339 |
+
```
|
| 340 |
+
|
| 341 |
+
</details>
|
docs/h3_prompt_format.py
ADDED
|
@@ -0,0 +1,246 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""MiniMax H3 video prompt structure for script → FL2V.
|
| 2 |
+
|
| 3 |
+
Guides (cached under optimization/h3-shrink/docs/):
|
| 4 |
+
- VIDEO_PROMPT_base-en.txt — T2VA / I2VA / FL2VA / L2VA
|
| 5 |
+
- VIDEO_PROMPT_ref-en.txt — full-reference Ref2VA
|
| 6 |
+
|
| 7 |
+
Script / scene generators should emit fields that map cleanly into these
|
| 8 |
+
structures so storyboard panels + H3 student FL2V get usable prompts.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
from __future__ import annotations
|
| 12 |
+
|
| 13 |
+
import re
|
| 14 |
+
from typing import Optional
|
| 15 |
+
|
| 16 |
+
# Local H3 clip length at 24 fps / 124 frames ≈ 5.17 s (length ≡ 5 mod 17).
|
| 17 |
+
H3_DEFAULT_CLIP_SECONDS = 5.0
|
| 18 |
+
|
| 19 |
+
FL2VA_ALIGN_LINE = (
|
| 20 |
+
"How the reference pictures align with the target video — "
|
| 21 |
+
"Picture 1 (from Shot 1) aligns with the 0.00-second mark of the target video; "
|
| 22 |
+
"Picture 2 (from Shot {shot_n}) aligns with the {end_s:.2f}-second mark of the target video."
|
| 23 |
+
)
|
| 24 |
+
|
| 25 |
+
I2VA_ALIGN_LINE = (
|
| 26 |
+
"For the target video, at 0.00 seconds into the target video, "
|
| 27 |
+
"<Picture 1> (from [Shot 1]) is fully referenced."
|
| 28 |
+
)
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def format_fl2va_prompt(
|
| 32 |
+
*,
|
| 33 |
+
multimodal_body: str,
|
| 34 |
+
overall_soundscape: str = "N/A",
|
| 35 |
+
non_diegetic_music: str = "N/A",
|
| 36 |
+
duration_s: float = H3_DEFAULT_CLIP_SECONDS,
|
| 37 |
+
final_shot: int = 1,
|
| 38 |
+
) -> str:
|
| 39 |
+
"""Assemble a complete FL2VA prompt (first+last storyboard panels)."""
|
| 40 |
+
body = multimodal_body.strip()
|
| 41 |
+
if not body.startswith("[Shot"):
|
| 42 |
+
body = f"[Shot 1] {body}"
|
| 43 |
+
align = FL2VA_ALIGN_LINE.format(shot_n=final_shot, end_s=duration_s)
|
| 44 |
+
return (
|
| 45 |
+
f"{align}\n\n"
|
| 46 |
+
f"integrated_multimodal_description: {body}\n\n"
|
| 47 |
+
f"overall_soundscape: {overall_soundscape.strip() or 'N/A'}\n\n"
|
| 48 |
+
f"non_diegetic_music: {non_diegetic_music.strip() or 'N/A'}"
|
| 49 |
+
)
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
def format_t2va_prompt(
|
| 53 |
+
*,
|
| 54 |
+
multimodal_body: str,
|
| 55 |
+
overall_soundscape: str = "N/A",
|
| 56 |
+
non_diegetic_music: str = "N/A",
|
| 57 |
+
) -> str:
|
| 58 |
+
body = multimodal_body.strip()
|
| 59 |
+
if not body.startswith("[Shot"):
|
| 60 |
+
body = f"[Shot 1] {body}"
|
| 61 |
+
return (
|
| 62 |
+
f"integrated_multimodal_description: {body}\n\n"
|
| 63 |
+
f"overall_soundscape: {overall_soundscape.strip() or 'N/A'}\n\n"
|
| 64 |
+
f"non_diegetic_music: {non_diegetic_music.strip() or 'N/A'}"
|
| 65 |
+
)
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
def parse_scene_h3_fields(scene_text: str) -> dict:
|
| 69 |
+
"""Extract H3-related fields from a genAI scene block."""
|
| 70 |
+
out: dict = {
|
| 71 |
+
"h3_mode": None,
|
| 72 |
+
"h3_video_prompt": None,
|
| 73 |
+
"storyboard_prompt": None,
|
| 74 |
+
"action": None,
|
| 75 |
+
"dialogue": [],
|
| 76 |
+
"shot": None,
|
| 77 |
+
"duration": None,
|
| 78 |
+
"soundscape": None,
|
| 79 |
+
"music": None,
|
| 80 |
+
}
|
| 81 |
+
text = scene_text.strip()
|
| 82 |
+
|
| 83 |
+
m = re.search(r"^H3_MODE:\s*(.+)$", text, re.M | re.I)
|
| 84 |
+
if m:
|
| 85 |
+
out["h3_mode"] = m.group(1).strip().upper()
|
| 86 |
+
|
| 87 |
+
m = re.search(r"^STORYBOARD_PROMPT:\s*(.+)$", text, re.M | re.I)
|
| 88 |
+
if m:
|
| 89 |
+
out["storyboard_prompt"] = m.group(1).strip()
|
| 90 |
+
else:
|
| 91 |
+
m = re.search(r"^PROMPT:\s*(.+)$", text, re.M | re.I)
|
| 92 |
+
if m:
|
| 93 |
+
out["storyboard_prompt"] = m.group(1).strip()
|
| 94 |
+
|
| 95 |
+
m = re.search(r"^ACTION:\s*(.+)$", text, re.M | re.I)
|
| 96 |
+
if m:
|
| 97 |
+
out["action"] = m.group(1).strip()
|
| 98 |
+
|
| 99 |
+
m = re.search(r"^SHOT(?:\s*1)?:\s*(.+)$", text, re.M | re.I)
|
| 100 |
+
if m:
|
| 101 |
+
out["shot"] = m.group(1).strip()
|
| 102 |
+
|
| 103 |
+
m = re.search(r"^DURATION:\s*([\d.]+)", text, re.M | re.I)
|
| 104 |
+
if m:
|
| 105 |
+
out["duration"] = float(m.group(1))
|
| 106 |
+
|
| 107 |
+
m = re.search(r"^OVERALL_SOUNDSCAPE:\s*(.+)$", text, re.M | re.I)
|
| 108 |
+
if m:
|
| 109 |
+
out["soundscape"] = m.group(1).strip()
|
| 110 |
+
|
| 111 |
+
m = re.search(r"^NON_DIEGETIC_MUSIC:\s*(.+)$", text, re.M | re.I)
|
| 112 |
+
if m:
|
| 113 |
+
out["music"] = m.group(1).strip()
|
| 114 |
+
|
| 115 |
+
# Multi-line H3_VIDEO_PROMPT until next machine field or next scene.
|
| 116 |
+
m = re.search(
|
| 117 |
+
r"^H3_VIDEO_PROMPT:\s*\n?(.*?)(?=^\s*(?:LORA|AUDIO|DURATION|STORYBOARD_PROMPT|H3_MODE|ACTION|SHOT|PROMPT|DIALOGUE)\s*:|^\s*##\s*SCENE|\Z)",
|
| 118 |
+
text,
|
| 119 |
+
re.M | re.S | re.I,
|
| 120 |
+
)
|
| 121 |
+
if m:
|
| 122 |
+
out["h3_video_prompt"] = m.group(1).strip()
|
| 123 |
+
|
| 124 |
+
for dm in re.finditer(
|
| 125 |
+
r"^DIALOGUE\s*[—\-]\s*(.+?):\s*(.+)$", text, re.M | re.I
|
| 126 |
+
):
|
| 127 |
+
out["dialogue"].append((dm.group(1).strip(), dm.group(2).strip()))
|
| 128 |
+
|
| 129 |
+
return out
|
| 130 |
+
|
| 131 |
+
|
| 132 |
+
def scene_to_h3_video_prompt(scene_text: str, *, mode: str = "FL2VA") -> str:
|
| 133 |
+
"""Build an H3 video prompt from a scene block (uses H3_VIDEO_PROMPT if present)."""
|
| 134 |
+
fields = parse_scene_h3_fields(scene_text)
|
| 135 |
+
if fields.get("h3_video_prompt"):
|
| 136 |
+
return fields["h3_video_prompt"]
|
| 137 |
+
|
| 138 |
+
mode = (fields.get("h3_mode") or mode or "FL2VA").upper()
|
| 139 |
+
duration = float(fields.get("duration") or H3_DEFAULT_CLIP_SECONDS)
|
| 140 |
+
# Prefer 5 s for local H3; clamp to API-friendly range.
|
| 141 |
+
duration = max(4.0, min(15.0, duration))
|
| 142 |
+
|
| 143 |
+
action = fields.get("action") or "The scene plays out continuously."
|
| 144 |
+
shot = fields.get("shot") or "medium shot, slow push in"
|
| 145 |
+
style = "Live-action, cinematic"
|
| 146 |
+
body_parts = [
|
| 147 |
+
f"{style}, {shot}. {action}",
|
| 148 |
+
]
|
| 149 |
+
for name, line in fields.get("dialogue") or []:
|
| 150 |
+
# Preserve dialogue language; default English tag.
|
| 151 |
+
body_parts.append(
|
| 152 |
+
f'The character {name} (S1) says: <d>[English] {line}</d>'
|
| 153 |
+
)
|
| 154 |
+
# FL2VA path language
|
| 155 |
+
if mode in ("FL2VA", "FL2V"):
|
| 156 |
+
body_parts.append(
|
| 157 |
+
"The framing begins on the composition of Picture 1 and continuously "
|
| 158 |
+
"evolves until it settles into the composition of Picture 2 at the end of the shot."
|
| 159 |
+
)
|
| 160 |
+
body = " ".join(body_parts)
|
| 161 |
+
return format_fl2va_prompt(
|
| 162 |
+
multimodal_body=body,
|
| 163 |
+
overall_soundscape=fields.get("soundscape") or "N/A",
|
| 164 |
+
non_diegetic_music=fields.get("music") or "N/A",
|
| 165 |
+
duration_s=duration,
|
| 166 |
+
final_shot=1,
|
| 167 |
+
)
|
| 168 |
+
|
| 169 |
+
body = " ".join(body_parts)
|
| 170 |
+
if mode in ("I2VA", "I2V"):
|
| 171 |
+
return (
|
| 172 |
+
f"{I2VA_ALIGN_LINE}\n\n"
|
| 173 |
+
+ format_t2va_prompt(
|
| 174 |
+
multimodal_body=body,
|
| 175 |
+
overall_soundscape=fields.get("soundscape") or "N/A",
|
| 176 |
+
non_diegetic_music=fields.get("music") or "N/A",
|
| 177 |
+
)
|
| 178 |
+
)
|
| 179 |
+
return format_t2va_prompt(
|
| 180 |
+
multimodal_body=body,
|
| 181 |
+
overall_soundscape=fields.get("soundscape") or "N/A",
|
| 182 |
+
non_diegetic_music=fields.get("music") or "N/A",
|
| 183 |
+
)
|
| 184 |
+
|
| 185 |
+
|
| 186 |
+
# ---------------------------------------------------------------------------
|
| 187 |
+
# System prompts for LLM / script-LoRA SFT targets
|
| 188 |
+
# ---------------------------------------------------------------------------
|
| 189 |
+
|
| 190 |
+
H3_SCENE_SYSTEM_PROMPT = """You are a scriptwriter for a MiniMax-H3 generative-AI video pipeline (Backlot).
|
| 191 |
+
You write ONE scene beat per request. Each scene maps 1:1 to:
|
| 192 |
+
(1) a storyboard still (T2I / image-edit), and
|
| 193 |
+
(2) one MiniMax H3 video clip via FL2VA (first storyboard panel → last / next panel).
|
| 194 |
+
|
| 195 |
+
Local H3 clips are ~5 seconds (124 frames @ 24 fps). Prefer DURATION 5 (allowed 4–8 for this local stack).
|
| 196 |
+
|
| 197 |
+
Output EXACTLY this structure (field labels verbatim, no markdown fences, no commentary):
|
| 198 |
+
|
| 199 |
+
## SCENE {N} — {SLUGLINE}
|
| 200 |
+
ACTION: <one or two sentences of visual action that can play in ~5 seconds>
|
| 201 |
+
DIALOGUE — {NAME}: <line> (at most 1 short line; omit entirely if silent)
|
| 202 |
+
SHOT: <camera: type + optional amplitude + speed, natural English e.g. "medium shot, push in with small amplitude at slow speed">
|
| 203 |
+
STORYBOARD_PROMPT: <self-contained image prompt for the key frame: subject, environment, lighting, style; NO camera timeline>
|
| 204 |
+
H3_MODE: FL2VA
|
| 205 |
+
H3_VIDEO_PROMPT:
|
| 206 |
+
How the reference pictures align with the target video — Picture 1 (from Shot 1) aligns with the 0.00-second mark of the target video; Picture 2 (from Shot 1) aligns with the 5.00-second mark of the target video.
|
| 207 |
+
|
| 208 |
+
integrated_multimodal_description: [Shot 1] Live-action, cinematic, <opening composition matching the storyboard>. <continuous motion path from Picture 1 state to Picture 2 state; include camera motion as natural English>. <optional dialogue as: the young woman (S1) says: <d>[English] line here</d>>
|
| 209 |
+
|
| 210 |
+
overall_soundscape: <1–3 sentences of ambience / physical sounds, or N/A>
|
| 211 |
+
|
| 212 |
+
non_diegetic_music: <1–2 sentences of audience-only score instrumentation/tempo, or N/A>
|
| 213 |
+
LORA: <image-lora-name:strength, or "none">
|
| 214 |
+
AUDIO: <post-process sfx/music note for OpenCode, or "none">
|
| 215 |
+
DURATION: 5
|
| 216 |
+
|
| 217 |
+
MiniMax H3 prompt rules (critical):
|
| 218 |
+
- Prefer a SINGLE shot for FL2VA so the model interpolates continuously first→last.
|
| 219 |
+
- Camera motion uses type + optional amplitude ("with small amplitude" / "with large amplitude") + speed ("at slow speed" / "at fast speed").
|
| 220 |
+
- Motion types: Zoom In/Out, Push In/Pull Out, Pan Left/Right, Truck Left/Right, Tilt Up/Down, Pedestal Up/Down, Arc Shot, Tracking Shot, Static Shot, Shake Slightly/Strongly, POV, Roll Clockwise/Counterclockwise.
|
| 221 |
+
- Cuts (only if essential): later shots use "[Shot N] At MM:SS.mmm, the camera cuts to...". First shot has NO timestamp.
|
| 222 |
+
- Speakers: stable (S1), (S2). Dialogue ONLY inside <d>[Language] ...</d>; preserve original words.
|
| 223 |
+
- On-screen text in English double quotes, verbatim.
|
| 224 |
+
- overall_soundscape: no dialogue/singing; those stay in integrated_multimodal_description.
|
| 225 |
+
- non_diegetic_music: audience-only score; N/A if none.
|
| 226 |
+
- Write H3_VIDEO_PROMPT body in English; keep dialogue language original.
|
| 227 |
+
- Never contradict CANON. Do not repeat AVOID content.
|
| 228 |
+
- STORYBOARD_PROMPT is for still image models (Z-Image / Qwen Edit), not the video timeline.
|
| 229 |
+
"""
|
| 230 |
+
|
| 231 |
+
|
| 232 |
+
H3_SCRIPT_SYSTEM_PROMPT = """You are a screenwriter for a MiniMax-H3 generative video pipeline.
|
| 233 |
+
Write a short multi-beat episode outline as sequential scene blocks (not classic screenplay INT./EXT. pages).
|
| 234 |
+
|
| 235 |
+
Each scene block uses the same field structure as the single-scene generator (ACTION, SHOT, STORYBOARD_PROMPT, H3_MODE, H3_VIDEO_PROMPT, overall_soundscape, non_diegetic_music, DURATION).
|
| 236 |
+
Default H3_MODE is FL2VA: each scene's storyboard is the first frame; the next scene's storyboard is the last frame of the previous clip.
|
| 237 |
+
DURATION defaults to 5 (local H3 ~5s clips).
|
| 238 |
+
|
| 239 |
+
Rules:
|
| 240 |
+
- Output ONLY scene blocks, no markdown fences, no commentary.
|
| 241 |
+
- H3_VIDEO_PROMPT must follow MiniMax structure: FL2VA alignment line, then integrated_multimodal_description / overall_soundscape / non_diegetic_music.
|
| 242 |
+
- Prefer single-shot FL2VA paths; continuous motion from Picture 1 to Picture 2.
|
| 243 |
+
- Camera motion in natural English (type + amplitude + speed when meaningful).
|
| 244 |
+
- Dialogue inside <d>[Language] ...</d> with speaker (S1) IDs.
|
| 245 |
+
- Do not repeat AVOID content. Keep each beat specific and filmable.
|
| 246 |
+
"""
|
scripts/build_sft_from_scriptlib.py
ADDED
|
@@ -0,0 +1,361 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Build chat SFT JSONL from scriptlib (+ optional TVTropes) for H3 script-LoRA.
|
| 3 |
+
|
| 4 |
+
Reads numbered screenplays under ../scriptlib/*.txt, splits them into short
|
| 5 |
+
scene-ish chunks, and emits two kinds of training rows:
|
| 6 |
+
|
| 7 |
+
1. **format** — classic slugline/action/dialogue → MiniMax FL2VA scene block
|
| 8 |
+
2. **premise** — short premise derived from the chunk → full H3 scene beat
|
| 9 |
+
|
| 10 |
+
Optionally samples TVTropes titles/tropes as extra premise seeds (no script body).
|
| 11 |
+
|
| 12 |
+
Output: train_dataset.full.jsonl (append or overwrite).
|
| 13 |
+
|
| 14 |
+
Example:
|
| 15 |
+
python build_sft_from_scriptlib.py --max-scripts 102 --chunks-per-script 4
|
| 16 |
+
"""
|
| 17 |
+
|
| 18 |
+
from __future__ import annotations
|
| 19 |
+
|
| 20 |
+
import argparse
|
| 21 |
+
import json
|
| 22 |
+
import random
|
| 23 |
+
import re
|
| 24 |
+
from pathlib import Path
|
| 25 |
+
|
| 26 |
+
ROOT = Path(__file__).resolve().parent
|
| 27 |
+
SCRIPTLIB = ROOT.parent / "scriptlib"
|
| 28 |
+
TROPES_TV = ROOT.parent / "TVTropesData" / "tv_tropes.csv"
|
| 29 |
+
TROPES_MASTER = ROOT.parent / "TVTropesData" / "tropes.csv"
|
| 30 |
+
OUT_DEFAULT = ROOT / "train_dataset.full.jsonl"
|
| 31 |
+
|
| 32 |
+
H3_SYSTEM = (
|
| 33 |
+
"You write ONE MiniMax-H3 FL2VA scene beat for Backlot. "
|
| 34 |
+
"Output fields: ACTION, SHOT, STORYBOARD_PROMPT, H3_MODE, H3_VIDEO_PROMPT "
|
| 35 |
+
"(alignment line + integrated_multimodal_description + overall_soundscape + "
|
| 36 |
+
"non_diegetic_music), LORA, AUDIO, DURATION 5. Prefer a single continuous shot "
|
| 37 |
+
"from Picture 1 to Picture 2. Dialogue only inside <d>[Language] ...</d>."
|
| 38 |
+
)
|
| 39 |
+
|
| 40 |
+
SLUGLINE_RE = re.compile(
|
| 41 |
+
r"^\s*(INT\.|EXT\.|INT/EXT\.|I/E\.|EST\.)\s+.+$",
|
| 42 |
+
re.I | re.M,
|
| 43 |
+
)
|
| 44 |
+
CHAR_RE = re.compile(r"^\s{10,}([A-Z][A-Z0-9 .'\-]{1,40})\s*(\(.*\))?\s*$")
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
def split_scenes(text: str, max_chars: int = 1800) -> list[str]:
|
| 48 |
+
"""Split screenplay into chunks on sluglines, then size-cap."""
|
| 49 |
+
text = text.replace("\r\n", "\n").replace("\r", "\n")
|
| 50 |
+
# Prefer slugline splits
|
| 51 |
+
parts: list[str] = []
|
| 52 |
+
matches = list(SLUGLINE_RE.finditer(text))
|
| 53 |
+
if matches:
|
| 54 |
+
for i, m in enumerate(matches):
|
| 55 |
+
start = m.start()
|
| 56 |
+
end = matches[i + 1].start() if i + 1 < len(matches) else len(text)
|
| 57 |
+
chunk = text[start:end].strip()
|
| 58 |
+
if len(chunk) > 80:
|
| 59 |
+
parts.append(chunk)
|
| 60 |
+
else:
|
| 61 |
+
# Seinfeld-style parenthetical locations: (Comedy club)
|
| 62 |
+
blocks = re.split(r"\n\s*\([^)\n]{3,80}\)\s*\n", text)
|
| 63 |
+
parts = [b.strip() for b in blocks if len(b.strip()) > 120]
|
| 64 |
+
|
| 65 |
+
# Size-cap / merge
|
| 66 |
+
out: list[str] = []
|
| 67 |
+
for p in parts:
|
| 68 |
+
if len(p) <= max_chars:
|
| 69 |
+
out.append(p)
|
| 70 |
+
else:
|
| 71 |
+
# take head of long scene (opening beat)
|
| 72 |
+
out.append(p[:max_chars].rsplit("\n", 1)[0])
|
| 73 |
+
return out
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
def extract_title(text: str) -> str:
|
| 77 |
+
for line in text.splitlines()[:25]:
|
| 78 |
+
s = line.strip()
|
| 79 |
+
if len(s) > 2 and s.isupper() and not s.startswith("WRITTEN"):
|
| 80 |
+
return s.title()
|
| 81 |
+
return "Untitled"
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
def extract_dialogue_pairs(chunk: str, limit: int = 2) -> list[tuple[str, str]]:
|
| 85 |
+
lines = chunk.splitlines()
|
| 86 |
+
pairs: list[tuple[str, str]] = []
|
| 87 |
+
i = 0
|
| 88 |
+
while i < len(lines) and len(pairs) < limit:
|
| 89 |
+
m = CHAR_RE.match(lines[i])
|
| 90 |
+
if not m:
|
| 91 |
+
i += 1
|
| 92 |
+
continue
|
| 93 |
+
name = m.group(1).strip().title()
|
| 94 |
+
i += 1
|
| 95 |
+
dial: list[str] = []
|
| 96 |
+
while i < len(lines):
|
| 97 |
+
L = lines[i]
|
| 98 |
+
if CHAR_RE.match(L) or SLUGLINE_RE.match(L):
|
| 99 |
+
break
|
| 100 |
+
if L.strip().startswith("(") and L.strip().endswith(")"):
|
| 101 |
+
i += 1
|
| 102 |
+
continue
|
| 103 |
+
if L.strip():
|
| 104 |
+
dial.append(L.strip())
|
| 105 |
+
elif dial:
|
| 106 |
+
break
|
| 107 |
+
i += 1
|
| 108 |
+
if dial:
|
| 109 |
+
pairs.append((name, " ".join(dial)))
|
| 110 |
+
return pairs
|
| 111 |
+
|
| 112 |
+
|
| 113 |
+
def extract_action_lines(chunk: str, max_sents: int = 2) -> str:
|
| 114 |
+
acts: list[str] = []
|
| 115 |
+
for line in chunk.splitlines():
|
| 116 |
+
s = line.strip()
|
| 117 |
+
if not s or CHAR_RE.match(line) or SLUGLINE_RE.match(line):
|
| 118 |
+
continue
|
| 119 |
+
if s.startswith("(") and s.endswith(")"):
|
| 120 |
+
continue
|
| 121 |
+
# skip all-caps character names
|
| 122 |
+
if s.isupper() and len(s) < 40:
|
| 123 |
+
continue
|
| 124 |
+
if len(s) > 20:
|
| 125 |
+
acts.append(s)
|
| 126 |
+
if len(acts) >= max_sents:
|
| 127 |
+
break
|
| 128 |
+
return " ".join(acts) if acts else "The scene plays out continuously."
|
| 129 |
+
|
| 130 |
+
|
| 131 |
+
def slugline_from_chunk(chunk: str) -> str:
|
| 132 |
+
m = SLUGLINE_RE.search(chunk)
|
| 133 |
+
if m:
|
| 134 |
+
return m.group(0).strip().upper()
|
| 135 |
+
# parenthetical location
|
| 136 |
+
m2 = re.search(r"\(([^)\n]{3,60})\)", chunk)
|
| 137 |
+
if m2:
|
| 138 |
+
return f"INT. {m2.group(1).upper()}"
|
| 139 |
+
return "INT. LOCATION - DAY"
|
| 140 |
+
|
| 141 |
+
|
| 142 |
+
def chunk_to_h3_assistant(chunk: str, title: str) -> str:
|
| 143 |
+
slug = slugline_from_chunk(chunk)
|
| 144 |
+
action = extract_action_lines(chunk)
|
| 145 |
+
dialogue = extract_dialogue_pairs(chunk, limit=1)
|
| 146 |
+
# Compress action for ~5s beat
|
| 147 |
+
action_short = action
|
| 148 |
+
if len(action_short) > 280:
|
| 149 |
+
action_short = action_short[:280].rsplit(" ", 1)[0] + "."
|
| 150 |
+
|
| 151 |
+
dial_line = ""
|
| 152 |
+
multimodal_extra = ""
|
| 153 |
+
if dialogue:
|
| 154 |
+
name, line = dialogue[0]
|
| 155 |
+
# keep dialogue short
|
| 156 |
+
if len(line) > 160:
|
| 157 |
+
line = line[:160].rsplit(" ", 1)[0] + "..."
|
| 158 |
+
dial_line = f"DIALOGUE — {name}: {line}\n"
|
| 159 |
+
multimodal_extra = (
|
| 160 |
+
f" {name} (S1) says: <d>[English] {line}</d>"
|
| 161 |
+
)
|
| 162 |
+
|
| 163 |
+
storyboard = (
|
| 164 |
+
f"cinematic still from {title}: {action_short[:200]}, "
|
| 165 |
+
f"detailed environment, live-action, film lighting"
|
| 166 |
+
)
|
| 167 |
+
|
| 168 |
+
body = (
|
| 169 |
+
f"[Shot 1] Live-action, cinematic, medium shot establishing the scene. "
|
| 170 |
+
f"{action_short} The camera pushes in with small amplitude at slow speed."
|
| 171 |
+
f"{multimodal_extra} "
|
| 172 |
+
f"The framing begins on the composition of Picture 1 and continuously "
|
| 173 |
+
f"evolves until it settles into the composition of Picture 2."
|
| 174 |
+
)
|
| 175 |
+
|
| 176 |
+
return (
|
| 177 |
+
f"## SCENE 1 — {slug}\n"
|
| 178 |
+
f"ACTION: {action_short}\n"
|
| 179 |
+
f"{dial_line}"
|
| 180 |
+
f"SHOT: medium shot, push in with small amplitude at slow speed\n"
|
| 181 |
+
f"STORYBOARD_PROMPT: {storyboard}\n"
|
| 182 |
+
f"H3_MODE: FL2VA\n"
|
| 183 |
+
f"H3_VIDEO_PROMPT:\n"
|
| 184 |
+
f"How the reference pictures align with the target video — Picture 1 "
|
| 185 |
+
f"(from Shot 1) aligns with the 0.00-second mark of the target video; "
|
| 186 |
+
f"Picture 2 (from Shot 1) aligns with the 5.00-second mark of the target video.\n\n"
|
| 187 |
+
f"integrated_multimodal_description: {body}\n\n"
|
| 188 |
+
f"overall_soundscape: Room tone and soft environmental ambience matching the location.\n\n"
|
| 189 |
+
f"non_diegetic_music: N/A\n"
|
| 190 |
+
f"LORA: none\n"
|
| 191 |
+
f"AUDIO: none\n"
|
| 192 |
+
f"DURATION: 5"
|
| 193 |
+
)
|
| 194 |
+
|
| 195 |
+
|
| 196 |
+
def row(messages: list[dict]) -> str:
|
| 197 |
+
return json.dumps({"messages": messages}, ensure_ascii=False)
|
| 198 |
+
|
| 199 |
+
|
| 200 |
+
def build_from_scripts(
|
| 201 |
+
script_dir: Path,
|
| 202 |
+
*,
|
| 203 |
+
max_scripts: int,
|
| 204 |
+
chunks_per_script: int,
|
| 205 |
+
rng: random.Random,
|
| 206 |
+
) -> list[str]:
|
| 207 |
+
files = sorted(script_dir.glob("*.txt"), key=lambda p: int(p.stem) if p.stem.isdigit() else p.stem)
|
| 208 |
+
if max_scripts > 0:
|
| 209 |
+
files = files[:max_scripts]
|
| 210 |
+
rows: list[str] = []
|
| 211 |
+
for path in files:
|
| 212 |
+
try:
|
| 213 |
+
text = path.read_text(encoding="utf-8", errors="replace")
|
| 214 |
+
except OSError:
|
| 215 |
+
continue
|
| 216 |
+
title = extract_title(text)
|
| 217 |
+
chunks = split_scenes(text)
|
| 218 |
+
if not chunks:
|
| 219 |
+
continue
|
| 220 |
+
rng.shuffle(chunks)
|
| 221 |
+
for chunk in chunks[:chunks_per_script]:
|
| 222 |
+
assistant = chunk_to_h3_assistant(chunk, title)
|
| 223 |
+
# Format transfer: classic excerpt → H3 beat
|
| 224 |
+
rows.append(
|
| 225 |
+
row(
|
| 226 |
+
[
|
| 227 |
+
{"role": "system", "content": H3_SYSTEM},
|
| 228 |
+
{
|
| 229 |
+
"role": "user",
|
| 230 |
+
"content": (
|
| 231 |
+
f"Rewrite this screenplay beat as a single ~5s MiniMax-H3 "
|
| 232 |
+
f"FL2VA scene for Backlot (first storyboard panel → last panel).\n\n"
|
| 233 |
+
f"SOURCE TITLE: {title}\n\n"
|
| 234 |
+
f"SCREENPLAY EXCERPT:\n{chunk[:1600]}"
|
| 235 |
+
),
|
| 236 |
+
},
|
| 237 |
+
{"role": "assistant", "content": assistant},
|
| 238 |
+
]
|
| 239 |
+
)
|
| 240 |
+
)
|
| 241 |
+
# Premise → scene (trope-style)
|
| 242 |
+
premise = extract_action_lines(chunk, max_sents=1)
|
| 243 |
+
rows.append(
|
| 244 |
+
row(
|
| 245 |
+
[
|
| 246 |
+
{"role": "system", "content": H3_SYSTEM},
|
| 247 |
+
{
|
| 248 |
+
"role": "user",
|
| 249 |
+
"content": (
|
| 250 |
+
f"Premise: {premise}\n"
|
| 251 |
+
f"Setting: derived from {title}\n"
|
| 252 |
+
f"Tone: cinematic\n"
|
| 253 |
+
f"Write SCENE 1 now (H3 FL2VA, DURATION 5)."
|
| 254 |
+
),
|
| 255 |
+
},
|
| 256 |
+
{"role": "assistant", "content": assistant},
|
| 257 |
+
]
|
| 258 |
+
)
|
| 259 |
+
)
|
| 260 |
+
return rows
|
| 261 |
+
|
| 262 |
+
|
| 263 |
+
def build_from_tropes(path: Path, *, n: int, rng: random.Random) -> list[str]:
|
| 264 |
+
if not path.exists() or n <= 0:
|
| 265 |
+
return []
|
| 266 |
+
# Stream a sample of lines (file is large)
|
| 267 |
+
import csv
|
| 268 |
+
|
| 269 |
+
rows_out: list[str] = []
|
| 270 |
+
with path.open(encoding="utf-8", errors="replace", newline="") as f:
|
| 271 |
+
reader = csv.DictReader(f)
|
| 272 |
+
# sample reservoir
|
| 273 |
+
reservoir: list[dict] = []
|
| 274 |
+
for i, rec in enumerate(reader):
|
| 275 |
+
if i < 5000:
|
| 276 |
+
reservoir.append(rec)
|
| 277 |
+
else:
|
| 278 |
+
j = rng.randint(0, i)
|
| 279 |
+
if j < 5000:
|
| 280 |
+
reservoir[j] = rec
|
| 281 |
+
if i > 200_000: # don't scan entire multi-hundred-MB file
|
| 282 |
+
break
|
| 283 |
+
rng.shuffle(reservoir)
|
| 284 |
+
for rec in reservoir[:n]:
|
| 285 |
+
title = (rec.get("Title") or rec.get("title") or "Untitled").strip()
|
| 286 |
+
trope = (rec.get("Trope") or rec.get("trope") or "PlotTwist").strip()
|
| 287 |
+
example = (rec.get("Example") or rec.get("Description") or "").strip()
|
| 288 |
+
if len(example) > 400:
|
| 289 |
+
example = example[:400] + "..."
|
| 290 |
+
premise = f"A scene in {title} illustrating the trope '{trope}'. {example}"
|
| 291 |
+
# Lightweight target (model will learn shape from script rows primarily)
|
| 292 |
+
assistant = (
|
| 293 |
+
f"## SCENE 1 — INT. SETTING - DAY\n"
|
| 294 |
+
f"ACTION: Characters enact a brief beat embodying {trope}.\n"
|
| 295 |
+
f"SHOT: medium shot, static shot\n"
|
| 296 |
+
f"STORYBOARD_PROMPT: cinematic still for {title}, {trope}, live-action\n"
|
| 297 |
+
f"H3_MODE: FL2VA\n"
|
| 298 |
+
f"H3_VIDEO_PROMPT:\n"
|
| 299 |
+
f"How the reference pictures align with the target video — Picture 1 "
|
| 300 |
+
f"(from Shot 1) aligns with the 0.00-second mark of the target video; "
|
| 301 |
+
f"Picture 2 (from Shot 1) aligns with the 5.00-second mark of the target video.\n\n"
|
| 302 |
+
f"integrated_multimodal_description: [Shot 1] Live-action, cinematic, a medium "
|
| 303 |
+
f"shot introduces the situation for {trope}. The camera holds a static shot as "
|
| 304 |
+
f"the beat resolves into the final composition of Picture 2.\n\n"
|
| 305 |
+
f"overall_soundscape: Soft room tone.\n\n"
|
| 306 |
+
f"non_diegetic_music: N/A\n"
|
| 307 |
+
f"LORA: none\n"
|
| 308 |
+
f"AUDIO: none\n"
|
| 309 |
+
f"DURATION: 5"
|
| 310 |
+
)
|
| 311 |
+
rows_out.append(
|
| 312 |
+
row(
|
| 313 |
+
[
|
| 314 |
+
{"role": "system", "content": H3_SYSTEM},
|
| 315 |
+
{
|
| 316 |
+
"role": "user",
|
| 317 |
+
"content": f"Premise: {premise}\nWrite SCENE 1 now (H3 FL2VA, DURATION 5).",
|
| 318 |
+
},
|
| 319 |
+
{"role": "assistant", "content": assistant},
|
| 320 |
+
]
|
| 321 |
+
)
|
| 322 |
+
)
|
| 323 |
+
return rows_out
|
| 324 |
+
|
| 325 |
+
|
| 326 |
+
def main() -> None:
|
| 327 |
+
ap = argparse.ArgumentParser()
|
| 328 |
+
ap.add_argument("--scriptlib", type=Path, default=SCRIPTLIB)
|
| 329 |
+
ap.add_argument("--out", type=Path, default=OUT_DEFAULT)
|
| 330 |
+
ap.add_argument("--max-scripts", type=int, default=0, help="0 = all")
|
| 331 |
+
ap.add_argument("--chunks-per-script", type=int, default=4)
|
| 332 |
+
ap.add_argument("--tropes", type=int, default=80, help="extra TVTropes premise rows")
|
| 333 |
+
ap.add_argument("--seed", type=int, default=42)
|
| 334 |
+
ap.add_argument("--include-seed", action="store_true", help="prepend train_dataset.jsonl")
|
| 335 |
+
args = ap.parse_args()
|
| 336 |
+
|
| 337 |
+
rng = random.Random(args.seed)
|
| 338 |
+
if not args.scriptlib.is_dir():
|
| 339 |
+
raise SystemExit(f"scriptlib not found: {args.scriptlib}")
|
| 340 |
+
|
| 341 |
+
rows = build_from_scripts(
|
| 342 |
+
args.scriptlib,
|
| 343 |
+
max_scripts=args.max_scripts,
|
| 344 |
+
chunks_per_script=args.chunks_per_script,
|
| 345 |
+
rng=rng,
|
| 346 |
+
)
|
| 347 |
+
rows += build_from_tropes(TROPES_TV, n=args.tropes, rng=rng)
|
| 348 |
+
|
| 349 |
+
seed_path = ROOT / "train_dataset.jsonl"
|
| 350 |
+
if args.include_seed and seed_path.exists():
|
| 351 |
+
seed_rows = [ln for ln in seed_path.read_text().splitlines() if ln.strip()]
|
| 352 |
+
rows = seed_rows + rows
|
| 353 |
+
|
| 354 |
+
rng.shuffle(rows)
|
| 355 |
+
args.out.parent.mkdir(parents=True, exist_ok=True)
|
| 356 |
+
args.out.write_text("\n".join(rows) + "\n", encoding="utf-8")
|
| 357 |
+
print(f"wrote {len(rows)} rows → {args.out}")
|
| 358 |
+
|
| 359 |
+
|
| 360 |
+
if __name__ == "__main__":
|
| 361 |
+
main()
|
scripts/train_dataset.full.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
scripts/train_dataset.jsonl
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{"messages":[{"role":"system","content":"You write ONE MiniMax-H3 FL2VA scene beat for Backlot. Output fields: ACTION, SHOT, STORYBOARD_PROMPT, H3_MODE, H3_VIDEO_PROMPT (alignment + integrated_multimodal_description + overall_soundscape + non_diegetic_music), DURATION 5."},{"role":"user","content":"Premise: A courier in a yellow raincoat delivers a package through a neon alley in the rain.\nSetting: Night, rain-slicked street, pink and cyan neon\nTone: moody, cinematic\nWrite SCENE 1 now."},{"role":"assistant","content":"## SCENE 1 — EXT. NEON ALLEY - NIGHT\nACTION: A courier in a yellow raincoat walks toward camera through steam and puddles; the camera pushes in until their hooded face fills the frame.\nDIALOGUE — COURIER: Almost there.\nSHOT: medium-wide shot, push in with small amplitude at slow speed\nSTORYBOARD_PROMPT: cinematic night alley, rain-slicked pavement, pink and cyan neon signs reflecting in puddles, courier in yellow raincoat walking toward camera, steam from street vent, moody live-action, sharp detail\nH3_MODE: FL2VA\nH3_VIDEO_PROMPT:\nHow the reference pictures align with the target video — Picture 1 (from Shot 1) aligns with the 0.00-second mark of the target video; Picture 2 (from Shot 1) aligns with the 5.00-second mark of the target video.\n\nintegrated_multimodal_description: [Shot 1] Live-action, cinematic, a medium-wide shot opens on the rain-slicked neon alley composition of Picture 1: a courier in a yellow raincoat walks toward the camera through rising steam, pink and cyan signs reflecting in puddles. The camera pushes in with small amplitude at slow speed as rain streaks past the lens. The courier (S1) says in a quiet, breathy voice: <d>[English] Almost there.</d> Their pace steadies until the framing settles into the extreme close-up of the hooded face established by Picture 2, neon catching in their eyes.\n\noverall_soundscape: Steady rain on asphalt and metal awnings, soft steam hiss from a street vent, distant traffic wet-road rumble.\n\nnon_diegetic_music: Sparse synth pads at a slow tempo with a low sub-bass pulse that gently rises then holds.\nLORA: none\nAUDIO: rain bed, optional neon buzz\nDURATION: 5"}]}
|
| 2 |
+
{"messages":[{"role":"system","content":"You write ONE MiniMax-H3 FL2VA scene beat for Backlot. Output fields: ACTION, SHOT, STORYBOARD_PROMPT, H3_MODE, H3_VIDEO_PROMPT (alignment + integrated_multimodal_description + overall_soundscape + non_diegetic_music), DURATION 5."},{"role":"user","content":"Premise: A baker opens a street bakery before sunrise and places the first loaf on the counter.\nTone: warm, quiet\nWrite SCENE 1 now."},{"role":"assistant","content":"## SCENE 1 — EXT./INT. STREET BAKERY - PRE-DAWN\nACTION: A middle-aged baker opens the shutters, then the camera moves inside as they set a warm loaf on the wooden counter.\nDIALOGUE — BAKER: First batch of the morning.\nSHOT: medium-wide, push in with small amplitude at slow speed\nSTORYBOARD_PROMPT: pre-dawn street bakery, baker opening wooden shutters, warm interior light, fresh bread, live-action cinematic, quiet mood\nH3_MODE: FL2VA\nH3_VIDEO_PROMPT:\nHow the reference pictures align with the target video — Picture 1 (from Shot 1) aligns with the 0.00-second mark of the target video; Picture 2 (from Shot 1) aligns with the 5.00-second mark of the target video.\n\nintegrated_multimodal_description: [Shot 1] Live-action, cinematic, a medium-wide shot frames a baker opening the shutters of a small street bakery before sunrise, matching Picture 1. The camera pushes in with small amplitude at slow speed as the middle-aged baker with a calm, slightly raspy voice (S1) places a fresh loaf on the wooden counter and says: <d>[English] First batch of the morning.</d> Steam rises and the composition settles into the close warm counter view of Picture 2.\n\noverall_soundscape: Wooden shutters scrape open over a quiet street; trays clink softly; bread crust crackles as it is set down.\n\nnon_diegetic_music: Soft acoustic-guitar pattern at a moderate tempo with sparse upright-bass notes and a gentle fade.\nLORA: none\nAUDIO: none\nDURATION: 5"}]}
|
| 3 |
+
{"messages":[{"role":"system","content":"You write ONE MiniMax-H3 FL2VA scene beat for Backlot. Output fields: ACTION, SHOT, STORYBOARD_PROMPT, H3_MODE, H3_VIDEO_PROMPT, DURATION 5."},{"role":"user","content":"Premise: A train passenger folds a letter and looks out at city lights in the rain.\nWrite SCENE 1 now."},{"role":"assistant","content":"## SCENE 1 — INT. TRAIN CARRIAGE - NIGHT\nACTION: A young woman by a rain-covered window lowers a letter and turns her gaze to the passing city lights as the camera trucks slightly.\nDIALOGUE — WOMAN: I get off at the next station.\nSHOT: medium close-up, truck right with small amplitude at slow speed\nSTORYBOARD_PROMPT: young woman at rain-covered train window, night city lights outside, folded letter in hands, carriage interior, cinematic live-action\nH3_MODE: FL2VA\nH3_VIDEO_PROMPT:\nHow the reference pictures align with the target video — Picture 1 (from Shot 1) aligns with the 0.00-second mark of the target video; Picture 2 (from Shot 1) aligns with the 5.00-second mark of the target video.\n\nintegrated_multimodal_description: [Shot 1] Live-action, cinematic, the young woman shown in Picture 1 remains beside the rain-covered train window, preserving her appearance, clothing, seat position, and the carriage layout. The camera trucks right with small amplitude at slow speed as she lifts her gaze from the folded letter toward the passing city lights. The quiet, breathy young woman (S1) says: <d>[English] I get off at the next station.</d> She folds the letter along its crease as the frame settles into Picture 2.\n\noverall_soundscape: Train wheels produce a steady metallic rhythm beneath a low ventilation hum. Rain ticks against the window; paper rustles softly.\n\nnon_diegetic_music: Sustained cello notes at a slow tempo with widely spaced piano tones, gradually decreasing in volume.\nLORA: none\nAUDIO: none\nDURATION: 5"}]}
|
| 4 |
+
{"messages":[{"role":"system","content":"You write ONE MiniMax-H3 FL2VA scene beat for Backlot."},{"role":"user","content":"Premise: A rain-soaked cyclist opens a black umbrella beside a silver bicycle.\nWrite SCENE 1 (single continuous FL2VA path)."},{"role":"assistant","content":"## SCENE 1 — EXT. WET STREET - DAY\nACTION: A cyclist raises and opens a black umbrella, stepping under it as the camera pulls out slightly.\nSHOT: medium shot, pull out with small amplitude at slow speed\nSTORYBOARD_PROMPT: rain-soaked cyclist with closed black umbrella beside silver bicycle, wet street, overcast daylight, cinematic\nH3_MODE: FL2VA\nH3_VIDEO_PROMPT:\nHow the reference pictures align with the target video — Picture 1 (from Shot 1) aligns with the 0.00-second mark of the target video; Picture 2 (from Shot 1) aligns with the 5.00-second mark of the target video.\n\nintegrated_multimodal_description: [Shot 1] Live-action, cinematic, a rain-soaked cyclist begins in the position and framing established by Picture 1, holding a closed black umbrella beside a silver bicycle. The camera pulls out with small amplitude at slow speed as she releases the bicycle handle, raises the umbrella, and presses the runner upward until the canopy opens. Water rolls from the expanding fabric while she steps beneath it and settles into the pose and composition established by Picture 2.\n\noverall_soundscape: Rain falls steadily on pavement, followed by the metallic click of the umbrella runner and the soft snap of the canopy opening. Water drips from the bicycle frame; distant traffic passes.\n\nnon_diegetic_music: N/A\nLORA: none\nAUDIO: rain, umbrella snap\nDURATION: 5"}]}
|
| 5 |
+
{"messages":[{"role":"system","content":"You write MiniMax-H3 multi-beat scripts as sequential SCENE blocks (FL2VA)."},{"role":"user","content":"Premise: Two scavengers argue about a locked vault door, then the door opens.\nTone: tense\nApproximate pages: 1"},{"role":"assistant","content":"## SCENE 1 — INT. UNDERGROUND VAULT CORRIDOR - DIM\nACTION: Two scavengers face a sealed vault door; the camera holds as tension rises, ending on a tighter framing of their hands on the wheel lock.\nDIALOGUE — REX: If this seals us in, we're done.\nSHOT: medium two-shot, static shot then slight push in with small amplitude at slow speed\nSTORYBOARD_PROMPT: dim underground corridor, heavy vault door, two scavengers in worn gear, practical work lights, cinematic grit\nH3_MODE: FL2VA\nH3_VIDEO_PROMPT:\nHow the reference pictures align with the target video — Picture 1 (from Shot 1) aligns with the 0.00-second mark of the target video; Picture 2 (from Shot 1) aligns with the 5.00-second mark of the target video.\n\nintegrated_multimodal_description: [Shot 1] Live-action, cinematic, a medium two-shot of scavengers Rex and Mara before a heavy vault door matches Picture 1. The camera holds a static shot, then pushes in with small amplitude at slow speed on their gloved hands on the wheel lock. Rex (S1) says under his breath: <d>[English] If this seals us in, we're done.</d> Mara (S2) keeps silent, jaw set, as the frame tightens to Picture 2.\n\noverall_soundscape: Low ventilation drone, distant metal creaks, glove leather flexing on cold steel.\n\nnon_diegetic_music: A low electronic pulse at a slow tempo that holds without resolving.\nLORA: none\nAUDIO: none\nDURATION: 5\n\n## SCENE 2 — INT. UNDERGROUND VAULT CORRIDOR - DIM\nACTION: The wheel lock turns and the vault door cracks open, light spilling into the corridor as the camera pushes through the gap.\nSHOT: medium shot, push in with large amplitude at moderate speed\nSTORYBOARD_PROMPT: vault door cracking open, hard white light spill, two silhouetted scavengers, dust motes, cinematic\nH3_MODE: FL2VA\nH3_VIDEO_PROMPT:\nHow the reference pictures align with the target video — Picture 1 (from Shot 1) aligns with the 0.00-second mark of the target video; Picture 2 (from Shot 1) aligns with the 5.00-second mark of the target video.\n\nintegrated_multimodal_description: [Shot 1] Live-action, cinematic, continuing from the tight wheel-lock framing of Picture 1. Mara (S2) heaves the wheel; metal groans as the door cracks and hard white light spills into the corridor. The camera pushes in with large amplitude toward the opening until Picture 2's silhouette-and-light composition is reached. Rex (S1) exhales: <d>[English] After you.</d>\n\noverall_soundscape: Wheel lock clanks, door hinges scream, air whooshes as pressure equalizes, light hum rises.\n\nnon_diegetic_music: The electronic pulse cuts to a single sustained high tone as the door opens.\nLORA: none\nAUDIO: heavy door, light bloom sfx\nDURATION: 5"}]}
|
| 6 |
+
{"messages":[{"role":"system","content":"You write ONE MiniMax-H3 FL2VA scene beat for Backlot."},{"role":"user","content":"Premise: Close-up of a glass tipping off a table and shattering (end on broken glass).\nWrite SCENE 1 as FL2VA single shot."},{"role":"assistant","content":"## SCENE 1 — INT. TABLE EDGE - DAY\nACTION: A hand knocks a drinking glass; it falls and shatters; fragments settle into a final arrangement.\nSHOT: close shot, push in with small amplitude at slow speed\nSTORYBOARD_PROMPT: intact drinking glass near edge of dark wooden table, hand approaching from right, soft daylight, cinematic close-up\nH3_MODE: FL2VA\nH3_VIDEO_PROMPT:\nHow the reference pictures align with the target video — Picture 1 (from Shot 1) aligns with the 0.00-second mark of the target video; Picture 2 (from Shot 1) aligns with the 5.00-second mark of the target video.\n\nintegrated_multimodal_description: [Shot 1] Live-action, cinematic, a close shot begins with an intact drinking glass near the edge of a dark wooden table as in Picture 1, while a hand and sleeve approach from the right. The camera pushes in with small amplitude at slow speed as fingertips strike the rim. The glass tips, falls, and hits the floor; cracks spread and fragments slide outward, settling into the broken arrangement and final composition of Picture 2.\n\noverall_soundscape: Fingertips tap glass; it scrapes the tabletop, falls, and breaks with a sharp crash; small fragments scatter and stop.\n\nnon_diegetic_music: A low electronic pulse at a slow tempo, ending immediately after the glass breaks.\nLORA: none\nAUDIO: glass break\nDURATION: 5"}]}
|
scripts/train_script_lora_h3.py
ADDED
|
@@ -0,0 +1,228 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""SFT train / continue-train script-lora for MiniMax-H3 prompt format.
|
| 3 |
+
|
| 4 |
+
Base: Qwen/Qwen3.5-0.8B
|
| 5 |
+
Recommended: --init-from ../final (continue from existing story/tropes adapter)
|
| 6 |
+
Data: train_dataset.full.jsonl (from build_sft_from_scriptlib.py)
|
| 7 |
+
Output: ../h3-v1/ (does not overwrite final/)
|
| 8 |
+
|
| 9 |
+
Examples:
|
| 10 |
+
# Build data from scriptlib + TVTropes
|
| 11 |
+
python build_sft_from_scriptlib.py --include-seed --chunks-per-script 4
|
| 12 |
+
|
| 13 |
+
# Continue-train from existing adapter (keeps story knowledge, adds H3 format)
|
| 14 |
+
python train_script_lora_h3.py \\
|
| 15 |
+
--dataset train_dataset.full.jsonl \\
|
| 16 |
+
--init-from ../final \\
|
| 17 |
+
--epochs 2 --lr 1e-4 --device cuda
|
| 18 |
+
"""
|
| 19 |
+
|
| 20 |
+
from __future__ import annotations
|
| 21 |
+
|
| 22 |
+
import argparse
|
| 23 |
+
import json
|
| 24 |
+
from pathlib import Path
|
| 25 |
+
|
| 26 |
+
ROOT = Path(__file__).resolve().parent
|
| 27 |
+
DATASET = ROOT / "train_dataset.full.jsonl"
|
| 28 |
+
DEFAULT_OUT = Path("/home/bbear/Documents/OlympusServer/models/script-lora/h3-v1")
|
| 29 |
+
DEFAULT_INIT = Path("/home/bbear/Documents/OlympusServer/models/script-lora/final")
|
| 30 |
+
BASE_MODEL = "Qwen/Qwen3.5-0.8B"
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
def load_rows(path: Path) -> list[dict]:
|
| 34 |
+
rows = []
|
| 35 |
+
with path.open() as f:
|
| 36 |
+
for line in f:
|
| 37 |
+
line = line.strip()
|
| 38 |
+
if line:
|
| 39 |
+
rows.append(json.loads(line))
|
| 40 |
+
return rows
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
def main() -> None:
|
| 44 |
+
ap = argparse.ArgumentParser()
|
| 45 |
+
ap.add_argument("--dataset", type=Path, default=DATASET)
|
| 46 |
+
ap.add_argument("--out", type=Path, default=DEFAULT_OUT)
|
| 47 |
+
ap.add_argument("--base-model", default=BASE_MODEL)
|
| 48 |
+
ap.add_argument(
|
| 49 |
+
"--init-from",
|
| 50 |
+
type=Path,
|
| 51 |
+
default=None,
|
| 52 |
+
help="PEFT adapter dir to continue from (e.g. ../final). If set, loads base+adapter.",
|
| 53 |
+
)
|
| 54 |
+
ap.add_argument("--epochs", type=int, default=2)
|
| 55 |
+
ap.add_argument("--lr", type=float, default=1e-4)
|
| 56 |
+
ap.add_argument("--lora-r", type=int, default=16)
|
| 57 |
+
ap.add_argument("--lora-alpha", type=int, default=32)
|
| 58 |
+
ap.add_argument("--max-seq-length", type=int, default=1536)
|
| 59 |
+
ap.add_argument("--device", default="cuda")
|
| 60 |
+
ap.add_argument("--batch-size", type=int, default=1)
|
| 61 |
+
ap.add_argument("--grad-accum", type=int, default=8)
|
| 62 |
+
args = ap.parse_args()
|
| 63 |
+
|
| 64 |
+
if not args.dataset.exists():
|
| 65 |
+
raise SystemExit(
|
| 66 |
+
f"dataset missing: {args.dataset}\n"
|
| 67 |
+
f"Run: python build_sft_from_scriptlib.py --include-seed"
|
| 68 |
+
)
|
| 69 |
+
rows = load_rows(args.dataset)
|
| 70 |
+
if not rows:
|
| 71 |
+
raise SystemExit(f"empty dataset: {args.dataset}")
|
| 72 |
+
|
| 73 |
+
import torch
|
| 74 |
+
from datasets import Dataset
|
| 75 |
+
from peft import LoraConfig, PeftModel
|
| 76 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 77 |
+
from trl import SFTConfig, SFTTrainer
|
| 78 |
+
|
| 79 |
+
# This machine often has torch+xpu only (no CUDA). Fall back automatically.
|
| 80 |
+
if args.device == "cuda" and not torch.cuda.is_available():
|
| 81 |
+
if hasattr(torch, "xpu") and torch.xpu.is_available():
|
| 82 |
+
print("CUDA not available; using XPU instead")
|
| 83 |
+
args.device = "xpu"
|
| 84 |
+
else:
|
| 85 |
+
print("CUDA not available; using CPU (slow)")
|
| 86 |
+
args.device = "cpu"
|
| 87 |
+
|
| 88 |
+
tok = AutoTokenizer.from_pretrained(args.base_model, trust_remote_code=True)
|
| 89 |
+
if tok.pad_token is None:
|
| 90 |
+
tok.pad_token = tok.eos_token
|
| 91 |
+
|
| 92 |
+
def to_text(ex):
|
| 93 |
+
msgs = ex["messages"]
|
| 94 |
+
if hasattr(tok, "apply_chat_template"):
|
| 95 |
+
text = tok.apply_chat_template(
|
| 96 |
+
msgs, tokenize=False, add_generation_prompt=False
|
| 97 |
+
)
|
| 98 |
+
else:
|
| 99 |
+
text = "\n".join(f"{m['role'].upper()}: {m['content']}" for m in msgs)
|
| 100 |
+
return {"text": text}
|
| 101 |
+
|
| 102 |
+
ds = Dataset.from_list(rows).map(to_text)
|
| 103 |
+
|
| 104 |
+
print(f"loading base {args.base_model} ...")
|
| 105 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 106 |
+
args.base_model,
|
| 107 |
+
trust_remote_code=True,
|
| 108 |
+
torch_dtype="auto",
|
| 109 |
+
device_map="auto" if args.device != "cpu" else None,
|
| 110 |
+
)
|
| 111 |
+
|
| 112 |
+
peft_config = None
|
| 113 |
+
init_from = args.init_from
|
| 114 |
+
if init_from is None and DEFAULT_INIT.exists():
|
| 115 |
+
# Default: continue from final/ when present
|
| 116 |
+
init_from = DEFAULT_INIT
|
| 117 |
+
|
| 118 |
+
if init_from and Path(init_from).exists():
|
| 119 |
+
print(f"continuing from adapter {init_from}")
|
| 120 |
+
model = PeftModel.from_pretrained(model, str(init_from), is_trainable=True)
|
| 121 |
+
# Ensure trainable
|
| 122 |
+
for n, p in model.named_parameters():
|
| 123 |
+
if "lora_" in n:
|
| 124 |
+
p.requires_grad = True
|
| 125 |
+
else:
|
| 126 |
+
print("training fresh LoRA (no --init-from)")
|
| 127 |
+
peft_config = LoraConfig(
|
| 128 |
+
r=args.lora_r,
|
| 129 |
+
lora_alpha=args.lora_alpha,
|
| 130 |
+
lora_dropout=0.05,
|
| 131 |
+
bias="none",
|
| 132 |
+
task_type="CAUSAL_LM",
|
| 133 |
+
target_modules=[
|
| 134 |
+
"q_proj", "k_proj", "v_proj", "o_proj",
|
| 135 |
+
"gate_proj", "up_proj", "down_proj",
|
| 136 |
+
],
|
| 137 |
+
)
|
| 138 |
+
|
| 139 |
+
args.out.mkdir(parents=True, exist_ok=True)
|
| 140 |
+
# Intel XPU lacks fp64; fused Adam (default on some stacks) crashes with:
|
| 141 |
+
# RuntimeError: Required aspect fp64 is not supported on the device
|
| 142 |
+
# Force plain AdamW (no fused/foreach kernels).
|
| 143 |
+
sft_config = SFTConfig(
|
| 144 |
+
output_dir=str(args.out),
|
| 145 |
+
num_train_epochs=args.epochs,
|
| 146 |
+
per_device_train_batch_size=args.batch_size,
|
| 147 |
+
gradient_accumulation_steps=args.grad_accum,
|
| 148 |
+
learning_rate=args.lr,
|
| 149 |
+
logging_steps=5,
|
| 150 |
+
save_strategy="epoch",
|
| 151 |
+
max_length=args.max_seq_length,
|
| 152 |
+
dataset_text_field="text",
|
| 153 |
+
report_to=[],
|
| 154 |
+
optim="adamw_torch",
|
| 155 |
+
bf16=False,
|
| 156 |
+
fp16=False,
|
| 157 |
+
)
|
| 158 |
+
|
| 159 |
+
trainer_kwargs = dict(
|
| 160 |
+
model=model,
|
| 161 |
+
args=sft_config,
|
| 162 |
+
train_dataset=ds,
|
| 163 |
+
processing_class=tok,
|
| 164 |
+
)
|
| 165 |
+
if peft_config is not None:
|
| 166 |
+
trainer_kwargs["peft_config"] = peft_config
|
| 167 |
+
|
| 168 |
+
trainer = SFTTrainer(**trainer_kwargs)
|
| 169 |
+
|
| 170 |
+
# Intel XPU: fused Adam requires fp64 (unsupported). Build a plain AdamW.
|
| 171 |
+
use_xpu = args.device == "xpu" or (
|
| 172 |
+
hasattr(torch, "xpu")
|
| 173 |
+
and torch.xpu.is_available()
|
| 174 |
+
and not torch.cuda.is_available()
|
| 175 |
+
)
|
| 176 |
+
if use_xpu:
|
| 177 |
+
def _create_optimizer_xpu_safe(self=trainer):
|
| 178 |
+
if self.optimizer is not None:
|
| 179 |
+
return self.optimizer
|
| 180 |
+
decay, no_decay = [], []
|
| 181 |
+
for n, p in self.model.named_parameters():
|
| 182 |
+
if not p.requires_grad:
|
| 183 |
+
continue
|
| 184 |
+
if any(x in n for x in ("bias", "LayerNorm", "layer_norm", "norm")):
|
| 185 |
+
no_decay.append(p)
|
| 186 |
+
else:
|
| 187 |
+
decay.append(p)
|
| 188 |
+
groups = [
|
| 189 |
+
{"params": decay, "weight_decay": self.args.weight_decay},
|
| 190 |
+
{"params": no_decay, "weight_decay": 0.0},
|
| 191 |
+
]
|
| 192 |
+
self.optimizer = torch.optim.AdamW(
|
| 193 |
+
groups,
|
| 194 |
+
lr=self.args.learning_rate,
|
| 195 |
+
betas=(self.args.adam_beta1, self.args.adam_beta2),
|
| 196 |
+
eps=self.args.adam_epsilon,
|
| 197 |
+
fused=False,
|
| 198 |
+
foreach=False,
|
| 199 |
+
)
|
| 200 |
+
return self.optimizer
|
| 201 |
+
|
| 202 |
+
trainer.create_optimizer = _create_optimizer_xpu_safe.__get__(trainer, type(trainer))
|
| 203 |
+
print("using non-fused AdamW for XPU (no fp64)")
|
| 204 |
+
|
| 205 |
+
trainer.train()
|
| 206 |
+
trainer.save_model(str(args.out))
|
| 207 |
+
tok.save_pretrained(str(args.out))
|
| 208 |
+
meta = {
|
| 209 |
+
"base_model": args.base_model,
|
| 210 |
+
"init_from": str(init_from) if init_from else None,
|
| 211 |
+
"lora_r": args.lora_r,
|
| 212 |
+
"lora_alpha": args.lora_alpha,
|
| 213 |
+
"epochs": args.epochs,
|
| 214 |
+
"learning_rate": args.lr,
|
| 215 |
+
"max_seq_length": args.max_seq_length,
|
| 216 |
+
"dataset": str(args.dataset),
|
| 217 |
+
"dataset_rows": len(rows),
|
| 218 |
+
"format": "minimax-h3-fl2va-v1",
|
| 219 |
+
"scriptlib": str(ROOT.parent / "scriptlib"),
|
| 220 |
+
}
|
| 221 |
+
(args.out / "training_config.json").write_text(
|
| 222 |
+
json.dumps(meta, indent=2) + "\n"
|
| 223 |
+
)
|
| 224 |
+
print(f"saved adapter → {args.out}")
|
| 225 |
+
|
| 226 |
+
|
| 227 |
+
if __name__ == "__main__":
|
| 228 |
+
main()
|
tokenizer.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:06b9509352d2af50381ab2247e083b80d32d5c0aba91c272ca9ff729b6a0e523
|
| 3 |
+
size 19989325
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_prefix_space": false,
|
| 3 |
+
"audio_bos_token": "<|audio_start|>",
|
| 4 |
+
"audio_eos_token": "<|audio_end|>",
|
| 5 |
+
"audio_token": "<|audio_pad|>",
|
| 6 |
+
"backend": "tokenizers",
|
| 7 |
+
"bos_token": null,
|
| 8 |
+
"clean_up_tokenization_spaces": false,
|
| 9 |
+
"eos_token": "<|im_end|>",
|
| 10 |
+
"errors": "replace",
|
| 11 |
+
"image_token": "<|image_pad|>",
|
| 12 |
+
"is_local": false,
|
| 13 |
+
"local_files_only": false,
|
| 14 |
+
"model_max_length": 262144,
|
| 15 |
+
"model_specific_special_tokens": {
|
| 16 |
+
"audio_bos_token": "<|audio_start|>",
|
| 17 |
+
"audio_eos_token": "<|audio_end|>",
|
| 18 |
+
"audio_token": "<|audio_pad|>",
|
| 19 |
+
"image_token": "<|image_pad|>",
|
| 20 |
+
"video_token": "<|video_pad|>",
|
| 21 |
+
"vision_bos_token": "<|vision_start|>",
|
| 22 |
+
"vision_eos_token": "<|vision_end|>"
|
| 23 |
+
},
|
| 24 |
+
"pad_token": "<|endoftext|>",
|
| 25 |
+
"pretokenize_regex": "(?i:'s|'t|'re|'ve|'m|'ll|'d)|[^\\r\\n\\p{L}\\p{N}]?[\\p{L}\\p{M}]+|\\p{N}| ?[^\\s\\p{L}\\p{M}\\p{N}]+[\\r\\n]*|\\s*[\\r\\n]+|\\s+(?!\\S)|\\s+",
|
| 26 |
+
"split_special_tokens": false,
|
| 27 |
+
"tokenizer_class": "Qwen2Tokenizer",
|
| 28 |
+
"unk_token": null,
|
| 29 |
+
"video_token": "<|video_pad|>",
|
| 30 |
+
"vision_bos_token": "<|vision_start|>",
|
| 31 |
+
"vision_eos_token": "<|vision_end|>"
|
| 32 |
+
}
|
training_config.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"base_model": "Qwen/Qwen3.5-0.8B",
|
| 3 |
+
"init_from": "/home/bbear/Documents/OlympusServer/models/script-lora/final",
|
| 4 |
+
"lora_r": 16,
|
| 5 |
+
"lora_alpha": 32,
|
| 6 |
+
"epochs": 2,
|
| 7 |
+
"learning_rate": 0.0001,
|
| 8 |
+
"max_seq_length": 1536,
|
| 9 |
+
"dataset": "/home/bbear/Documents/OlympusServer/models/script-lora/h3-format/train_dataset.full.jsonl",
|
| 10 |
+
"dataset_rows": 836,
|
| 11 |
+
"format": "minimax-h3-fl2va-v1",
|
| 12 |
+
"scriptlib": "/home/bbear/Documents/OlympusServer/models/script-lora/scriptlib"
|
| 13 |
+
}
|