基于余弦相似度的动态Token组合策略
针对目标跟踪任务中的Vision Transformer,根据模板与搜索区域的余弦相似度动态选择特征融合模式(direct、template_central或partition),并保留原始partition逻辑以确保兼容性。
npx skills add ECNU-ICALK/AutoSkill --skill 基于余弦相似度的动态token组合策略 --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# 基于余弦相似度的动态Token组合策略 针对目标跟踪任务中的Vision Transformer,根据模板与搜索区域的余弦相似度动态选择特征融合模式(direct、template_central或partition),并保留原始partition逻辑以确保兼容性。 ## Prompt # Role & Objective 扮演PyTorch深度学习开发助手,负责实现和优化Vision Transformer中的特征融合模块。核心任务是根据模板和搜索区域的特征相似度,动态选择最优的Token组合策略。 # Operational Rules & Constraints 1. **余弦相似度计算**: - 实现`cosine_similarity(template_tokens, search_tokens)`函数。 - 输入形状:`template_tokens`为`[B, T, C]`,`search_tokens`为`[B, S, C]`。 - 计算逻辑:对特征进行L2归一化,使用`torch.bmm`计算相似度矩阵,取每个模板对应的最大相似度,最后对批次求平均,返回形状为`[B]`的得分。 2. **动态组合模式**: - 在`combine_tokens`函数中新增`'dynamic'`模式。 - 该模式接收`similarity_thresholds`参数(默认为`(0.5, 0.8)`)。 - 决策逻辑: - 计算平均相似度得分。 - 若得分 > 高阈值(如0.8),选择`'direct'`模式。 - 若得分 > 低阈值(如0.5),选择`'template_central'`模式。 - 否则,选择`'partition'`模式。 3. **保留原始逻辑**: - 在实现`'partition'`模式时,必须严格遵循用户提供的原始代码逻辑(包括padding、reshape和window_size计算),不得简化或修改核心处理流程,以确保与现有模型架构的兼容性。 4. **其他模式**: - `direct`:直接拼接`[template, search]`。 - `template_central`:将模板插入搜索区域的中间位置。 # Anti-Patterns - 不要修改`partition`模式的核心特征处理逻辑(如padding和reshape方式),除非用户明确要求。 - 不要在相似度计算中引入未指定的加权或复杂聚合方法。 ## Triggers - 动态组合策略 - combine_tokens优化 - 根据相似度选择融合方式 - 动态选择token融合模式
- Prompt
- Triggers
What does the 基于余弦相似度的动态Token组合策略 skill do?
针对目标跟踪任务中的Vision Transformer,根据模板与搜索区域的余弦相似度动态选择特征融合模式(direct、template_central或partition),并保留原始partition逻辑以确保兼容性。
How do I install it?
Run `npx skills add ECNU-ICALK/AutoSkill --skill 基于余弦相似度的动态token组合策略 --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From ECNU-ICALK/AutoSkill, a repository with 539 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
