SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2409.01156 · ICLR · 2025

TempMe: Video Temporal Token Merging for Efficient Text-Video Retrieval

Sicheng Zhao, Guiguang Ding, Tao He, Tianxiang Hao, Leqi Shen, Yifeng Zhang, Pengzhang Liu, Yongjun Bao

arXiv · PDF · Open in the Atlas

Code that ran

7 of 8 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (3 of them constructed an object rather than computing a result; 1 honoured the contract we drafted, 0 violated it and 3 have no contract verdict; 3 failures of our instrument; 1 no recorded run), measured 2026-11-22; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2409.01156.json · badge: /api/ran/2409.01156.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
LunarShen/TempMe community
Papers with Code archive
6 ran · 1 no recorded run
lunarshen/dsicovla community
Papers with Code archive
1 ran · 0 no recorded run
FunctionStatusWhere it lives
Attention Ran
ran on a synthesized input · constructed an object; no result was computed
LunarShen/TempMe/tvr/models/module_tome_patch.py
code served (permissive licence) · get_code("cbfdf39eacd6be6c")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned an instance of its own class, Attention: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
import math

torch.manual_seed(0)

# Build the Attention module with valid parameters
embed_dim = 8
num_heads = 2
lora_dim = 4

attention_module = nn.Attention(embed_dim, num_heads, lora_dim) if hasattr(nn, 'Attention') else None

# Since Attention is defined in the function, we need to instantiate it directly
# Create a simple test by importing and instantiating
class Attention(nn.Module):
    def __init__(self, embed_dim, num_heads, lora_dim):
        super().__init__()
        self.num_heads = num_heads
        self.head_dim = embed_dim // num_heads
        self.scaling = float(self.head_dim) ** (-0.5)
        self.lora_dim = lora_dim
        self.in_proj_weight = nn.Parameter(torch.empty(3 * embed_dim, embed_dim))
        self.in_proj_bias = nn.Parameter(torch.empty(3 * embed_dim))
        self.out_proj = nn.Linear(embed_dim, embed_dim, bias=True)
        self.TVPt_LoRA_a = nn.Parameter(torch.zeros(lora_dim, embed_dim))
        nn.init.kaiming_uniform_(self.TVPt_LoRA_a, a=math.sqrt(5))
        self.TVPt_LoRA_b = nn.Parameter(torch.zeros(3 * embed_dim, lora_dim))

    def _reset_parameters(self):
        from torch.nn.init import constant_, xavier_uniform_
        xavier_uniform_(self.in_proj_weight)
        constant_(self.in_proj_bias, 0.0)
        constant_(self.out_proj.bias, 0.0)

    def forward(self, x):
        import torch.nn.functional as F
        bsz, tgt_len, embed_dim = x.size()
        q, k, v = F.linear(x, self.in_proj_weight, self.in_proj_bias).chunk(3, dim=-1)
        q = q * self.scaling
        q = q.contiguous().view(bsz, tgt_len, self.num_heads, self.head_dim).permute(0, 2, 1, 3)
        k = k.contiguous().view(bsz, tgt_len, self.num_heads, self.head_dim).permute(0, 2, 1, 3)
        v = v.contiguous().view(bsz, tgt_len, self.num_heads, self.head_dim).permute(0, 2, 1, 3)
        attn = q @ k.transpose(-2, -1)
        attn = attn.softmax(dim=-1)
        x = (attn @ v).transpose(1, 2).reshape(bsz, tgt_len, embed_dim)
        x = F.linear(x, self.out_proj.weight, self.out_proj.bias)
        return (x, None)

# Create input tensor: batch_size=2, sequence_length=3, embed_dim=8
x = torch.randn(2, 3, 8)

ARGS = {
    "embed_dim": 8,
    "num_heads": 2,
    "lora_dim": 4,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Attention — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a Attention output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
Attention_GlobalCLS Ran
ran on a synthesized input · constructed an object; no result was computed
lunarshen/dsicovla/tvr/models/module_transformer.py
code served (permissive licence) · get_code("f770b619ad6d77b5")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned an instance of its own class, Attention_GlobalCLS: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
from torch import nn
import math

torch.manual_seed(0)

# Define the ARGS dict with all required parameters for Attention_GlobalCLS
ARGS = {
    'embed_dim': 8,
    'num_heads': 2,
    'lora_dim': 4,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
einops, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Attention_GlobalCLS — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a Attention_GlobalCLS output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
ResidualAttentionBlock Ran
ran on a synthesized input · constructed an object; no result was computed
LunarShen/TempMe/tvr/models/module_tome_patch.py
code served (permissive licence) · get_code("07221ceabbfc85ec")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned an instance of its own class, ResidualAttentionBlock: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
import math

torch.manual_seed(0)

# Define ARGS dictionary with all parameters for ResidualAttentionBlock
ARGS = {
    'd_model': 8,
    'n_head': 2,
    'lora_dim': 4,
    'frame_num': 3,
    'attn_mask': None,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ResidualAttentionBlock — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a ResidualAttentionBlock output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
bipartite_soft_matching Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
LunarShen/TempMe/tvr/models/module_tome_patch.py
code served (permissive licence) · get_code("c8bfd649bf334138")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# Analyze the function signature and body:
# - metric: torch.Tensor - used with indexing, norm, transpose, max, argsort, gather, scatter_reduce
# - r: int - used as threshold for slicing
# - cls_num: int - used for slicing and modulo check
# - r_f: int - not used in the function body, but required as parameter

# The metric tensor is indexed as:
# metric[:, :cls_num, :] and metric[:, cls_num:, :]
# So shape should be (batch, num_tokens, features)
# Let's use batch=2, num_tokens=8, features=4

batch_size = 2
num_tokens = 8
feature_dim = 4
cls_num = 2

# Create metric tensor with shape (batch, num_tokens, feature_dim)
metric = torch.randn(batch_size, num_tokens, feature_dim)

# r should be positive and less than (num_tokens - cls_num) // 2
# to have meaningful matching
r = 2

# r_f is not used in function body, but is a required parameter
r_f = 0

ARGS = {
    "metric": metric,
    "r": r,
    "cls_num": cls_num,
    "r_f": r_f,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, dtype family float — a tuple output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
do_nothing Ran
ran, honoured the contract we drafted
LunarShen/TempMe/tvr/models/module_tome_patch.py
code served (permissive licence) · get_code("969e8250d805a154")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 2, dtype family float, shape (2, 4) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

ARGS = {
    "x": torch.randn(2, 4),
    "mode": None,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 2, dtype family float, shape (2, 4) — shape (2, 4) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
merge_source Ran
ran; our contract draft was wrong, not the code
LunarShen/TempMe/tvr/models/module_tome_patch.py
code served (permissive licence) · get_code("d6d31b246591a6d0")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 3, dtype family float, shape (2, 4, 1) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
from typing import Callable

torch.manual_seed(0)

# Create a simple merge callable that applies amax pooling
class SimpleMerge(nn.Module):
    def forward(self, tensor, mode='amax'):
        if mode == 'amax':
            # Simple reduction along last dimension
            return torch.amax(tensor, dim=-1, keepdim=True)
        return tensor

merge_fn = SimpleMerge()

# Create input tensor x with shape (batch=2, tokens=4, features=3)
x = torch.randn(2, 4, 3)

# Create source tensor (adjacency matrix) or leave as None
# If provided, should be (batch=2, tokens=4, tokens=4)
source = torch.eye(4)[None, ...].expand(2, 4, 4)

ARGS = {
    'merge': merge_fn,
    'x': x,
    'source': source
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 3, dtype family float, shape (2, 4, 1) — shape (2, 4, 1) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
merge_wavg Ran
ran; our contract draft was wrong, not the code
LunarShen/TempMe/tvr/models/module_tome_patch.py
code served (permissive licence) · get_code("726064eec41365b4")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
from typing import Callable

torch.manual_seed(0)

# Define a simple merge function that the merge_wavg function will call
# Based on the function body, it needs to accept x and a mode parameter
class SimpleMerge(nn.Module):
    def forward(self, x, mode='sum'):
        # Simple merge: sum along a specific dimension (e.g., sequence dimension)
        # Assuming x has shape (..., seq_len, features), merge along seq_len
        if mode == 'sum':
            return x.sum(dim=-2, keepdim=True)
        else:
            return x

merge_fn = SimpleMerge()

# Create a small tensor
# Shape: (batch=2, seq_len=3, features=4)
x = torch.randn(2, 3, 4)

# Create size tensor
# Shape: (batch=2, seq_len=3, 1)
size = torch.ones(2, 3, 1)

ARGS = {
    'merge': merge_fn,
    'x': x,
    'size': size
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
ToMeBlock Not yet run
unverified (harvested, no recorded run)
LunarShen/TempMe/tvr/models/module_tome_patch.py
code served (permissive licence) · get_code("f46324f012ea5ba4")
How it ran

no invocation recorded.

Also present in other papers' code

Of 8 samples lifted from this paper's linked repositories, 8 carry a function identity and 0 do not. Of the 8 distinct functions with an identity, 3 are also present in other papers whose code we hold (3 with at least one paper dated earlier, 1 the same month, 2 later) and 5 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

FunctionAlso present inEarliest-datedOthers named
do_nothing
brick of this paper's assembly: helper
13 other papers
9 dated earlier, 1 the same month, 3 later · 4 only as an assembly brick
2210.09461 (2022-10)
Token Merging: Your ViT But Faster
2307.10780 (2023-07)
Learned Thresholds Token Merging and Pruning for Vision Transformers
2310.01812 (2023-10)
PPT: Token Pruning and Pooling for Efficient Vision Transformers
and 10 more not named here
merge_wavg
brick of this paper's assembly: helper
5 other papers
3 dated earlier, 2 later · 2 only as an assembly brick
2310.19060 (2023-10)
TESTA: Temporal-Spatial Token Aggregation for Long-form Video-Language Understanding
2404.09490 (2024-04)
Leveraging Temporal Contextualization for Video Action Recognition
2406.09936 (2024-06)
ALGM: Adaptive Local-then-Global Token Merging for Efficient Semantic Segmentation with Plain Vision Transformers
and 2 more not named here
merge_source
brick of this paper's assembly: helper
2 other papers
2 dated earlier · 1 only as an assembly brick
2404.09490 (2024-04)
Leveraging Temporal Contextualization for Video Action Recognition
2406.09936 (2024-06)
ALGM: Adaptive Local-then-Global Token Merging for Efficient Semantic Segmentation with Plain Vision Transformers

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-22.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Most text-video retrieval methods utilize the text-image pre-trained models like CLIP as a backbone. These methods process each sampled frame independently by the image encoder, resulting in high computational overhead and limiting practical deployment. Addressing this, we focus on efficient text-video retrieval by tackling two key challenges: 1. From the perspective of trainable parameters, current parameter-efficient fine-tuning methods incur high inference costs; 2. From the perspective of model complexity, current token compression methods are mainly designed for images to reduce spatial redundancy but overlook temporal redundancy in consecutive frames of a video. To tackle these challenges, we propose Temporal Token Merging (TempMe), a parameter-efficient and training-inference efficient text-video retrieval architecture that minimizes trainable parameters and model complexity. Specifically, we introduce a progressive multi-granularity framework. By gradually combining neighboring clips, we reduce spatio-temporal redundancy and enhance temporal modeling across different frames, leading to improved efficiency and performance. Extensive experiments validate the superiority of our TempMe. Compared to previous parameter-efficient text-video retrieval methods, TempMe achieves superior performance with just 0.50M trainable parameters. It significantly reduces output tokens by 95% and GFLOPs by 51%, while achieving a 1.8× speedup and a 4.4% R-Sum improvement. With full fine-tuning, TempMe achieves a significant 7.9% R-Sum improvement, trains 1.57× faster, and utilizes 75.2% GPU memory usage. The code is available at https://github.com/LunarShen/TempMe.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2409.01156")
get_code_for_paper("2409.01156")
have("2409.01156")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2409.01156.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2409.01156.svg)](https://syntology.ai/paper/2409.01156)

Connect an agent — have() is free.