Publish subtitle postprocessor v12
Browse filesFiles changed (2)
- README.md+16-135
- model.safetensors+1-1
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149---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 postprocessor merged modelThis 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`.The model is specialized for a narrow post-ASR 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.This model is not an audio transcription model. It should receive subtitle segments that already have ids, start/end timestamps, and ASR text.## Repository rolecode-tape publishes the same model family in three forms:| 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. |For browser-local inference in code-tape, use the ONNX repository. Use this repository when you need a standard Transformers checkpoint.## Intended contractInput 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, AutoTokenizermodel_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 conversionThe 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.## Evaluationcode-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 securityThe 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.## LicenseApache-2.0, following the base model license.123456789101112131415161718192021222324252627282930---license: apache-2.0base_model: HuggingFaceTB/SmolLM2-135M-Instructtags:- code-tape- subtitle- merged- text-generation---# code-tape Subtitle Postprocessor Merged v12Merged full model for the code-tape subtitle postprocessor. This model combines SmolLM2-135M-Instruct with the v12 LoRA adapter.## TaskGiven subtitle text plus code-tape context, output strict JSON for:- sparse subtitle corrections for frontend/code terminology- playback chapter jump pointsThe prompt separates `inputSegments` (`id`, `text`) from `timeline` (`id`, `startMs`, `endMs`) to reduce schema-copy failures such as segment outputs containing timing fields.## Validation Snapshot- 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
123version https://git-lfs.github.com/spec/v1oid sha256:ead0d2269ae7da4e28260b7fc730d5b1bca038a3c54a81055f058e33264c88e9size 538090408123version https://git-lfs.github.com/spec/v1oid sha256:aa07ac774e59fb9f571f92a46d8bc788870b8ad3561ec5721c7f67f529175245size 538090408
README.md+16-135
model.safetensors+1-1