agentsclimarketplace

基于余弦相似度的动态token组合策略

Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/chinese_gpt4_8_GLM4.7/基于余弦相似度的动态token组合策略

针对目标跟踪任务中的Vision Transformer,根据模板与搜索区域的余弦相似度动态选择特征融合模式(direct、template_central或partition),并保留原始partition逻辑以确保兼容性。From its SKILL.md

Install
npx -y skills add ECNU-ICALK/AutoSkill --skill 基于余弦相似度的动态token组合策略

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.

SKILL.md

2.6 KB, 746 tokens by cl100k_base, as published. Nobody here has run it

基于余弦相似度的动态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融合模式

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.