百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
C

chapter-llama

> 编程语言
开源

论文"Chapter-LLaMA: 利用 LLM 在长达一小时的视频中进行高效分章"的官方 PyTorch 实现

99 stars0 点赞2 次浏览
访问官网GitHub

工具介绍

论文"Chapter-LLaMA: 利用 LLM 在长达一小时的视频中进行高效分章"的官方 PyTorch 实现

Description

This repository contains the code for the paper "Chapter-Llama: Efficient Chaptering in Hour-Long Videos with LLMs" (CVPR 2025).

Please visit our webpage for more details.

Project Structure  

…

Installation

Create environment  

bash
conda create python=3.12 --name chapter-llama -y
conda activate chapter-llama

To install the necessary packages for training and testing, you can use the provided requirements.txt file:

bash
python -m pip install -r requirements.txt

or

bash
python -m pip install -e .

The code was tested on Python 3.12.9 and PyTorch 2.6.0

For inference on videos that are not in the VidChapters-7M dataset, you will need to install the following dependencies to extract ASR and captions from the video (not required for training):

bash
python -m pip install -e ".[inference]"

Download models  

The Llama-3.1-8B-Instruct model will be downloaded automatically from Hugging Face, make sure you agree to the license terms here. If you already have it downloaded, please check the llama3.1_8B.yaml config file to specify the checkpoint path.

We provide 3 LoRA parameter sets for Llama-3.1-8B-Instruct:

  • asr-10k: Model trained with ASR from 10k videos of the VidChapters-7M dataset. Used for our Speech-based frame selector.
  • captions_asr-10k: Model trained with Captions+ASR from 10k videos of the VidChapters-7M dataset. Used for most of our experiments.
  • captions_asr-1k: Model trained with Captions+ASR from 1k videos of the VidChapters-7M dataset. Used for the full test set.

To download the LoRA parameter sets, run:

bash
python tools/download/models.py "asr-1k" --local_dir "."
python tools/download/models.py "asr-10k" --local_dir "."
python tools/download/models.py "captions_asr-1k" --local_dir "."
python tools/download/models.py "captions_asr-10k" --local_dir "."

Download captions  

First, create a directory to store the data and create a symlink to it from the VidChapters directory:

bash
mkdir path/to/VidChapters/
ln -s path/to/VidChapters/ dataset/

The dataset/captions/ directory contains the video captions organized by the captioning model used (HwwwH_MiniCPM-V-2) and the sampling method. To download the captions for our sampling method (asr_s10k-2_train_preds+no-asr-10s), run:

bash
bash tools/download/captions.sh asr_s10k-2_train_preds+no-asr-10s

This method uses predictions from an ASR model trained on the s10k-2 subset when ASR is available for the video, and falls back to sampling frames every 10 seconds when ASR is not available. The other sampling methods available are:

bash
bash tools/download/captions.sh 10s
bash tools/download/captions.sh 100f
bash tools/download/captions.sh shot_boundaries

Please refer to the how_to_extract_captions.md documentation for more details.

Download docs  

The dataset/docs/ directory contains the ASR and chapter data for the VidChapters-7M dataset. We provide:

  1. Complete dataset: Contains 817k videos with approximately 20 GB of ASR data.
  2. Specific subsets used in our paper experiments (recommended for most users as it is much faster to load and download).

To download a specific subset's data (which includes video ids, ASR and chapter information), run:

bash
bash tools/download/docs.sh subset_name

Where subset_name can be full for the complete dataset or one of the following:

Training sets:

  • sml1k_train: Training set with 1k videos (short+medium+long), used for ablation studies.
  • sml10k_train: Training set with 10k videos (short+medium+long), used for Table 1 and the data scaling experiment (Figure 4).
  • s10k-2_train: Training set with 10k videos (short), used for our Speech-based frame selector.

Validation sets:

  • sml300_val: Validation set with 300 videos (short+medium+long)
  • s100_val: Validation set with 100 videos (short)
  • m100_val: Validation set with 100 videos (medium)
  • l100_val: Validation set with 100 videos (long)

Test sets:

  • s_test: Short videos (

Download videos  

Note: Downloading videos is not necessary for training or testing since we provide the extracted captions and ASR data via Hugging Face (see commands above). This step is only required if you want to process new videos from different subsets or extract additional captions.

To download videos, install the yt-dlp library and run:

bash
python tools/download/videos.py dataset/docs/subset_data/subset_name.json

The videos will be downloaded to dataset/videos/.

If you encounter any issues with yt-dlp, you can find the video subsets sml1k_train, sml300_val, and test on Hugging Face. Access them here: Hugging Face Datasets - lucas-ventura/chapter-llama.

Dataset structure   Here's how the dataset folder should be structured:

…

Usage

Training and testing  

The command to launch a training experiment is the following:

bash
python train.py [OPTIONS]

or to run both train.py and test.py with the same options:

bash
bash train.sh [OPTIONS]

For only testing, run:

bash
python test.py [OPTIONS]

Note: You might need to run the test script with a single GPU (CUDA_VISIBLE_DEVICES=0).

Configuration  

The project uses Hydra for configuration management. Key configuration options:

  • data: asr, captions, captions_asr, captions_asr_given_times, captions_asr_given_titles, captions_asr_window
  • subset_train: Training dataset subset (default: "s1k_train")
  • paths: To change default paths, create a default.yaml file in configs/local/ and modify it as in configs/local/example.yaml
  • model: llama3.1_8B (default), zero-shot, llama3.2_3B, etc.

For example, to run training with the sml1k_train subset with ASR only, run:

bash
bash train.sh data=asr subset_train=sml1k_train subset_test=sml300_val

Results  

To get results from a single test experiment, run:

bash
python tools/results/evaluate_results.py path/to/experiment/test_dir --subset subset_name

For example:

bash
python tools/results/evaluate_results.py outputs/chapterize/Meta-Llama-3.1-8B-Instruct/captions_asr/asr_s10k-2_train_preds+no-asr-10s/sml1k_train/default/test/

Additionally, you can use the tools/results/evaluate_results.ipynb notebook to compare results from different video chapter generation experiments.

Quick Start ⚡

Single Video Chaptering  

If you just want to generate chapters for a single video:

bash
# Clone the repository
git clone https://github.com/lucas-ventura/chapter-llama.git
cd chapter-llama

# Create a conda environment (optional but recommended)
conda create python=3.12 --name chapter-llama -y
conda activate chapter-llama

# Install the package with inference dependencies
python -m pip install -e ".[inference]"

# Run the chaptering command
python inference.py /path/to/your/video.mp4

Currently, the command only uses the audio (via ASR extraction) to generate chapters. Support for automatic visual caption extraction will be added soon.

Chapters and the full output text will be saved in outputs/inference//.

Interactive Demo  

We also provide an interactive demo where you can upload videos and visualize the generated chapters:

bash
# Clone the repository
git clone https://github.com/lucas-ventura/chapter-llama.git
cd chapter-llama

# Install demo dependencies
python -m pip install -e ".[demo]"

# Launch the demo
python demo.py

The demo will start a local web server that you can access in your browser. You can upload videos, generate chapters, and see them visualized on the video timeline.

Citation

If you use this code in your work, please cite our paper:

bibtex
@InProceedings{ventura25chapter,
    title     = {{Chapter-Llama}: Efficient Chaptering in Hour-Long Videos with {LLM}s},
    author    = {Lucas Ventura and Antoine Yang and Cordelia Schmid and G{"u}l Varol},
    booktitle = {CVPR},
    year      = {2025}
}

Acknowledgements

Based on llama-cookbook and lightning-hydra-template.

License :books:

This code is distributed under an MIT License.

Our models are trained using the VidChapters-7M dataset, which has its own license that must be followed. Additionally, this project depends on several third-party libraries and resources, each with their own licenses: PyTorch, Hugging Face Transformers, Hydra, Lightning, Llama models.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Python

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言