Publish subtitle postprocessor v12
Browse files- README.md +16 -135
- model.safetensors +1 -1
README.md
CHANGED
|
@@ -1,149 +1,30 @@
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
| 3 |
base_model: HuggingFaceTB/SmolLM2-135M-Instruct
|
| 4 |
-
library_name: transformers
|
| 5 |
-
pipeline_tag: text-generation
|
| 6 |
-
language:
|
| 7 |
-
- zh
|
| 8 |
-
- en
|
| 9 |
tags:
|
| 10 |
-
-
|
| 11 |
-
-
|
| 12 |
-
-
|
| 13 |
-
-
|
| 14 |
-
- subtitle-correction
|
| 15 |
-
- chapter-generation
|
| 16 |
---
|
| 17 |
|
| 18 |
-
# code-tape
|
| 19 |
|
| 20 |
-
|
| 21 |
|
| 22 |
-
|
| 23 |
|
| 24 |
-
|
| 25 |
-
- keep code identifiers, package names, function names, and component names stable;
|
| 26 |
-
- return only changed subtitle segments as a sparse `segments` array;
|
| 27 |
-
- create timestamped playback chapters;
|
| 28 |
-
- output one strict JSON object.
|
| 29 |
|
| 30 |
-
|
|
|
|
| 31 |
|
| 32 |
-
|
| 33 |
|
| 34 |
-
|
| 35 |
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
| [`ceilf6/code-tape-subtitle-postprocessor-onnx`](https://huggingface.co/ceilf6/code-tape-subtitle-postprocessor-onnx) | Transformers.js-compatible ONNX export used by the browser app. |
|
| 41 |
|
| 42 |
-
For browser-local inference in code-tape, use the ONNX repository. Use this repository when you need a standard Transformers checkpoint.
|
| 43 |
-
|
| 44 |
-
## Intended contract
|
| 45 |
-
|
| 46 |
-
Input is a chat message containing JSON:
|
| 47 |
-
|
| 48 |
-
```json
|
| 49 |
-
{
|
| 50 |
-
"context": {
|
| 51 |
-
"fileName": "ReplayControls.tsx",
|
| 52 |
-
"code": "const canSeek = durationMs > 0;",
|
| 53 |
-
"runtimeOutput": "",
|
| 54 |
-
"glossary": ["ReplayControls", "canSeek", "durationMs"]
|
| 55 |
-
},
|
| 56 |
-
"segments": [
|
| 57 |
-
{ "id": "subtitle-1", "startMs": 0, "endMs": 1400, "text": "这里先判断 can seek 是否可用" }
|
| 58 |
-
]
|
| 59 |
-
}
|
| 60 |
-
```
|
| 61 |
-
|
| 62 |
-
Expected output shape:
|
| 63 |
-
|
| 64 |
-
```json
|
| 65 |
-
{
|
| 66 |
-
"segments": [
|
| 67 |
-
{ "id": "subtitle-1", "text": "这里先判断 canSeek 是否可用" }
|
| 68 |
-
],
|
| 69 |
-
"chapters": [
|
| 70 |
-
{ "title": "判断回放是否可 seek", "startMs": 0, "endMs": 1400 }
|
| 71 |
-
]
|
| 72 |
-
}
|
| 73 |
-
```
|
| 74 |
-
|
| 75 |
-
Rules expected by the code-tape application:
|
| 76 |
-
|
| 77 |
-
- output JSON only, with no Markdown or explanation;
|
| 78 |
-
- `segments` contains only changed segments and may be empty;
|
| 79 |
-
- every returned segment id must exist in the input and must not be duplicated;
|
| 80 |
-
- chapter times must be monotonic, non-overlapping, and inside the subtitle timeline;
|
| 81 |
-
- invalid output is discarded by the application.
|
| 82 |
-
|
| 83 |
-
## Usage with Transformers
|
| 84 |
-
|
| 85 |
-
```python
|
| 86 |
-
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 87 |
-
|
| 88 |
-
model_id = "ceilf6/code-tape-subtitle-postprocessor-merged"
|
| 89 |
-
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 90 |
-
model = AutoModelForCausalLM.from_pretrained(model_id)
|
| 91 |
-
|
| 92 |
-
messages = [
|
| 93 |
-
{
|
| 94 |
-
"role": "system",
|
| 95 |
-
"content": (
|
| 96 |
-
"You are the code-tape subtitle post-processing model.\n"
|
| 97 |
-
"Only output one JSON object.\n"
|
| 98 |
-
"Goal: correct ASR subtitle text for frontend/code terms and create playback chapter jump points."
|
| 99 |
-
),
|
| 100 |
-
},
|
| 101 |
-
{"role": "user", "content": "{\"context\":{},\"segments\":[]}"},
|
| 102 |
-
]
|
| 103 |
-
|
| 104 |
-
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
| 105 |
-
inputs = tokenizer(prompt, return_tensors="pt")
|
| 106 |
-
outputs = model.generate(**inputs, max_new_tokens=384, do_sample=False)
|
| 107 |
-
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
| 108 |
-
```
|
| 109 |
-
|
| 110 |
-
## Training and conversion
|
| 111 |
-
|
| 112 |
-
The model was created from the code-tape subtitle post-processing LoRA workflow:
|
| 113 |
-
|
| 114 |
-
1. prepare seed records with ASR-like subtitles, code context, runtime output, and glossary terms;
|
| 115 |
-
2. distill strict JSON correction/chapter examples;
|
| 116 |
-
3. fine-tune a LoRA adapter on `HuggingFaceTB/SmolLM2-135M-Instruct`;
|
| 117 |
-
4. merge the adapter into a full model;
|
| 118 |
-
5. export the merged model to ONNX for browser use.
|
| 119 |
-
|
| 120 |
-
The merged checkpoint is mainly an intermediate artifact for reproducibility and export.
|
| 121 |
-
|
| 122 |
-
## Evaluation
|
| 123 |
-
|
| 124 |
-
code-tape evaluates this model family with project-specific checks instead of broad language-model benchmarks:
|
| 125 |
-
|
| 126 |
-
- valid JSON object output;
|
| 127 |
-
- valid sparse segment references;
|
| 128 |
-
- glossary preservation after sparse corrections are applied back to the source subtitles;
|
| 129 |
-
- non-empty, ordered, non-overlapping chapter supervision for training/evaluation records;
|
| 130 |
-
- chapter bounds inside the subtitle timeline.
|
| 131 |
-
|
| 132 |
-
The model output must always be validated by the caller.
|
| 133 |
-
|
| 134 |
-
## Limitations
|
| 135 |
-
|
| 136 |
-
- Narrowly trained for code-tape subtitle correction and chapter generation.
|
| 137 |
-
- Not suitable as a general chat assistant or general summarizer.
|
| 138 |
-
- Not an ASR model and cannot process audio directly.
|
| 139 |
-
- Small local models may produce malformed JSON; callers must keep a fallback path.
|
| 140 |
-
|
| 141 |
-
## Privacy and security
|
| 142 |
-
|
| 143 |
-
The intended production path is the ONNX export running in the browser with `@huggingface/transformers`. Public browser loading does not require a Hugging Face token.
|
| 144 |
-
|
| 145 |
-
Do not put secrets, credentials, private code, or access tokens in prompts unless your inference environment is trusted.
|
| 146 |
-
|
| 147 |
-
## License
|
| 148 |
-
|
| 149 |
-
Apache-2.0, following the base model license.
|
|
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
| 3 |
base_model: HuggingFaceTB/SmolLM2-135M-Instruct
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
tags:
|
| 5 |
+
- code-tape
|
| 6 |
+
- subtitle
|
| 7 |
+
- merged
|
| 8 |
+
- text-generation
|
|
|
|
|
|
|
| 9 |
---
|
| 10 |
|
| 11 |
+
# code-tape Subtitle Postprocessor Merged v12
|
| 12 |
|
| 13 |
+
Merged full model for the code-tape subtitle postprocessor. This model combines SmolLM2-135M-Instruct with the v12 LoRA adapter.
|
| 14 |
|
| 15 |
+
## Task
|
| 16 |
|
| 17 |
+
Given subtitle text plus code-tape context, output strict JSON for:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
+
- sparse subtitle corrections for frontend/code terminology
|
| 20 |
+
- playback chapter jump points
|
| 21 |
|
| 22 |
+
The prompt separates `inputSegments` (`id`, `text`) from `timeline` (`id`, `startMs`, `endMs`) to reduce schema-copy failures such as segment outputs containing timing fields.
|
| 23 |
|
| 24 |
+
## Validation Snapshot
|
| 25 |
|
| 26 |
+
- 12-sample PyTorch generation probe: 12/12 valid JSON
|
| 27 |
+
- Unknown segment references: 0
|
| 28 |
+
- Extra timing fields inside `segments`: 0
|
| 29 |
+
- Average generation time in local PyTorch probe: 2.58s
|
|
|
|
| 30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
model.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 538090408
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:aa07ac774e59fb9f571f92a46d8bc788870b8ad3561ec5721c7f67f529175245
|
| 3 |
size 538090408
|