Publish subtitle postprocessor v12
Browse filesFiles changed (2)
- README.md+16-135
- model.safetensors+1-1
123456784101112131415567891018111220131422151624252627281718301920213222233424253637383940262728293042434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149---license: apache-2.0base_model: HuggingFaceTB/SmolLM2-135M-Instructlibrary_name: transformerspipeline_tag: text-generationlanguage:- zh- entags:- safetensors- llama- transformers- code-tape- subtitle-correction- chapter-generation - code-tape - subtitle - merged - text-generation---
# code-tape subtitle postprocessor merged model# code-tape Subtitle Postprocessor Merged v12
This repository contains the full merged Hugging Face model for code-tape subtitle post-processing. It was produced by applying the project LoRA adapter to `HuggingFaceTB/SmolLM2-135M-Instruct`.Merged full model for the code-tape subtitle postprocessor. This model combines SmolLM2-135M-Instruct with the v12 LoRA adapter.
The model is specialized for a narrow post-ASR task:## Task
- fix frontend/code terminology in subtitle text;- keep code identifiers, package names, function names, and component names stable;- return only changed subtitle segments as a sparse `segments` array;- create timestamped playback chapters;- output one strict JSON object.Given subtitle text plus code-tape context, output strict JSON for:
This model is not an audio transcription model. It should receive subtitle segments that already have ids, start/end timestamps, and ASR text.- sparse subtitle corrections for frontend/code terminology- playback chapter jump points
## Repository roleThe prompt separates `inputSegments` (`id`, `text`) from `timeline` (`id`, `startMs`, `endMs`) to reduce schema-copy failures such as segment outputs containing timing fields.
code-tape publishes the same model family in three forms:## Validation Snapshot
| Repository | Purpose || --- | --- || [`ceilf6/code-tape-subtitle-postprocessor-lora`](https://huggingface.co/ceilf6/code-tape-subtitle-postprocessor-lora) | LoRA adapter for reproducibility and continued fine-tuning. || [`ceilf6/code-tape-subtitle-postprocessor-merged`](https://huggingface.co/ceilf6/code-tape-subtitle-postprocessor-merged) | This full merged model, useful for Python/Transformers inspection or re-export. || [`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. |- 12-sample PyTorch generation probe: 12/12 valid JSON- Unknown segment references: 0- Extra timing fields inside `segments`: 0- Average generation time in local PyTorch probe: 2.58s
For browser-local inference in code-tape, use the ONNX repository. Use this repository when you need a standard Transformers checkpoint.
## Intended contract
Input is a chat message containing JSON:
```json{ "context": { "fileName": "ReplayControls.tsx", "code": "const canSeek = durationMs > 0;", "runtimeOutput": "", "glossary": ["ReplayControls", "canSeek", "durationMs"] }, "segments": [ { "id": "subtitle-1", "startMs": 0, "endMs": 1400, "text": "这里先判断 can seek 是否可用" } ]}```
Expected output shape:
```json{ "segments": [ { "id": "subtitle-1", "text": "这里先判断 canSeek 是否可用" } ], "chapters": [ { "title": "判断回放是否可 seek", "startMs": 0, "endMs": 1400 } ]}```
Rules expected by the code-tape application:
- output JSON only, with no Markdown or explanation;- `segments` contains only changed segments and may be empty;- every returned segment id must exist in the input and must not be duplicated;- chapter times must be monotonic, non-overlapping, and inside the subtitle timeline;- invalid output is discarded by the application.
## Usage with Transformers
```pythonfrom transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "ceilf6/code-tape-subtitle-postprocessor-merged"tokenizer = AutoTokenizer.from_pretrained(model_id)model = AutoModelForCausalLM.from_pretrained(model_id)
messages = [ { "role": "system", "content": ( "You are the code-tape subtitle post-processing model.\n" "Only output one JSON object.\n" "Goal: correct ASR subtitle text for frontend/code terms and create playback chapter jump points." ), }, {"role": "user", "content": "{\"context\":{},\"segments\":[]}"},]
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)inputs = tokenizer(prompt, return_tensors="pt")outputs = model.generate(**inputs, max_new_tokens=384, do_sample=False)print(tokenizer.decode(outputs[0], skip_special_tokens=True))```
## Training and conversion
The model was created from the code-tape subtitle post-processing LoRA workflow:
1. prepare seed records with ASR-like subtitles, code context, runtime output, and glossary terms;2. distill strict JSON correction/chapter examples;3. fine-tune a LoRA adapter on `HuggingFaceTB/SmolLM2-135M-Instruct`;4. merge the adapter into a full model;5. export the merged model to ONNX for browser use.
The merged checkpoint is mainly an intermediate artifact for reproducibility and export.
## Evaluation
code-tape evaluates this model family with project-specific checks instead of broad language-model benchmarks:
- valid JSON object output;- valid sparse segment references;- glossary preservation after sparse corrections are applied back to the source subtitles;- non-empty, ordered, non-overlapping chapter supervision for training/evaluation records;- chapter bounds inside the subtitle timeline.
The model output must always be validated by the caller.
## Limitations
- Narrowly trained for code-tape subtitle correction and chapter generation.- Not suitable as a general chat assistant or general summarizer.- Not an ASR model and cannot process audio directly.- Small local models may produce malformed JSON; callers must keep a fallback path.
## Privacy and security
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.
Do not put secrets, credentials, private code, or access tokens in prompts unless your inference environment is trusted.
## License
Apache-2.0, following the base model license.1223version https://git-lfs.github.com/spec/v1oid sha256:ead0d2269ae7da4e28260b7fc730d5b1bca038a3c54a81055f058e33264c88e9oid sha256:aa07ac774e59fb9f571f92a46d8bc788870b8ad3561ec5721c7f67f529175245size 538090408README.md+16-135
model.safetensors+1-1