Skip to content

feat: add opt-in source-linked transcript overview experiment - #179

Draft
devhims wants to merge 1 commit into
feat/compact-transcript-citationsfrom
feat/experimental-transcript-overview
Draft

devhims wants to merge 1 commit into
feat/compact-transcript-citationsfrom
feat/experimental-transcript-overview

Conversation

@devhims

@devhims devhims commented Oct 10, 2026 •

Copy link
Copy Markdown
Owner

Problem / Motivation

Whole-video summaries need both broad coverage and citations that land where each explanation begins. The React tutorial experiments showed that choosing a few relevant passages from a hierarchy could lose later lessons or point to an earlier, related exercise.

This PR adds an opt-in local implementation of the source-linked overview approach developed from those experiments. It depends on #178 and targets that branch. The application controls passage selection, coverage slots and citation validation. Fireworks generates the summaries and answers.

How the experiments led to this design

We started with RAPTOR-style recursive clustering and summarization. The React transcript produced 132 source passages, 25 semantic summaries and five top-level groups. The tree retained the source material, but selecting top-ranked nodes and representative source passages did not preserve every topic needed for an overview.

The final Alert exercise illustrates the problem. Its introduction is at segment 1996, about 1:14:21. A semantic group combined earlier Alert work, the Button exercise and the later Alert solution. Retrieval could supply the Button introduction or the solution around 1:16:28 while omitting the actual Alert introduction. The model could therefore return a valid caption ID that started at the wrong explanation.

Giving each group a representative passage and strengthening the prompt still left gaps. Another problem appeared even with the full transcript: some answers filled the twenty-block response limit with early lessons and stopped before the ending. A single capped outline could repeat that behavior. The application therefore needs to allocate coverage before answer generation, rather than relying entirely on relevance ranking or a prompt.

The resulting design separates three jobs: preserving source coverage, reducing it into a bounded whole-video outline, and resolving individual citation anchors. RAPTOR's retrieval implementation informed the initial experiment. GraphRAG global search provided a precedent for a separate whole-dataset synthesis path. This PR implements our transcript-specific adaptation, without embeddings or the UMAP/GMM clustering layer. The experiments did not establish that semantic clustering improved this overview path.

What changed

Added platform/scripts/experimental-overview/index.ts for construction, validation, retrieval and citation resolution, and cli.ts for explicit local execution through npm run experiment:overview.

Index construction

  1. Keep original caption identities. Read a saved normalized transcript and hash its video ID, caption order, text and timestamps. Original array positions remain segment IDs. Empty and oversized captions are recorded as omissions and break passages.
  2. Create small source passages. Preserve whole captions, preferring sentence boundaries after 100 cl100k_base tokens and otherwise closing a passage once it reaches 160 tokens. A caption is never split merely to meet that target. The React fixture produces 132 passages.
  3. Build one source-linked card per passage. Generate batches of twelve cards. Each contains a title, summary, starting segment ID and anchor quote. Up to eight preceding captions help locate the local introduction. The application checks the anchor's permitted neighborhood and quote against original text. It accepts whitespace normalization and exact consecutive source text, without fuzzy matching, and stores the canonical starting caption.
  4. Correct only rejected cards. Whole-batch repair repeated an invalid anchor during the live implementation test. The final code retains accepted cards and gives only rejected passages to one correction call. A second source-validation failure stops construction.
  5. Reserve overview space across the video. Divide the ordered cards into at most six chronological portions. Generate three lessons per portion, or fewer for a short portion, with a maximum of eighteen lessons. Each lesson must select an anchor from its own portion. These portions allocate coverage; they are not semantic clusters. Neither the user's question nor expected topic names are supplied during construction.

Retrieval and answers

Overview mode supplies all outline lessons plus up to ten original captions beginning at each anchor, deduplicated. The React run supplied eighteen lessons and 180 captions. Model-facing summary cards expose their citable anchor without source-range boundaries, avoiding the earlier prototype's confusion between a range boundary and a citation ID.

The answer returns one starting segment ID per block. The application rejects IDs outside the permitted anchors and resolves accepted IDs to exact original text, millisecond timestamps and a YouTube link at the segment's start. Summaries are derived evidence used for coverage; exact caption matching does not prove that every summary claim is correct. Missing outline anchors are reported as a structural diagnostic, not a semantic quality score.

%%{init: {"themeVariables": {"actorBkg": "#eef2ff", "actorTextColor": "#111827", "actorBorder": "#475569", "signalColor": "#475569", "sequenceNumberColor": "#ffffff"}}}%%
sequenceDiagram
    autonumber
    participant App as Experimental command
    participant Model as Fireworks
    participant Source as Saved transcript
    App->>Source: Read original captions and hash source
    App->>Model: Source passages and local anchor neighborhoods
    Model-->>App: Source-linked cards
    App->>App: Validate coverage, anchors and quotes
    App->>Model: Cards in six chronological portions
    Model-->>App: Up to eighteen overview lessons
    App->>Model: Question, outline and original anchor captions
    Model-->>App: Answer blocks with starting IDs
    App->>Source: Resolve exact captions and playback links
Loading

The experimental path prepares and reuses an outline before answering. The existing production path is retained unchanged.

Running and reusing the experiment

  • build makes paid model calls and saves the validated index. Source/model/format identity and prompt/schema/input fingerprints protect checkpoint reuse.
  • retrieve validates the saved index and exports overview input offline.
  • answer --mode overview uses that input. --mode full supplies the full usable transcript as a same-model control. --mode cards supplies every source card with four captions per anchor for focused diagnostics; it is not top-k semantic search.

Calls use the existing model factory, defaulting to DeepSeek V4.1 Flash with reasoning disabled. The command records usage, corrections and failures, propagates cancellation, and bounds each request to 150 seconds. Local checkpoints support resumed builds. Production lexical search, timestamp tools, routing, billing and storage are unchanged. Storyboards and production index lifecycle management are outside this PR.

Design and commands contain the limits and reproduction instructions.

Tests

The platform build passed. The unit suite passed 1,701 tests, including 26 new regressions covering source coverage, local anchor bounds, exact quotes, stale indexes, omissions, bounded correction, citation resolution and cancellation. Rebuilding and retrieving with credentials removed reused checkpoints without additional model calls.

A fresh live smoke comparison used the saved React transcript and the same question, model and answer schema for both arms:

Answer input Input tokens Output tokens Outcome
Full transcript 21,693 1,244 Filled twenty blocks and stopped at props; omitted the final exercise
Source-linked overview 5,256 1,522 Included the final Alert exercise at segment 1996; represented all eighteen outline anchors

This is the packaged command's isolated comparison, not a deployed-production or full agent/finalizer benchmark. It used about 76% less input and 22% more output. All eighteen overview citations matched the original caption text and timestamps.

The completed build retained twenty generation stages, including three card-correction calls: 53,718 input and 15,741 output tokens, estimated at $0.04107. All twenty-four recorded build/development calls, including earlier rejected outputs, cost approximately $0.05164. Checkpoints were reused across development runs, so this was not a clean-cache benchmark. At the observed answer costs and cache rates, the retained build cost would take roughly eight similar overviews to recover. One answer including index construction costs more than one full-transcript answer.

Remaining limitations: the overview still omitted Node/editor setup and Vite project creation despite their presence in the outline. Some lessons combine multiple topics under a broad starting citation. Structural coverage and exact caption resolution do not establish complete topic coverage or perfect semantic attribution. This remains an opt-in experiment pending broader evaluation and production lifecycle design.

Detailed validation and cost accounting distinguish earlier experiments from this implementation's checks. No new GLM, multi-video, Workers integration or production evaluation was performed for this PR, and nothing was deployed.

@vercel

vercel Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
video2ctx-web Ready Ready Preview Oct 10, 2026 5:52pm UTC

devhims commented Oct 10, 2026

Copy link
Copy Markdown
Owner Author

Reviewed c9c2f57 against its stacked base 9a201f0. Two reproducible issues in the new index path:

  1. P2: Check the original quote before stripping a possible numeric prefix. At index.ts:63–71, a real caption beginning with its own ID is treated as model-added metadata. For segment 0 containing 0 degrees is the freezing point., an exact anchorQuote is stripped to degrees… and rejected. Returning the correct quote again consumes the correction call and fails construction. Returning 0 0 degrees… initially validates, but the stored canonical quote is stripped again during validateIndex, so the completed index still cannot be saved/reused. Try the unmodified quote first, then an optionally de-prefixed candidate, against the same exact-source rules. Add build → canonicalize → validateIndex regressions for numeric-leading captions, including whitespace normalization.

  2. P2: Reject duplicated outline lessons instead of counting them as coverage slots. validateLessons checks row count and anchor membership only. In a 132-card mock with distinct anchors, copying each portion's first lesson three times produces an 18-row index that passes persisted validation. Retrieval then has only six allowed anchors [0,22,44,66,88,110]; a six-block answer reports unrepresentedAnchors: []. This lets repeated model output silently consume the reserved slots before answer generation. Reject repeated lessons and require distinct selected anchors when the portion has enough distinct candidates (with an explicit short/shared-anchor policy), so bounded correction runs instead. Add a regression covering both fresh construction and persisted-index validation. This is a structural duplicate check, separate from the documented semantic-completeness limitation.

Verification: executed the actual TypeScript index module locally with mocked generation, including a 132-card happy path, omissions, stale source rejection, gap-local anchoring, unavailable citations, cancellation and isolated repair. Both findings reproduced without paid calls. Independently confirmed Verify #416 succeeded, including platform type/unit checks and integration. I did not rerun the full suite or live model comparison locally. The documentation appropriately distinguishes the single-video token comparison, incomplete topic coverage, preparation cost and estimated pricing from production evidence.

This branch was successfully deployed

1 active deployment
Preview — c9c2f577 Deployed Oct 10, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant