初始化项目,由ModelHub XC社区提供模型

Model: Pageshift-Entertainment/pagestorm-research-preview-24b-first-chapter-only
Source: Original Platform
This commit is contained in:
ModelHub XC
2026-11-01 05:00:18 +08:00
commit 5bf151128c
45 changed files with 16816 additions and 0 deletions

38
.gitattributes vendored Normal file
View File

@@ -0,0 +1,38 @@
*.7z filter=lfs diff=lfs merge=lfs -text
*.arrow filter=lfs diff=lfs merge=lfs -text
*.bin filter=lfs diff=lfs merge=lfs -text
*.bz2 filter=lfs diff=lfs merge=lfs -text
*.ckpt filter=lfs diff=lfs merge=lfs -text
*.ftz filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.h5 filter=lfs diff=lfs merge=lfs -text
*.joblib filter=lfs diff=lfs merge=lfs -text
*.lfs.* filter=lfs diff=lfs merge=lfs -text
*.mlmodel filter=lfs diff=lfs merge=lfs -text
*.model filter=lfs diff=lfs merge=lfs -text
*.msgpack filter=lfs diff=lfs merge=lfs -text
*.npy filter=lfs diff=lfs merge=lfs -text
*.npz filter=lfs diff=lfs merge=lfs -text
*.onnx filter=lfs diff=lfs merge=lfs -text
*.ot filter=lfs diff=lfs merge=lfs -text
*.parquet filter=lfs diff=lfs merge=lfs -text
*.pb filter=lfs diff=lfs merge=lfs -text
*.pickle filter=lfs diff=lfs merge=lfs -text
*.pkl filter=lfs diff=lfs merge=lfs -text
*.pt filter=lfs diff=lfs merge=lfs -text
*.pth filter=lfs diff=lfs merge=lfs -text
*.rar filter=lfs diff=lfs merge=lfs -text
*.safetensors filter=lfs diff=lfs merge=lfs -text
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
*.tar.* filter=lfs diff=lfs merge=lfs -text
*.tar filter=lfs diff=lfs merge=lfs -text
*.tflite filter=lfs diff=lfs merge=lfs -text
*.tgz filter=lfs diff=lfs merge=lfs -text
*.wasm filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text
*tfevents* filter=lfs diff=lfs merge=lfs -text
tekken.json filter=lfs diff=lfs merge=lfs -text
tokenizer.json filter=lfs diff=lfs merge=lfs -text
cover_image.png filter=lfs diff=lfs merge=lfs -text

44
README.md Normal file
View File

@@ -0,0 +1,44 @@
---
library_name: transformers
pipeline_tag: text-generation
datasets:
- Pageshift-Entertainment/LongPage
tags:
- text-generation
- transformers
- vllm
- story-generation
- staged-generation
- first-chapter
license: apache-2.0
language:
- en
---
![PageStorm Research Preview 24B First Chapter Only](cover_image.png)
# PageStorm Research Preview 24B First Chapter Only
### Paper: [`2605.17064`](https://huggingface.co/papers/2605.17064)
### Collection: [`PageStorm Research Preview`](https://huggingface.co/collections/Pageshift-Entertainment/pagestorm-research-preview)
### Twitter / X: [`https://x.com/pageshiftAI`](https://x.com/pageshiftAI)
### Job Openings: [`https://pageshift.ai/hiring`](https://pageshift.ai/hiring)
This is an older pipe-cleaning model and is not the one described in the paper. It was trained to only generate until the first chapter, and it uses an older and simpler planning scaffold. It was trained without the LongPage Dataset and was initialized from a Mistral 24B base model. The training was performed on a V5p-64 TPU Pod provided by Google’s TPU Research Cloud.
The model is single-turn only and cannot receive additional user prompts after the initial one.
> [!WARNING]
> **Important Safety Note:** This model was trained **without safety** guidelines in place. It **cannot refuse** any requests on its own and should be deployed behind a separate safety classifier.
## Usage Example
```bash
pip install "git+https://github.com/Pageshift-ai/pagestorm.git"
```
```bash
pagestorm generate \
--repo-id Pageshift-Entertainment/pagestorm-research-preview-24b-first-chapter-only \
--prompt "Thriller in Zurich"
```

23
chat_template.jinja Normal file
View File

@@ -0,0 +1,23 @@
{% for message in messages %}{% set role = message['role'] %}{% set content = message['content'] | default('', true) %}{% if role == 'prompt' %}<|start_header_id|>prompt<|stop_header_id|>
{% elif role == 'book_preview' %}<|start_header_id|>book_preview<|stop_header_id|>
{% elif role == 'book_plan' %}<|start_header_id|>book_plan<|stop_header_id|>
{% elif role == 'first_chapter_plan' %}<|start_header_id|>first_chapter_plan<|stop_header_id|>
{% elif role == 'first_chapter_scene_breakdown' %}<|start_header_id|>first_chapter_scene_breakdown<|stop_header_id|>
{% elif role == 'first_chapter_text' %}<|start_header_id|>first_chapter_text<|stop_header_id|>
{% elif role == 'full_book_chapters_plan' %}<|start_header_id|>full_book_chapters_plan<|stop_header_id|>
{% elif role == 'book_characters_list' %}<|start_header_id|>book_characters_list<|stop_header_id|>
{% elif role == 'scene_breakdown' %}<|start_header_id|>scene_breakdown<|stop_header_id|>
{% elif role == 'chapter_text' %}<|start_header_id|>chapter_text<|stop_header_id|>
{% else %}<|start_header_id|>{{ role }}<|stop_header_id|>
{% endif %}{{ content }}{% if not loop.last or content %}<|eot_id|>{% endif %}{% endfor %}

28
config.json Normal file
View File

@@ -0,0 +1,28 @@
{
"architectures": [
"MistralForCausalLM"
],
"attention_dropout": 0.0,
"bos_token_id": 1,
"dtype": "bfloat16",
"eos_token_id": 2,
"head_dim": 128,
"hidden_act": "silu",
"hidden_size": 5120,
"initializer_range": 0.02,
"intermediate_size": 32768,
"max_position_embeddings": 32768,
"model_type": "mistral",
"num_attention_heads": 32,
"num_hidden_layers": 40,
"num_key_value_heads": 16,
"pad_token_id": null,
"rms_norm_eps": 1e-05,
"rope_parameters": null,
"rope_theta": 100000000.0,
"sliding_window": null,
"tie_word_embeddings": false,
"transformers_version": "5.12.1",
"use_cache": true,
"vocab_size": 131072
}

3
cover_image.png Normal file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:c18725bf03ea3b952b1f5a9abfcee8afc18c07cd50d4697ba28c477618e7d27f
size 10504492

6
generation_config.json Normal file
View File

@@ -0,0 +1,6 @@
{
"_from_model_config": true,
"bos_token_id": 1,
"eos_token_id": 2,
"transformers_version": "4.49.0.dev0"
}

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:8c47db7a088b87d901372b29ca7199875ed7b7e9b53d8f43377a79399005d339
size 1342177376

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:c6f5be7646ca5c679173c794c6d6f5da9a4749611e3f9f03df60966790c37100
size 1677732176

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:b3dc12f2f1746f1eb0d9dfd1123e3fe2ed25659f07940f954da8f1d607e6d7fc
size 1468028024

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:f3f6952590186b067bc2bb22e60833c3b1febe41f2d83656c4ac770ddd01a879
size 1593878328

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:ce10a99144d6c2908bb500e50cb37f1e296cb558cd898895fec5e048a35b3b70
size 1468028048

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:2b5d7c3402f8dd7268d4b2c091c9fa8a6fcccce62e5dac180b122e3aa5611c51
size 1468028032

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:958d97accb4227dda0af18a8ac182a21357fd4ad46df4fc72a8d39e17ce40243
size 1593878336

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:16a700e9abe25d41fd0166366a38deb62b56154855e483091603fa68a3df00ae
size 1468028048

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:1a9dd1a9084c173bcc9e9f6433184c8d67be0de11babc0d1c7f2207dda157255
size 1468028032

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:46384fa3d60f54a2e90a76a20b4f2b9999163d24c83bd347969654fb72cb05d0
size 1593878336

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:61e135bab1a3bef168b39fabcf3cec1fb89bbdaa0a20097bf75facbc07a34a19
size 1468028048

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:e6b895e59b0f13a00d25d89e4ea8ce2335dc9b980b90ab6c4d9925fe772ade0b
size 1468028024

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:5ea6a96255f26ff12ffb53a7510d02119d4066fb13c160b12062bd4dc15b2a20
size 1593878336

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:947edef8e07bdf2ec8d51e38196169fe35d80679eaf9b60900f02a2951868640
size 1468028048

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:7815b69846f0b241efdaf003fa5780eb051cf05865ec85eebb8e4b8e6cc495e7
size 1468028032

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:9f1833c0b69ea3755c61bbf27cd67a93fffab53fc486590fb428128c7706c6b9
size 1593878336

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:62d00a41863f5aa85d7227a668a424433c69d416591ebc38d0b5113a30a90954
size 1468028048

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:716cd100fda86631de424b281c4359c086961c2b3d58b3749be62c2a6c600538
size 1468028032

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:9c323780bce99a3e6f5150d4dfb7aa87ca26de7452f5645e76a032526baf2440
size 1593878336

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:dcaa5e1b1abe44bd435ba5614714fe3ff38c0381906a26d8313cfce0649a6b14
size 1468028040

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:aaaf93fa4b8f1b015f30a635c1c394680c7fe555b8dd3af33ee7e068a4f2bdcb
size 1468028032

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:6daf8368c4e90dfe3e87977e0d4630d1eb7ea929fee1bf20fa051489195e585f
size 1593878336

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:d506b17c6c132caca71e4338556c8d686a3f934ccd876ae453a17fa0f816beb3
size 1468028048

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:cfb7a528da69d28a323238e4401ec97fccc0886183a5d2abeb4cf981459fa693
size 1468028032

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:88250492bd304203e53b07a52ee3856b64e7b665a777d268fe67d28c004292a0
size 1593878336

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:4f9a4b08dd633a4e167351ca6e8a7d7d5c1a0eb369fe4629f22eee74ba5356b6
size 1468028048

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:b8324bb2bad691a180e9a485c64c25915e4959b88d053150fdbb5969375c51ac
size 1468028032

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:df38f8d0e6454a362bafe764033c45385a7a28afad22ab9e0da57fc0103ec5d5
size 1593878328

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:762f3006cbe3a98d8df7df8c13d5592ceb175699d3bf49a4e8701ca1d3118405
size 1468028040

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:e7710f13199307593a7d10d28d5666d857a59c56ec93721a7c0fb41e76d7c0f5
size 1468028024

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:8080bf7226766308fb784858c9500df8789bf2433c9faa417312825f9b569805
size 1593878320

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:6e96a6ff68b84f2e747a209a8071206b96c022adc610962647d64904d6ceaa69
size 1132483584

View File

@@ -0,0 +1,370 @@
{
"metadata": {
"total_size": 47983667200
},
"weight_map": {
"lm_head.weight": "model-00001-of-00032.safetensors",
"model.embed_tokens.weight": "model-00002-of-00032.safetensors",
"model.layers.0.input_layernorm.weight": "model-00002-of-00032.safetensors",
"model.layers.0.mlp.down_proj.weight": "model-00002-of-00032.safetensors",
"model.layers.0.mlp.gate_proj.weight": "model-00003-of-00032.safetensors",
"model.layers.0.mlp.up_proj.weight": "model-00003-of-00032.safetensors",
"model.layers.0.post_attention_layernorm.weight": "model-00003-of-00032.safetensors",
"model.layers.0.self_attn.k_proj.weight": "model-00003-of-00032.safetensors",
"model.layers.0.self_attn.o_proj.weight": "model-00003-of-00032.safetensors",
"model.layers.0.self_attn.q_proj.weight": "model-00003-of-00032.safetensors",
"model.layers.0.self_attn.v_proj.weight": "model-00003-of-00032.safetensors",
"model.layers.1.input_layernorm.weight": "model-00003-of-00032.safetensors",
"model.layers.1.mlp.down_proj.weight": "model-00003-of-00032.safetensors",
"model.layers.1.mlp.gate_proj.weight": "model-00003-of-00032.safetensors",
"model.layers.1.mlp.up_proj.weight": "model-00004-of-00032.safetensors",
"model.layers.1.post_attention_layernorm.weight": "model-00004-of-00032.safetensors",
"model.layers.1.self_attn.k_proj.weight": "model-00004-of-00032.safetensors",
"model.layers.1.self_attn.o_proj.weight": "model-00004-of-00032.safetensors",
"model.layers.1.self_attn.q_proj.weight": "model-00004-of-00032.safetensors",
"model.layers.1.self_attn.v_proj.weight": "model-00004-of-00032.safetensors",
"model.layers.10.input_layernorm.weight": "model-00004-of-00032.safetensors",
"model.layers.10.mlp.down_proj.weight": "model-00004-of-00032.safetensors",
"model.layers.10.mlp.gate_proj.weight": "model-00004-of-00032.safetensors",
"model.layers.10.mlp.up_proj.weight": "model-00004-of-00032.safetensors",
"model.layers.10.post_attention_layernorm.weight": "model-00004-of-00032.safetensors",
"model.layers.10.self_attn.k_proj.weight": "model-00004-of-00032.safetensors",
"model.layers.10.self_attn.o_proj.weight": "model-00004-of-00032.safetensors",
"model.layers.10.self_attn.q_proj.weight": "model-00004-of-00032.safetensors",
"model.layers.10.self_attn.v_proj.weight": "model-00004-of-00032.safetensors",
"model.layers.11.input_layernorm.weight": "model-00004-of-00032.safetensors",
"model.layers.11.mlp.down_proj.weight": "model-00005-of-00032.safetensors",
"model.layers.11.mlp.gate_proj.weight": "model-00005-of-00032.safetensors",
"model.layers.11.mlp.up_proj.weight": "model-00005-of-00032.safetensors",
"model.layers.11.post_attention_layernorm.weight": "model-00005-of-00032.safetensors",
"model.layers.11.self_attn.k_proj.weight": "model-00005-of-00032.safetensors",
"model.layers.11.self_attn.o_proj.weight": "model-00005-of-00032.safetensors",
"model.layers.11.self_attn.q_proj.weight": "model-00005-of-00032.safetensors",
"model.layers.11.self_attn.v_proj.weight": "model-00005-of-00032.safetensors",
"model.layers.12.input_layernorm.weight": "model-00005-of-00032.safetensors",
"model.layers.12.mlp.down_proj.weight": "model-00005-of-00032.safetensors",
"model.layers.12.mlp.gate_proj.weight": "model-00006-of-00032.safetensors",
"model.layers.12.mlp.up_proj.weight": "model-00006-of-00032.safetensors",
"model.layers.12.post_attention_layernorm.weight": "model-00006-of-00032.safetensors",
"model.layers.12.self_attn.k_proj.weight": "model-00006-of-00032.safetensors",
"model.layers.12.self_attn.o_proj.weight": "model-00006-of-00032.safetensors",
"model.layers.12.self_attn.q_proj.weight": "model-00006-of-00032.safetensors",
"model.layers.12.self_attn.v_proj.weight": "model-00006-of-00032.safetensors",
"model.layers.13.input_layernorm.weight": "model-00006-of-00032.safetensors",
"model.layers.13.mlp.down_proj.weight": "model-00006-of-00032.safetensors",
"model.layers.13.mlp.gate_proj.weight": "model-00006-of-00032.safetensors",
"model.layers.13.mlp.up_proj.weight": "model-00007-of-00032.safetensors",
"model.layers.13.post_attention_layernorm.weight": "model-00007-of-00032.safetensors",
"model.layers.13.self_attn.k_proj.weight": "model-00007-of-00032.safetensors",
"model.layers.13.self_attn.o_proj.weight": "model-00007-of-00032.safetensors",
"model.layers.13.self_attn.q_proj.weight": "model-00007-of-00032.safetensors",
"model.layers.13.self_attn.v_proj.weight": "model-00007-of-00032.safetensors",
"model.layers.14.input_layernorm.weight": "model-00007-of-00032.safetensors",
"model.layers.14.mlp.down_proj.weight": "model-00007-of-00032.safetensors",
"model.layers.14.mlp.gate_proj.weight": "model-00007-of-00032.safetensors",
"model.layers.14.mlp.up_proj.weight": "model-00007-of-00032.safetensors",
"model.layers.14.post_attention_layernorm.weight": "model-00007-of-00032.safetensors",
"model.layers.14.self_attn.k_proj.weight": "model-00007-of-00032.safetensors",
"model.layers.14.self_attn.o_proj.weight": "model-00007-of-00032.safetensors",
"model.layers.14.self_attn.q_proj.weight": "model-00007-of-00032.safetensors",
"model.layers.14.self_attn.v_proj.weight": "model-00007-of-00032.safetensors",
"model.layers.15.input_layernorm.weight": "model-00007-of-00032.safetensors",
"model.layers.15.mlp.down_proj.weight": "model-00008-of-00032.safetensors",
"model.layers.15.mlp.gate_proj.weight": "model-00008-of-00032.safetensors",
"model.layers.15.mlp.up_proj.weight": "model-00008-of-00032.safetensors",
"model.layers.15.post_attention_layernorm.weight": "model-00008-of-00032.safetensors",
"model.layers.15.self_attn.k_proj.weight": "model-00008-of-00032.safetensors",
"model.layers.15.self_attn.o_proj.weight": "model-00008-of-00032.safetensors",
"model.layers.15.self_attn.q_proj.weight": "model-00008-of-00032.safetensors",
"model.layers.15.self_attn.v_proj.weight": "model-00008-of-00032.safetensors",
"model.layers.16.input_layernorm.weight": "model-00008-of-00032.safetensors",
"model.layers.16.mlp.down_proj.weight": "model-00008-of-00032.safetensors",
"model.layers.16.mlp.gate_proj.weight": "model-00009-of-00032.safetensors",
"model.layers.16.mlp.up_proj.weight": "model-00009-of-00032.safetensors",
"model.layers.16.post_attention_layernorm.weight": "model-00009-of-00032.safetensors",
"model.layers.16.self_attn.k_proj.weight": "model-00009-of-00032.safetensors",
"model.layers.16.self_attn.o_proj.weight": "model-00009-of-00032.safetensors",
"model.layers.16.self_attn.q_proj.weight": "model-00009-of-00032.safetensors",
"model.layers.16.self_attn.v_proj.weight": "model-00009-of-00032.safetensors",
"model.layers.17.input_layernorm.weight": "model-00009-of-00032.safetensors",
"model.layers.17.mlp.down_proj.weight": "model-00009-of-00032.safetensors",
"model.layers.17.mlp.gate_proj.weight": "model-00009-of-00032.safetensors",
"model.layers.17.mlp.up_proj.weight": "model-00010-of-00032.safetensors",
"model.layers.17.post_attention_layernorm.weight": "model-00010-of-00032.safetensors",
"model.layers.17.self_attn.k_proj.weight": "model-00010-of-00032.safetensors",
"model.layers.17.self_attn.o_proj.weight": "model-00010-of-00032.safetensors",
"model.layers.17.self_attn.q_proj.weight": "model-00010-of-00032.safetensors",
"model.layers.17.self_attn.v_proj.weight": "model-00010-of-00032.safetensors",
"model.layers.18.input_layernorm.weight": "model-00010-of-00032.safetensors",
"model.layers.18.mlp.down_proj.weight": "model-00010-of-00032.safetensors",
"model.layers.18.mlp.gate_proj.weight": "model-00010-of-00032.safetensors",
"model.layers.18.mlp.up_proj.weight": "model-00010-of-00032.safetensors",
"model.layers.18.post_attention_layernorm.weight": "model-00010-of-00032.safetensors",
"model.layers.18.self_attn.k_proj.weight": "model-00010-of-00032.safetensors",
"model.layers.18.self_attn.o_proj.weight": "model-00010-of-00032.safetensors",
"model.layers.18.self_attn.q_proj.weight": "model-00010-of-00032.safetensors",
"model.layers.18.self_attn.v_proj.weight": "model-00010-of-00032.safetensors",
"model.layers.19.input_layernorm.weight": "model-00010-of-00032.safetensors",
"model.layers.19.mlp.down_proj.weight": "model-00011-of-00032.safetensors",
"model.layers.19.mlp.gate_proj.weight": "model-00011-of-00032.safetensors",
"model.layers.19.mlp.up_proj.weight": "model-00011-of-00032.safetensors",
"model.layers.19.post_attention_layernorm.weight": "model-00011-of-00032.safetensors",
"model.layers.19.self_attn.k_proj.weight": "model-00011-of-00032.safetensors",
"model.layers.19.self_attn.o_proj.weight": "model-00011-of-00032.safetensors",
"model.layers.19.self_attn.q_proj.weight": "model-00011-of-00032.safetensors",
"model.layers.19.self_attn.v_proj.weight": "model-00011-of-00032.safetensors",
"model.layers.2.input_layernorm.weight": "model-00011-of-00032.safetensors",
"model.layers.2.mlp.down_proj.weight": "model-00011-of-00032.safetensors",
"model.layers.2.mlp.gate_proj.weight": "model-00012-of-00032.safetensors",
"model.layers.2.mlp.up_proj.weight": "model-00012-of-00032.safetensors",
"model.layers.2.post_attention_layernorm.weight": "model-00012-of-00032.safetensors",
"model.layers.2.self_attn.k_proj.weight": "model-00012-of-00032.safetensors",
"model.layers.2.self_attn.o_proj.weight": "model-00012-of-00032.safetensors",
"model.layers.2.self_attn.q_proj.weight": "model-00012-of-00032.safetensors",
"model.layers.2.self_attn.v_proj.weight": "model-00012-of-00032.safetensors",
"model.layers.20.input_layernorm.weight": "model-00012-of-00032.safetensors",
"model.layers.20.mlp.down_proj.weight": "model-00012-of-00032.safetensors",
"model.layers.20.mlp.gate_proj.weight": "model-00012-of-00032.safetensors",
"model.layers.20.mlp.up_proj.weight": "model-00013-of-00032.safetensors",
"model.layers.20.post_attention_layernorm.weight": "model-00013-of-00032.safetensors",
"model.layers.20.self_attn.k_proj.weight": "model-00013-of-00032.safetensors",
"model.layers.20.self_attn.o_proj.weight": "model-00013-of-00032.safetensors",
"model.layers.20.self_attn.q_proj.weight": "model-00013-of-00032.safetensors",
"model.layers.20.self_attn.v_proj.weight": "model-00013-of-00032.safetensors",
"model.layers.21.input_layernorm.weight": "model-00013-of-00032.safetensors",
"model.layers.21.mlp.down_proj.weight": "model-00013-of-00032.safetensors",
"model.layers.21.mlp.gate_proj.weight": "model-00013-of-00032.safetensors",
"model.layers.21.mlp.up_proj.weight": "model-00013-of-00032.safetensors",
"model.layers.21.post_attention_layernorm.weight": "model-00013-of-00032.safetensors",
"model.layers.21.self_attn.k_proj.weight": "model-00013-of-00032.safetensors",
"model.layers.21.self_attn.o_proj.weight": "model-00013-of-00032.safetensors",
"model.layers.21.self_attn.q_proj.weight": "model-00013-of-00032.safetensors",
"model.layers.21.self_attn.v_proj.weight": "model-00013-of-00032.safetensors",
"model.layers.22.input_layernorm.weight": "model-00013-of-00032.safetensors",
"model.layers.22.mlp.down_proj.weight": "model-00014-of-00032.safetensors",
"model.layers.22.mlp.gate_proj.weight": "model-00014-of-00032.safetensors",
"model.layers.22.mlp.up_proj.weight": "model-00014-of-00032.safetensors",
"model.layers.22.post_attention_layernorm.weight": "model-00014-of-00032.safetensors",
"model.layers.22.self_attn.k_proj.weight": "model-00014-of-00032.safetensors",
"model.layers.22.self_attn.o_proj.weight": "model-00014-of-00032.safetensors",
"model.layers.22.self_attn.q_proj.weight": "model-00014-of-00032.safetensors",
"model.layers.22.self_attn.v_proj.weight": "model-00014-of-00032.safetensors",
"model.layers.23.input_layernorm.weight": "model-00014-of-00032.safetensors",
"model.layers.23.mlp.down_proj.weight": "model-00014-of-00032.safetensors",
"model.layers.23.mlp.gate_proj.weight": "model-00015-of-00032.safetensors",
"model.layers.23.mlp.up_proj.weight": "model-00015-of-00032.safetensors",
"model.layers.23.post_attention_layernorm.weight": "model-00015-of-00032.safetensors",
"model.layers.23.self_attn.k_proj.weight": "model-00015-of-00032.safetensors",
"model.layers.23.self_attn.o_proj.weight": "model-00015-of-00032.safetensors",
"model.layers.23.self_attn.q_proj.weight": "model-00015-of-00032.safetensors",
"model.layers.23.self_attn.v_proj.weight": "model-00015-of-00032.safetensors",
"model.layers.24.input_layernorm.weight": "model-00015-of-00032.safetensors",
"model.layers.24.mlp.down_proj.weight": "model-00015-of-00032.safetensors",
"model.layers.24.mlp.gate_proj.weight": "model-00015-of-00032.safetensors",
"model.layers.24.mlp.up_proj.weight": "model-00016-of-00032.safetensors",
"model.layers.24.post_attention_layernorm.weight": "model-00016-of-00032.safetensors",
"model.layers.24.self_attn.k_proj.weight": "model-00016-of-00032.safetensors",
"model.layers.24.self_attn.o_proj.weight": "model-00016-of-00032.safetensors",
"model.layers.24.self_attn.q_proj.weight": "model-00016-of-00032.safetensors",
"model.layers.24.self_attn.v_proj.weight": "model-00016-of-00032.safetensors",
"model.layers.25.input_layernorm.weight": "model-00016-of-00032.safetensors",
"model.layers.25.mlp.down_proj.weight": "model-00016-of-00032.safetensors",
"model.layers.25.mlp.gate_proj.weight": "model-00016-of-00032.safetensors",
"model.layers.25.mlp.up_proj.weight": "model-00016-of-00032.safetensors",
"model.layers.25.post_attention_layernorm.weight": "model-00016-of-00032.safetensors",
"model.layers.25.self_attn.k_proj.weight": "model-00016-of-00032.safetensors",
"model.layers.25.self_attn.o_proj.weight": "model-00016-of-00032.safetensors",
"model.layers.25.self_attn.q_proj.weight": "model-00016-of-00032.safetensors",
"model.layers.25.self_attn.v_proj.weight": "model-00016-of-00032.safetensors",
"model.layers.26.input_layernorm.weight": "model-00016-of-00032.safetensors",
"model.layers.26.mlp.down_proj.weight": "model-00017-of-00032.safetensors",
"model.layers.26.mlp.gate_proj.weight": "model-00017-of-00032.safetensors",
"model.layers.26.mlp.up_proj.weight": "model-00017-of-00032.safetensors",
"model.layers.26.post_attention_layernorm.weight": "model-00017-of-00032.safetensors",
"model.layers.26.self_attn.k_proj.weight": "model-00017-of-00032.safetensors",
"model.layers.26.self_attn.o_proj.weight": "model-00017-of-00032.safetensors",
"model.layers.26.self_attn.q_proj.weight": "model-00017-of-00032.safetensors",
"model.layers.26.self_attn.v_proj.weight": "model-00017-of-00032.safetensors",
"model.layers.27.input_layernorm.weight": "model-00017-of-00032.safetensors",
"model.layers.27.mlp.down_proj.weight": "model-00017-of-00032.safetensors",
"model.layers.27.mlp.gate_proj.weight": "model-00018-of-00032.safetensors",
"model.layers.27.mlp.up_proj.weight": "model-00018-of-00032.safetensors",
"model.layers.27.post_attention_layernorm.weight": "model-00018-of-00032.safetensors",
"model.layers.27.self_attn.k_proj.weight": "model-00018-of-00032.safetensors",
"model.layers.27.self_attn.o_proj.weight": "model-00018-of-00032.safetensors",
"model.layers.27.self_attn.q_proj.weight": "model-00018-of-00032.safetensors",
"model.layers.27.self_attn.v_proj.weight": "model-00018-of-00032.safetensors",
"model.layers.28.input_layernorm.weight": "model-00018-of-00032.safetensors",
"model.layers.28.mlp.down_proj.weight": "model-00018-of-00032.safetensors",
"model.layers.28.mlp.gate_proj.weight": "model-00018-of-00032.safetensors",
"model.layers.28.mlp.up_proj.weight": "model-00019-of-00032.safetensors",
"model.layers.28.post_attention_layernorm.weight": "model-00019-of-00032.safetensors",
"model.layers.28.self_attn.k_proj.weight": "model-00019-of-00032.safetensors",
"model.layers.28.self_attn.o_proj.weight": "model-00019-of-00032.safetensors",
"model.layers.28.self_attn.q_proj.weight": "model-00019-of-00032.safetensors",
"model.layers.28.self_attn.v_proj.weight": "model-00019-of-00032.safetensors",
"model.layers.29.input_layernorm.weight": "model-00019-of-00032.safetensors",
"model.layers.29.mlp.down_proj.weight": "model-00019-of-00032.safetensors",
"model.layers.29.mlp.gate_proj.weight": "model-00019-of-00032.safetensors",
"model.layers.29.mlp.up_proj.weight": "model-00019-of-00032.safetensors",
"model.layers.29.post_attention_layernorm.weight": "model-00019-of-00032.safetensors",
"model.layers.29.self_attn.k_proj.weight": "model-00019-of-00032.safetensors",
"model.layers.29.self_attn.o_proj.weight": "model-00019-of-00032.safetensors",
"model.layers.29.self_attn.q_proj.weight": "model-00019-of-00032.safetensors",
"model.layers.29.self_attn.v_proj.weight": "model-00019-of-00032.safetensors",
"model.layers.3.input_layernorm.weight": "model-00019-of-00032.safetensors",
"model.layers.3.mlp.down_proj.weight": "model-00020-of-00032.safetensors",
"model.layers.3.mlp.gate_proj.weight": "model-00020-of-00032.safetensors",
"model.layers.3.mlp.up_proj.weight": "model-00020-of-00032.safetensors",
"model.layers.3.post_attention_layernorm.weight": "model-00020-of-00032.safetensors",
"model.layers.3.self_attn.k_proj.weight": "model-00020-of-00032.safetensors",
"model.layers.3.self_attn.o_proj.weight": "model-00020-of-00032.safetensors",
"model.layers.3.self_attn.q_proj.weight": "model-00020-of-00032.safetensors",
"model.layers.3.self_attn.v_proj.weight": "model-00020-of-00032.safetensors",
"model.layers.30.input_layernorm.weight": "model-00020-of-00032.safetensors",
"model.layers.30.mlp.down_proj.weight": "model-00020-of-00032.safetensors",
"model.layers.30.mlp.gate_proj.weight": "model-00021-of-00032.safetensors",
"model.layers.30.mlp.up_proj.weight": "model-00021-of-00032.safetensors",
"model.layers.30.post_attention_layernorm.weight": "model-00021-of-00032.safetensors",
"model.layers.30.self_attn.k_proj.weight": "model-00021-of-00032.safetensors",
"model.layers.30.self_attn.o_proj.weight": "model-00021-of-00032.safetensors",
"model.layers.30.self_attn.q_proj.weight": "model-00021-of-00032.safetensors",
"model.layers.30.self_attn.v_proj.weight": "model-00021-of-00032.safetensors",
"model.layers.31.input_layernorm.weight": "model-00021-of-00032.safetensors",
"model.layers.31.mlp.down_proj.weight": "model-00021-of-00032.safetensors",
"model.layers.31.mlp.gate_proj.weight": "model-00021-of-00032.safetensors",
"model.layers.31.mlp.up_proj.weight": "model-00022-of-00032.safetensors",
"model.layers.31.post_attention_layernorm.weight": "model-00022-of-00032.safetensors",
"model.layers.31.self_attn.k_proj.weight": "model-00022-of-00032.safetensors",
"model.layers.31.self_attn.o_proj.weight": "model-00022-of-00032.safetensors",
"model.layers.31.self_attn.q_proj.weight": "model-00022-of-00032.safetensors",
"model.layers.31.self_attn.v_proj.weight": "model-00022-of-00032.safetensors",
"model.layers.32.input_layernorm.weight": "model-00022-of-00032.safetensors",
"model.layers.32.mlp.down_proj.weight": "model-00022-of-00032.safetensors",
"model.layers.32.mlp.gate_proj.weight": "model-00022-of-00032.safetensors",
"model.layers.32.mlp.up_proj.weight": "model-00022-of-00032.safetensors",
"model.layers.32.post_attention_layernorm.weight": "model-00022-of-00032.safetensors",
"model.layers.32.self_attn.k_proj.weight": "model-00022-of-00032.safetensors",
"model.layers.32.self_attn.o_proj.weight": "model-00022-of-00032.safetensors",
"model.layers.32.self_attn.q_proj.weight": "model-00022-of-00032.safetensors",
"model.layers.32.self_attn.v_proj.weight": "model-00022-of-00032.safetensors",
"model.layers.33.input_layernorm.weight": "model-00022-of-00032.safetensors",
"model.layers.33.mlp.down_proj.weight": "model-00023-of-00032.safetensors",
"model.layers.33.mlp.gate_proj.weight": "model-00023-of-00032.safetensors",
"model.layers.33.mlp.up_proj.weight": "model-00023-of-00032.safetensors",
"model.layers.33.post_attention_layernorm.weight": "model-00023-of-00032.safetensors",
"model.layers.33.self_attn.k_proj.weight": "model-00023-of-00032.safetensors",
"model.layers.33.self_attn.o_proj.weight": "model-00023-of-00032.safetensors",
"model.layers.33.self_attn.q_proj.weight": "model-00023-of-00032.safetensors",
"model.layers.33.self_attn.v_proj.weight": "model-00023-of-00032.safetensors",
"model.layers.34.input_layernorm.weight": "model-00023-of-00032.safetensors",
"model.layers.34.mlp.down_proj.weight": "model-00023-of-00032.safetensors",
"model.layers.34.mlp.gate_proj.weight": "model-00024-of-00032.safetensors",
"model.layers.34.mlp.up_proj.weight": "model-00024-of-00032.safetensors",
"model.layers.34.post_attention_layernorm.weight": "model-00024-of-00032.safetensors",
"model.layers.34.self_attn.k_proj.weight": "model-00024-of-00032.safetensors",
"model.layers.34.self_attn.o_proj.weight": "model-00024-of-00032.safetensors",
"model.layers.34.self_attn.q_proj.weight": "model-00024-of-00032.safetensors",
"model.layers.34.self_attn.v_proj.weight": "model-00024-of-00032.safetensors",
"model.layers.35.input_layernorm.weight": "model-00024-of-00032.safetensors",
"model.layers.35.mlp.down_proj.weight": "model-00024-of-00032.safetensors",
"model.layers.35.mlp.gate_proj.weight": "model-00024-of-00032.safetensors",
"model.layers.35.mlp.up_proj.weight": "model-00025-of-00032.safetensors",
"model.layers.35.post_attention_layernorm.weight": "model-00025-of-00032.safetensors",
"model.layers.35.self_attn.k_proj.weight": "model-00025-of-00032.safetensors",
"model.layers.35.self_attn.o_proj.weight": "model-00025-of-00032.safetensors",
"model.layers.35.self_attn.q_proj.weight": "model-00025-of-00032.safetensors",
"model.layers.35.self_attn.v_proj.weight": "model-00025-of-00032.safetensors",
"model.layers.36.input_layernorm.weight": "model-00025-of-00032.safetensors",
"model.layers.36.mlp.down_proj.weight": "model-00025-of-00032.safetensors",
"model.layers.36.mlp.gate_proj.weight": "model-00025-of-00032.safetensors",
"model.layers.36.mlp.up_proj.weight": "model-00025-of-00032.safetensors",
"model.layers.36.post_attention_layernorm.weight": "model-00025-of-00032.safetensors",
"model.layers.36.self_attn.k_proj.weight": "model-00025-of-00032.safetensors",
"model.layers.36.self_attn.o_proj.weight": "model-00025-of-00032.safetensors",
"model.layers.36.self_attn.q_proj.weight": "model-00025-of-00032.safetensors",
"model.layers.36.self_attn.v_proj.weight": "model-00025-of-00032.safetensors",
"model.layers.37.input_layernorm.weight": "model-00025-of-00032.safetensors",
"model.layers.37.mlp.down_proj.weight": "model-00026-of-00032.safetensors",
"model.layers.37.mlp.gate_proj.weight": "model-00026-of-00032.safetensors",
"model.layers.37.mlp.up_proj.weight": "model-00026-of-00032.safetensors",
"model.layers.37.post_attention_layernorm.weight": "model-00026-of-00032.safetensors",
"model.layers.37.self_attn.k_proj.weight": "model-00026-of-00032.safetensors",
"model.layers.37.self_attn.o_proj.weight": "model-00026-of-00032.safetensors",
"model.layers.37.self_attn.q_proj.weight": "model-00026-of-00032.safetensors",
"model.layers.37.self_attn.v_proj.weight": "model-00026-of-00032.safetensors",
"model.layers.38.input_layernorm.weight": "model-00026-of-00032.safetensors",
"model.layers.38.mlp.down_proj.weight": "model-00026-of-00032.safetensors",
"model.layers.38.mlp.gate_proj.weight": "model-00027-of-00032.safetensors",
"model.layers.38.mlp.up_proj.weight": "model-00027-of-00032.safetensors",
"model.layers.38.post_attention_layernorm.weight": "model-00027-of-00032.safetensors",
"model.layers.38.self_attn.k_proj.weight": "model-00027-of-00032.safetensors",
"model.layers.38.self_attn.o_proj.weight": "model-00027-of-00032.safetensors",
"model.layers.38.self_attn.q_proj.weight": "model-00027-of-00032.safetensors",
"model.layers.38.self_attn.v_proj.weight": "model-00027-of-00032.safetensors",
"model.layers.39.input_layernorm.weight": "model-00027-of-00032.safetensors",
"model.layers.39.mlp.down_proj.weight": "model-00027-of-00032.safetensors",
"model.layers.39.mlp.gate_proj.weight": "model-00027-of-00032.safetensors",
"model.layers.39.mlp.up_proj.weight": "model-00028-of-00032.safetensors",
"model.layers.39.post_attention_layernorm.weight": "model-00028-of-00032.safetensors",
"model.layers.39.self_attn.k_proj.weight": "model-00028-of-00032.safetensors",
"model.layers.39.self_attn.o_proj.weight": "model-00028-of-00032.safetensors",
"model.layers.39.self_attn.q_proj.weight": "model-00028-of-00032.safetensors",
"model.layers.39.self_attn.v_proj.weight": "model-00028-of-00032.safetensors",
"model.layers.4.input_layernorm.weight": "model-00028-of-00032.safetensors",
"model.layers.4.mlp.down_proj.weight": "model-00028-of-00032.safetensors",
"model.layers.4.mlp.gate_proj.weight": "model-00028-of-00032.safetensors",
"model.layers.4.mlp.up_proj.weight": "model-00028-of-00032.safetensors",
"model.layers.4.post_attention_layernorm.weight": "model-00028-of-00032.safetensors",
"model.layers.4.self_attn.k_proj.weight": "model-00028-of-00032.safetensors",
"model.layers.4.self_attn.o_proj.weight": "model-00028-of-00032.safetensors",
"model.layers.4.self_attn.q_proj.weight": "model-00028-of-00032.safetensors",
"model.layers.4.self_attn.v_proj.weight": "model-00028-of-00032.safetensors",
"model.layers.5.input_layernorm.weight": "model-00028-of-00032.safetensors",
"model.layers.5.mlp.down_proj.weight": "model-00029-of-00032.safetensors",
"model.layers.5.mlp.gate_proj.weight": "model-00029-of-00032.safetensors",
"model.layers.5.mlp.up_proj.weight": "model-00029-of-00032.safetensors",
"model.layers.5.post_attention_layernorm.weight": "model-00029-of-00032.safetensors",
"model.layers.5.self_attn.k_proj.weight": "model-00029-of-00032.safetensors",
"model.layers.5.self_attn.o_proj.weight": "model-00029-of-00032.safetensors",
"model.layers.5.self_attn.q_proj.weight": "model-00029-of-00032.safetensors",
"model.layers.5.self_attn.v_proj.weight": "model-00029-of-00032.safetensors",
"model.layers.6.input_layernorm.weight": "model-00029-of-00032.safetensors",
"model.layers.6.mlp.down_proj.weight": "model-00029-of-00032.safetensors",
"model.layers.6.mlp.gate_proj.weight": "model-00030-of-00032.safetensors",
"model.layers.6.mlp.up_proj.weight": "model-00030-of-00032.safetensors",
"model.layers.6.post_attention_layernorm.weight": "model-00030-of-00032.safetensors",
"model.layers.6.self_attn.k_proj.weight": "model-00030-of-00032.safetensors",
"model.layers.6.self_attn.o_proj.weight": "model-00030-of-00032.safetensors",
"model.layers.6.self_attn.q_proj.weight": "model-00030-of-00032.safetensors",
"model.layers.6.self_attn.v_proj.weight": "model-00030-of-00032.safetensors",
"model.layers.7.input_layernorm.weight": "model-00030-of-00032.safetensors",
"model.layers.7.mlp.down_proj.weight": "model-00030-of-00032.safetensors",
"model.layers.7.mlp.gate_proj.weight": "model-00030-of-00032.safetensors",
"model.layers.7.mlp.up_proj.weight": "model-00031-of-00032.safetensors",
"model.layers.7.post_attention_layernorm.weight": "model-00031-of-00032.safetensors",
"model.layers.7.self_attn.k_proj.weight": "model-00031-of-00032.safetensors",
"model.layers.7.self_attn.o_proj.weight": "model-00031-of-00032.safetensors",
"model.layers.7.self_attn.q_proj.weight": "model-00031-of-00032.safetensors",
"model.layers.7.self_attn.v_proj.weight": "model-00031-of-00032.safetensors",
"model.layers.8.input_layernorm.weight": "model-00031-of-00032.safetensors",
"model.layers.8.mlp.down_proj.weight": "model-00031-of-00032.safetensors",
"model.layers.8.mlp.gate_proj.weight": "model-00031-of-00032.safetensors",
"model.layers.8.mlp.up_proj.weight": "model-00031-of-00032.safetensors",
"model.layers.8.post_attention_layernorm.weight": "model-00031-of-00032.safetensors",
"model.layers.8.self_attn.k_proj.weight": "model-00031-of-00032.safetensors",
"model.layers.8.self_attn.o_proj.weight": "model-00031-of-00032.safetensors",
"model.layers.8.self_attn.q_proj.weight": "model-00031-of-00032.safetensors",
"model.layers.8.self_attn.v_proj.weight": "model-00031-of-00032.safetensors",
"model.layers.9.input_layernorm.weight": "model-00031-of-00032.safetensors",
"model.layers.9.mlp.down_proj.weight": "model-00032-of-00032.safetensors",
"model.layers.9.mlp.gate_proj.weight": "model-00032-of-00032.safetensors",
"model.layers.9.mlp.up_proj.weight": "model-00032-of-00032.safetensors",
"model.layers.9.post_attention_layernorm.weight": "model-00032-of-00032.safetensors",
"model.layers.9.self_attn.k_proj.weight": "model-00032-of-00032.safetensors",
"model.layers.9.self_attn.o_proj.weight": "model-00032-of-00032.safetensors",
"model.layers.9.self_attn.q_proj.weight": "model-00032-of-00032.safetensors",
"model.layers.9.self_attn.v_proj.weight": "model-00032-of-00032.safetensors",
"model.norm.weight": "model-00032-of-00032.safetensors"
}
}

13
params.json Normal file
View File

@@ -0,0 +1,13 @@
{
"dim": 5120,
"n_layers": 40,
"head_dim": 128,
"hidden_dim": 32768,
"n_heads": 32,
"n_kv_heads": 8,
"norm_eps": 1e-05,
"vocab_size": 131072,
"rope_theta": 100000000.0,
"max_seq_len": 32768,
"max_position_embeddings": 32768
}

7007
special_tokens_map.json Normal file

File diff suppressed because it is too large Load Diff

162
story_stage_generation.py Normal file
View File

@@ -0,0 +1,162 @@
"""Minimal staged-generation helpers for the exported 24b story model."""
from __future__ import annotations
import re
from typing import Any
from jinja2 import Environment
EOT_TOKEN = "<|eot_id|>"
START_HEADER_TOKEN = "<|start_header_id|>"
STOP_HEADER_TOKEN = "<|stop_header_id|>"
PROFILE_NAME = "24b"
CHAT_TEMPLATE = "{% for message in messages %}{% set role = message['role'] %}{% set content = message['content'] | default('', true) %}{% if role == 'prompt' %}<|start_header_id|>prompt<|stop_header_id|>\n\n{% elif role == 'book_preview' %}<|start_header_id|>book_preview<|stop_header_id|>\n\n{% elif role == 'book_plan' %}<|start_header_id|>book_plan<|stop_header_id|>\n\n{% elif role == 'first_chapter_plan' %}<|start_header_id|>first_chapter_plan<|stop_header_id|>\n\n{% elif role == 'first_chapter_scene_breakdown' %}<|start_header_id|>first_chapter_scene_breakdown<|stop_header_id|>\n\n{% elif role == 'first_chapter_text' %}<|start_header_id|>first_chapter_text<|stop_header_id|>\n\n{% elif role == 'full_book_chapters_plan' %}<|start_header_id|>full_book_chapters_plan<|stop_header_id|>\n\n{% elif role == 'book_characters_list' %}<|start_header_id|>book_characters_list<|stop_header_id|>\n\n{% elif role == 'scene_breakdown' %}<|start_header_id|>scene_breakdown<|stop_header_id|>\n\n{% elif role == 'chapter_text' %}<|start_header_id|>chapter_text<|stop_header_id|>\n\n{% else %}<|start_header_id|>{{ role }}<|stop_header_id|>\n\n{% endif %}{{ content }}{% if not loop.last or content %}<|eot_id|>{% endif %}{% endfor %}"
DEFAULT_STAGE_SEQUENCE = ('book_preview', 'book_plan', 'first_chapter_plan', 'first_chapter_scene_breakdown', 'first_chapter_text')
STAGE_ROLES = ('prompt', 'book_preview', 'book_plan', 'first_chapter_plan', 'first_chapter_scene_breakdown', 'first_chapter_text')
def stage_header(role: str) -> str:
if role not in STAGE_ROLES:
raise ValueError(f"Unsupported story stage role: {role}")
return f"{START_HEADER_TOKEN}{role}{STOP_HEADER_TOKEN}"
BOOK_PREVIEW_REGEX = '^## Book Highlight\\n(?:\\S+\\s+){0,149}\\S+\\n\\n## Book Title\\n(?:[^\\s\\n]+\\s+){0,7}[^\\s\\n]+\\n\\n## Book Tags\\n(?:- [^\\r\\n]{1,75}\\n){7}## Book Archetype\\n(?:\\S+\\s+){0,199}\\S+\\n?$'
BOOK_PLAN_REGEX = '^## World Rules\\n(?:- [^\\n]{1,300}\\n){1,90}\\n## Story Arcs\\n(?:### Arc [1-9][0-9]*: [^\\n]{1,120}\\n(?:- [^\\n]{1,300}\\n){1,20}\\n?){1,12}## Character Archetypes\\n(?:### [^\\n]{1,120}\\n(?:- [^\\n]{1,300}\\n){1,10}\\n?){1,32}## Writing Style\\n(?:- [^\\n]{1,300}\\n){0,39}- [^\\n]{1,300}\\n?$'
FIRST_CHAPTER_PLAN_REGEX = '^(?:### [^\\n]{1,120}\\n\\*\\*Word Count:\\*\\* [0-9]{2,5}\\n\\*\\*Embedding Space:\\*\\* erotic: [0-9]{1,2}, action: [0-9]{1,2}, world_building: [0-9]{1,2}, exposition: [0-9]{1,2}, dialog: [0-9]{1,2}, romantic: [0-9]{1,2}, pacing: [0-9]{1,2}\\n\\*\\*Narrative Focuses:\\*\\* \\S(?:[^\\n;]{0,63}\\S)?(?:; \\S(?:[^\\n;]{0,63}\\S)?){0,6}\\n\\*\\*Chapter Summary:\\*\\*\\n(?:- [^\\n]{1,300}\\n){0,31}- [^\\n]{1,300}\\n?\\n?){1,2}$'
FULL_BOOK_CHAPTERS_PLAN_REGEX = '^(?:### [^\\n]{1,120}\\n\\*\\*Word Count:\\*\\* [0-9]{2,5}\\n\\*\\*Embedding Space:\\*\\* erotic: [0-9]{1,2}, action: [0-9]{1,2}, world_building: [0-9]{1,2}, exposition: [0-9]{1,2}, dialog: [0-9]{1,2}, romantic: [0-9]{1,2}, pacing: [0-9]{1,2}\\n\\*\\*Narrative Focuses:\\*\\* \\S(?:[^\\n;]{0,63}\\S)?(?:; \\S(?:[^\\n;]{0,63}\\S)?){0,6}\\n\\*\\*Chapter Summary:\\*\\*\\n(?:- [^\\n]{1,300}\\n){0,79}- [^\\n]{1,300}\\n?\\n?){1,24}$'
SCENE_BREAKDOWN_REGEX = '^### [^\\n]{1,120}\\n(?:#### Scene (?:[1-9]|1[0-2]): [^\\n]{1,120}\\n\\*\\*Word Count:\\*\\* [0-9]{2,5}\\n\\*\\*Embedding Space:\\*\\* action: [0-9]{1,2}, dialog: [0-9]{1,2}, world_building: [0-9]{1,2}, exposition: [0-9]{1,2}, romantic: [0-9]{1,2}, erotic: [0-9]{1,2}, pacing: [0-9]{1,2}\\n\\*\\*Narrative Focus:\\*\\* \\S(?:[^\\n;]{0,63}\\S)?(?:; \\S(?:[^\\n;]{0,63}\\S)?){0,6}\\n\\*\\*Narrative Perspective:\\*\\* [^\\n]{1,200}\\n\\*\\*Scene Summary:\\*\\*\\n(?:- [^\\n]{1,300}\\n){0,19}- [^\\n]{1,300}\\n?\\n?){1,12}$'
BOOK_CHARACTERS_LIST_REGEX = '^### Main Characters\\n(?:#### [^\\n]{1,120}\\n(?:- [^\\n]{1,300}\\n){0,19}- [^\\n]{1,300}\\n?\\n?){1,20}### Side Characters\\n(?:#### [^\\n]{1,120}\\n(?:- [^\\n]{1,300}\\n){0,19}- [^\\n]{1,300}\\n?\\n?){1,20}$'
def _book_plan_section(text: str, section_name: str) -> str:
section_match = re.search(
rf"(?ms)^## {re.escape(section_name)}\n(?P<body>.*?)(?=^## |\Z)",
text,
)
if section_match is None:
raise ValueError(f"Missing book_plan section: {section_name}")
return section_match.group("body").strip()
def extract_preloaded_chapters_info(book_plan_text: str) -> list[dict[str, str | int]]:
chapter_names_section = _book_plan_section(book_plan_text, "Chapter Names")
embedding_section = _book_plan_section(book_plan_text, "Chapters Embedding Space")
word_count_section = _book_plan_section(book_plan_text, "Chapters Word Count")
chapter_names = [
chapter_name_match.group(1).strip()
for chapter_name_match in re.finditer(r"(?m)^- (.+?)\s*$", chapter_names_section)
]
if not chapter_names:
raise ValueError("Could not extract preloaded chapter names from the 14b book_plan stage.")
if len(set(chapter_names)) != len(chapter_names):
raise ValueError("Duplicate chapter names are not supported in the 14b book_plan preload.")
chapter_embedding_space_by_name: dict[str, str] = {}
for embedding_match in re.finditer(r"(?ms)^#### (.+?)\s*$\n([^\n]+)", embedding_section):
chapter_name = embedding_match.group(1).strip()
if chapter_name in chapter_embedding_space_by_name:
raise ValueError(f"Duplicate embedding-space preload for chapter {chapter_name!r}.")
chapter_embedding_space_by_name[chapter_name] = embedding_match.group(2).strip()
chapter_word_count_by_name: dict[str, int] = {}
for word_count_match in re.finditer(r"(?ms)^#### (.+?)\s*$\n([0-9]{2,5})", word_count_section):
chapter_name = word_count_match.group(1).strip()
if chapter_name in chapter_word_count_by_name:
raise ValueError(f"Duplicate word-count preload for chapter {chapter_name!r}.")
chapter_word_count_by_name[chapter_name] = int(word_count_match.group(2))
chapters_info: list[dict[str, str | int]] = []
for chapter_name in chapter_names:
if chapter_name not in chapter_embedding_space_by_name:
raise ValueError(f"Missing embedding-space preload for chapter {chapter_name!r}.")
if chapter_name not in chapter_word_count_by_name:
raise ValueError(f"Missing word-count preload for chapter {chapter_name!r}.")
chapters_info.append(
{
"chapter_name": chapter_name,
"chapter_word_count": chapter_word_count_by_name[chapter_name],
"chapter_embedding_space": chapter_embedding_space_by_name[chapter_name],
}
)
return chapters_info
def build_full_book_chapters_plan_regex_from_book_plan(book_plan_text: str) -> str:
chapters_info = extract_preloaded_chapters_info(book_plan_text)
if len(chapters_info) < 2:
raise ValueError("14b book_plan must preload the first chapter and at least one later chapter.")
later_chapter_patterns: list[str] = []
for chapter_info in chapters_info[1:]:
later_chapter_patterns.append(
r"### "
+ re.escape(str(chapter_info["chapter_name"]))
+ r"\n"
r"\*\*Word Count:\*\* "
+ re.escape(str(chapter_info["chapter_word_count"]))
+ r"\n"
r"\*\*Embedding Space:\*\* "
+ re.escape(str(chapter_info["chapter_embedding_space"]))
+ r"\n"
r"\*\*Narrative Focuses:\*\* "
+ '\\S(?:[^\\n;]{0,63}\\S)?(?:; \\S(?:[^\\n;]{0,63}\\S)?){0,6}'
+ r"\n"
r"\*\*Chapter Summary:\*\*\n"
+ '(?:- [^\\n]{1,300}\\n){0,79}- [^\\n]{1,300}\\n?'
)
return r"^" + r"\n\n".join(later_chapter_patterns) + r"$"
STAGE_STRUCTURED_OUTPUTS = {
"book_preview": {"regex": BOOK_PREVIEW_REGEX},
"book_plan": {"regex": BOOK_PLAN_REGEX},
"first_chapter_plan": {"regex": FIRST_CHAPTER_PLAN_REGEX},
"first_chapter_scene_breakdown": {"regex": SCENE_BREAKDOWN_REGEX},
}
def stage_structured_outputs(role: str) -> dict[str, Any] | None:
structured_outputs = STAGE_STRUCTURED_OUTPUTS.get(role)
if structured_outputs is None:
return None
return dict(structured_outputs)
def build_stage_messages(
prompt: str,
completed_stages: list[tuple[str, str]] | None,
next_stage_role: str,
) -> list[dict[str, str]]:
if next_stage_role == "prompt":
raise ValueError("prompt cannot be used as a generation stage")
if next_stage_role not in STAGE_ROLES:
raise ValueError(f"Unsupported story stage role: {next_stage_role}")
messages = [{"role": "prompt", "content": prompt}]
for role, content in completed_stages or []:
if role == "prompt":
raise ValueError("completed_stages must not include prompt")
if role not in STAGE_ROLES:
raise ValueError(f"Unsupported completed stage role: {role}")
messages.append({"role": role, "content": content})
messages.append({"role": next_stage_role, "content": ""})
return messages
def render_stage_prompt(
tokenizer: Any,
prompt: str,
completed_stages: list[tuple[str, str]] | None,
next_stage_role: str,
) -> str:
messages = build_stage_messages(prompt, completed_stages, next_stage_role)
rendered = Environment().from_string(CHAT_TEMPLATE).render(messages=messages)
if not isinstance(rendered, str):
raise TypeError("Stage chat template rendering must return a string")
return rendered
def trim_generated_stage_text(text: str, generated_stage_role: str) -> str:
del generated_stage_role
return text.split(EOT_TOKEN, 1)[0].rstrip()

3
tekken.json Normal file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:c4b90a968dbc67ef3975129d0b78a2e3cbb6bea340ab9205f22e8a0308b1ffc5
size 14801223

3
tokenizer.json Normal file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:57b42b226e2726c538edc62e5687ac5cb7518c7d880c6b8b590217c99574147c
size 29906843

9020
tokenizer_config.json Normal file

File diff suppressed because it is too large Load Diff