-
Notifications
You must be signed in to change notification settings - Fork 1
Slide Matching Algorithm
This document presents an enhanced slide matching algorithm that aligns lecture transcript sentences to corresponding PDF slides using vision-text embeddings derived from audio-only input. Unlike the MaViLS benchmark which uses video frames with OCR and image features, our system operates exclusively on audio transcripts processed through ASR (Automatic Speech Recognition) and RAG embeddings. We enhance the MaViLS dynamic programming framework with four key algorithmic improvements: exponential scaling, confidence boosting, context similarity tracking, and sentence length filtering. Through extensive hyperparameter optimization across 20 diverse lecture datasets from the MaViLS benchmark, we achieved 81.7% accuracy, representing a 28.7pp absolute improvement over MaViLS's audio-only approach (53%) and approaching the performance of MaViLS's multimodal (video+audio+OCR) system (82%).
Given a lecture transcript split into sentences and a set of lecture slides in PDF format, the goal is to assign each sentence to its corresponding slide page number. This is challenging because:
- Lectures often reference slides non-sequentially (jumping back and forth)
- Some sentences may not directly correspond to any visible slide content
- Multimodal similarity scores alone are insufficient for accurate alignment
- Temporal coherence must be maintained while allowing necessary slide transitions
The MaViLS (Matching Videos to Lecture Slides) benchmark [Anderer et al., 2024] presents a multimodal algorithm for aligning lecture videos with PDF slides. The original MaViLS system:
Input: Lecture video frames (not audio transcripts)
Features:
- Text features via OCR (Tesseract) from video frames
- Image features from video frames using transformer models
- Audio features from speech transcripts
Matching Strategy: Dynamic programming with basic jump penalty mechanism
Performance on MaViLS Dataset:
- Text-only (OCR): 76% accuracy
- Audio-only: 53% accuracy
- Image-only: 64% accuracy
- Combined (multimodal): 82% accuracy
Unlike MaViLS which extracts features from video frames, our system operates exclusively with audio transcripts. This presents unique challenges:
- No visual information: We cannot use OCR from video frames or image features
- ASR-based text extraction: Instead of OCR from videos, we use ASR (Automatic Speech Recognition) to transcribe audio
- Sentence-level embeddings: We employ RAG (Retrieval-Augmented Generation) embeddings on ASR transcripts to create rich semantic representations
MaViLS's audio-only approach achieved 53% accuracy, demonstrating the difficulty of slide matching without visual features from video frames.
We adopt and extend the MaViLS dynamic programming formulation:
D[i,j] = max over k: D[i-1,k] + similarity[i,j] - jump_penalty(k, j)
MaViLS jump penalty:
jump_penalty(k, j) = {
|k - j| × λ, if k < j (forward jump)
2 × |k - j| × λ, if k > j (backward jump)
}
where λ is a small constant (MaViLS used λ=0.1 optimally, achieving 82% with multimodal features).
- Uniform score treatment: All similarity scores treated equally regardless of confidence level
- No context awareness: Each sentence matched independently without considering lecture flow
- Linear scoring: Raw similarity scores don't distinguish well between close candidates
- No confidence modeling: Uncertainty in ASR transcription not considered
- Fixed penalty weights: No adaptive mechanisms for different lecture styles
The core matching algorithm uses dynamic programming to find the globally optimal slide sequence while penalizing excessive slide jumps. We adopt the DP formulation from MaViLS and enhance it with three key improvements to the scoring mechanism.
State Definition:
dp[i][j] = maximum cumulative score for assigning sentences 0..i
where sentence i is matched to slide j
Transition Function:
dp[i][j] = max over k of:
dp[i-1][k] + score[i][j] - jump_penalty(k, j)
Jump Penalty:
jump_penalty(k, j) = {
(j - k - 1) × penalty_base, if k < j (forward jump)
(k - j) × penalty_base × backward_weight, if k ≥ j (backward jump)
}
Parameters:
-
penalty_base: Base penalty for slide jumps (default: 1.5) -
backward_weight: Multiplier for backward jumps (default: 1.85)
Rationale: Forward jumps (skipping slides) are natural in lectures, but backward jumps (returning to earlier slides) should be penalized more heavily since they are less common.
The basic DP framework with raw similarity scores has several limitations:
- Small score differences: Embedding models produce scores with small numerical differences between correct and incorrect matches
- No confidence modeling: All matches treated equally regardless of how certain they are
- No temporal context: Each sentence matched independently without considering lecture flow
- Balance issues: Raw scores may not be properly balanced against jump penalties
We introduce four complementary techniques that modify the score[i][j] term in the DP transition to improve matching accuracy. These enhancements are applied sequentially to the similarity scores before the DP algorithm runs.
Motivation: Raw similarity scores from embedding models often have small differences between correct and incorrect matches. Linear scoring doesn't sufficiently amplify these differences, making it hard for the DP algorithm to distinguish between good and mediocre matches.
Applied to DP: Modify the base similarity scores before they enter the DP transition:
# Original DP transition
dp[i][j] = max_k [ dp[i-1][k] + score[i][j] - jump_penalty(k, j) ]
# With exponential scaling
score_norm[i][j] = score[i][j] / max(score[i]) # Normalize (1st = 1.0)
score_scaled[i][j] = exp(α · (score_norm[i][j] - 1)) # Amplify differences
dp[i][j] = max_k [ dp[i-1][k] + score_scaled[i][j] - jump_penalty(k, j) ]
Parameters:
-
α: Exponential scale factor (default: 2.79)
Effect:
- High-scoring matches get exponentially boosted (closer to 1.0 → higher boost)
- Low-scoring matches get exponentially suppressed (farther from 1.0 → lower score)
- This makes the best matches "stand out" more clearly in the DP optimization
Motivation: After normalization, the second-best score represents the relative strength of the runner-up candidate. When the second-best score is low (below threshold), it indicates a large gap between the top two candidates, meaning the first choice is highly confident. In such cases, we should amplify all scores to let the DP prioritize the strong similarity match over jump penalties.
Applied to DP: Conditionally boost all scores for high-confidence sentences:
# After exponential scaling
score_norm[i][j] = score[i][j] / max(score[i]) # 1st place = 1.0
second_best[i] = top2_scores[i][1] # 2nd place score
if second_best[i] < threshold: # Large gap = high confidence
score_boosted[i][:] = score[i][:] * confidence_weight
else:
score_boosted[i][:] = score[i][:]
dp[i][j] = max_k [ dp[i-1][k] + score_boosted[i][j] - jump_penalty(k, j) ]
Parameters:
-
threshold: Confidence threshold for second-best score (default: 0.9) -
confidence_weight: Score multiplier when confidence is high (default: 2.13)
Effect:
- When the top match is significantly better than alternatives (second < 0.9), boost all scores
- This increases the relative weight of similarity vs. jump penalty
- Allows the DP to "trust" clear matches more strongly and make necessary jumps when confident
Motivation: Lectures typically spend multiple consecutive sentences on the same slide. By tracking which slides have been recently discussed using an exponential moving average (EMA), we can provide temporal context to the DP algorithm and encourage it to stay on recently-visited slides.
Applied to DP: Add context-aware bonus to scores during DP iteration:
# Initialize context
context_scores[j] = 0 for all slides j
# During DP loop (for each sentence i)
for i in range(num_sentences):
# Add context bonus to current scores
score_final[i][j] = score_boosted[i][j] + γ · context_scores[j]
# DP transition with context-aware scores
dp[i][j] = max_k [ dp[i-1][k] + score_final[i][j] - jump_penalty(k, j) ]
# Update context EMA after matching sentence i
context_scores[j] += β · (score_boosted[i][j] - context_scores[j])
Parameters:
-
β: EMA update rate (default: 0.24) -
γ: Context weight (default: 0.04)
Effect:
- Slides recently matched receive a small bonus (context_scores[j] > 0)
- This bonus decays exponentially if the slide isn't matched for a while
- Encourages temporal coherence while still allowing jumps when similarity is strong
Motivation: Very short utterances (e.g., "okay", "um", "yeah") often lack semantic content and can introduce noise into the matching process. These sentences typically have low similarity scores to all slides, making them unreliable for alignment.
Applied to DP: Filter out short sentences before computing similarity-based scores:
# Preprocessing: filter by word count
for i in range(num_sentences):
word_count = len(sentence[i].split())
if word_count < min_sentence_length:
# Skip similarity computation, use only previous DP state
dp[i][j] = dp[i-1][best_previous_slide]
else:
# Normal DP transition with similarity scores
dp[i][j] = max_k [ dp[i-1][k] + score[i][j] - jump_penalty(k, j) ]
Parameters:
-
min_sentence_length: Minimum word count threshold (default: 2)
Effect:
- Sentences with fewer than 2 words are automatically assigned to the previous best slide
- Reduces noise from uninformative utterances
- Improves overall matching accuracy by focusing on semantically meaningful content
- Has minimal impact on overall accuracy but provides cleaner alignment
Putting all four enhancements together, the complete DP transition becomes:
# 1. Compute raw similarity scores
scores = cosine_similarity(query_embeddings, image_embeddings)
# 2. Normalize scores (per-query)
scores = scores / max(scores, dim=1)
# 3. Enhancement 1: Exponential Scaling
scores = exp(α · (scores - 1))
# 4. Enhancement 2: Confidence Boosting
top2 = top2_scores(scores, dim=1)
if top2[:, 1] < confidence_threshold:
scores *= confidence_weight
# 5. Initialize DP and context
dp[0, :] = scores[0, :]
context_scores = zeros(num_pages)
# 6. DP with Enhancement 3: Context Similarity and Enhancement 4: Length Filter
for i in range(1, num_sentences):
word_count = len(sentences[i].split())
if word_count < min_sentence_length:
# Enhancement 4: Skip short sentences
dp[i, :] = dp[i-1, argmax(dp[i-1, :])]
else:
# Add context bonus
current_scores = scores[i, :] + γ · context_scores
# DP transition
for j in range(num_pages):
dp[i][j] = max over k:
dp[i-1][k] + current_scores[j] - jump_penalty(k, j)
# Update context EMA
context_scores += β · (scores[i, :] - context_scores)
# 7. Backtrack to find optimal path
best_path = backtrack(dp)
Key Insight: Each enhancement addresses a different aspect of the scoring mechanism:
- Exponential scaling → Amplifies score differences (better signal)
- Confidence boosting → Adjusts score-penalty balance (adaptive trust)
- Context similarity → Adds temporal coherence (lecture flow)
- Sentence length filter → Reduces noise from uninformative short utterances
System Overview: Our system operates on audio-only input (audio → ASR → RAG embeddings → enhanced DP matching), using NVIDIA ColEmbedder-3B (bfloat16) for multimodal embeddings, PyMuPDF for PDF processing (150 DPI), and vectorized PyTorch DP implementation. The complete code is available in backend/inference_models/slide_matching_processor.py.
Comparison Summary:
- MaViLS: Video frames → OCR/Image features → Basic DP → 82% (multimodal), 53% (audio-only)
- Our approach: Audio → ASR → RAG embeddings → Enhanced DP → 81.7% (audio-only)
We conducted an extensive hyperparameter search over the following space:
| Parameter | Search Range | Final Value |
|---|---|---|
jump_penalty |
[0.05, 2.5] | 1.5 |
backward_weight |
[0.25, 3.0] | 1.85 |
exponential_scale |
[2.5, 3.5] | 2.785 |
confidence_threshold |
[0.85, 0.975] | 0.913 |
confidence_weight |
[1.05, 2.5] | 2.18 |
context_weight |
[0.01, 1.0] | 0.04 |
context_update_rate |
[0.05, 0.8] | 0.24 |
min_sentence_length |
[1, 5] | 2 |
Total configurations evaluated: 10,000+ combinations
The top-performing configuration achieved:
- Average accuracy: 81.7%
- Standard deviation: 0.098
- Min accuracy: 62.0% (Cognitive Robotics lecture)
- Max accuracy: 93.1% (Creating Breakthrough Products lecture)
Key observations:
- Top configurations cluster tightly around optimal values
-
jump_penalty=1.5andbackward_weight=1.85are critical -
exponential_scalehas a narrow optimal range (2.78-2.79) -
confidence_weight=2.18provides best boost without over-correction -
min_sentence_length=2filters out uninformative short utterances
To understand the contribution of each component, we conducted a systematic ablation study on 20 lectures.
| Configuration | Exponential Scaling | Confidence Boost | Context Similarity | Length Filter | Avg Accuracy | Improvement |
|---|---|---|---|---|---|---|
| Baseline (No features) | ✗ | ✗ | ✗ | ✗ | 78.37% | — |
| Full Model (All) | ✓ | ✓ | ✓ | ✓ | 81.66% | +3.29% |
| w/o Length Filter | ✓ | ✓ | ✓ | ✗ | 81.62% | +3.25% |
| w/o Context Similarity | ✓ | ✓ | ✗ | ✓ | 81.18% | +2.81% |
| w/o Exponential Scaling | ✗ | ✓ | ✓ | ✓ | 79.02% | +0.65% |
| w/o Confidence Boost | ✓ | ✗ | ✓ | ✓ | 78.40% | +0.03% |
- Confidence boost is most critical: Removing it drops accuracy by 3.26pp (81.66% → 78.40%)
- Exponential scaling is second most important: Removing it drops accuracy by 2.64pp (81.66% → 79.02%)
- Context similarity provides modest gain: Contributes 0.48pp improvement
- Length filter has minimal impact: Only 0.04pp improvement, but helps with cleaner alignment
- Synergistic effects: Individual components work best when combined together
- Full model achieves 81.7% accuracy: All four components together provide 3.29pp improvement over baseline
Best and worst performing lectures with full model:
Top 3 Performers:
- Creating Breakthrough Products: 93.1%
- Deep Learning: 92.6%
- Computer Vision 2.2: 92.5%
Bottom 3 Performers:
- Cognitive Robotics: 62.0%
- Psychology: 62.2%
- Reinforcement Learning: 68.3%
Analysis: Performance correlates with visual-textual alignment. Lectures with clear diagrams, code, or equations perform better than those with abstract concepts.
| Method | Modality | Accuracy | Key Features |
|---|---|---|---|
| MaViLS (OCR only) | Video frames | 76.0% | OCR from video + DP |
| MaViLS (Audio only) | Audio transcript | 53.0% | Speech features + DP |
| MaViLS (Image only) | Video frames | 64.0% | Visual features + DP |
| MaViLS (Multimodal) | Video + Audio | 82.0% | OCR + Image + Audio + DP |
| Our approach (Audio only + Enhanced DP) | Audio transcript | 81.7% | ASR + RAG embeddings + Exp scaling + Conf boost + Context + Length filter + Optimized DP |
Key Insights:
- Major improvement: Our algorithmic enhancements boost audio-only accuracy from MaViLS's 53% to 81.7% (+28.7pp absolute improvement)
- Approaching multimodal performance: Our audio-only system (81.7%) nearly matches MaViLS's full multimodal system (82.0%), demonstrating that sophisticated algorithmic improvements can compensate for lack of visual information
- Practical advantage: Our approach requires only audio input, while MaViLS requires video frames for OCR and image extraction
We presented an enhanced slide matching algorithm that achieves near-multimodal performance using audio-only input on the MaViLS benchmark through four key innovations applied to the dynamic programming framework:
- Exponential scaling to amplify similarity score differences
- Confidence boosting to emphasize high-confidence matches by increasing their relative weight over jump penalties
- Context similarity tracking via EMA to maintain temporal coherence
- Sentence length filtering to reduce noise from uninformative short utterances
Key Contributions:
-
Audio-only approach: Unlike MaViLS which requires video frames for OCR and image features, our system operates exclusively on audio transcripts processed through ASR and RAG embeddings
-
Algorithmic innovations: We enhance the MaViLS DP framework with four novel components that work synergistically to improve matching accuracy
-
Extensive optimization: Through hyperparameter search over 10,000+ configurations and rigorous ablation studies, we identified optimal parameter settings
-
Remarkable performance: We achieve 81.7% accuracy (audio-only), representing a 28.7pp absolute improvement over MaViLS's audio-only approach (53%) and approaching MaViLS's multimodal performance (82%)
Significance: Our work demonstrates that sophisticated algorithmic enhancements to the matching framework can compensate for the lack of visual information, achieving near-multimodal performance with audio alone.