T5Gemma 2B-2B · YouTube transcript chaptering
LoRA for splitting videos into chapters
2 min readupdated
This is a LoRA (a lightweight adapter built on top of a base model) for google/t5gemma-2b-2b-ul2-it by Saltywan. It automatically structures long-form videos: you pass in a YouTube transcript split into numbered sentences, and the model outputs a strict JSON table of contents specifying the starting sentence number and title for each chapter. Built as part of the llm-video-chaptering project, this adapter became the top-performing model in its series, outperforming both the base model and the specialized segmenter MiniSeg. It is a solid fit for developers building content-processing tools and NLP researchers.
Key features
- High segmentation accuracy: Boundary F1 jumped from 0.149 on the base model to 0.500, reaching 0.679 with a two-sentence tolerance window.
- Reliable JSON output: syntax errors during generation dropped from 477 down to just 4 failures across 1,448 test videos.
- Handles long transcripts: the base context window fits up to 8,192 tokens, while longer transcripts are split into overlapping chunks and stitched back together.
- Ready-to-use tooling: the project's GitHub repository includes scripts for prompt formatting, window chunking, and strict output parsing.
What you can do
- Plug it into an English podcast or livestream processing pipeline to automatically generate timestamps from subtitles.
- Build a bot or web app that takes a YouTube lecture transcript and returns a clean, sentence-indexed table of contents.
- Use the code in the
llm-video-chapteringrepository to benchmark open models on text segmentation tasks.
Example
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
from peft import PeftModel
base = "google/t5gemma-2b-2b-ul2-it"
tok = AutoTokenizer.from_pretrained(base)
model = AutoModelForSeq2SeqLM.from_pretrained(base, torch_dtype="bfloat16", device_map="cuda")
model = PeftModel.from_pretrained(model, "Saltywan/t5gemma-2b-2b-ytseg-chaptering-lora").eval()
# Полный пайплайн с build_window_prompt и parse_window_outline доступен в репозитории автораRead more
DetailsBenchmarks (YTSeg, 1,448 videos): Boundary F1 exact 0.500 (vs. 0.149 base), Boundary F1 micro 51.99 (vs. 45.81 for MiniSeg), Title BERTScore 0.651.
Hardware and speed: inference on windows up to 8k tokens takes about 13 GiB of VRAM in bf16; training took 29 minutes on a single NVIDIA B200.
Training details: LoRA rank 16, alpha 32, dropout 0.05 across encoder, decoder, and cross-attention projections (adapter size is 73 MB).
Limitations: English only, text-only analysis with no audio or video input; licensed for non-commercial research only (CC BY-NC-SA 4.0).










Comments