Skip to content
Back to skills

Tecoa Text Contrastive Objective

ASecurity

Compute TeCoA image-to-text contrastive logits, loss, margins, and accuracy for robustness recovery.

  • 247 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 9, 2026
toolspythongit

Works with

  • cli

Security analysis

A100/100

Scanned September 9, 2026

npx -y skills add VectorSpaceLab/AREX-Skill --skill tecoa_text_contrastive_objective --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Tecoa Text Contrastive Objective?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Tecoa Text Contrastive Objective
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/vectorspacelab-tecoa-text-contrastive-objective/badge)](https://www.skillsdirectory.com/skills/vectorspacelab-tecoa-text-contrastive-objective)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

SKILL.md
---
name: tecoa_text_contrastive_objective
description: Compute TeCoA image-to-text contrastive logits, loss, margins, and accuracy for robustness recovery.
---

# TeCoA Text Contrastive Objective

Use this skill when image and text embeddings must be scored according to the TeCoA objective. It implements the paper's cross-modal supervision contract: adversarial visual features should align with the correct text embeddings under normalized cosine logits.

Do not use this skill to generate adversarial perturbations or update model parameters. It is a deterministic scoring module consumed by attack and recovery harnesses.

## Inputs

- `image_embeddings`: numeric matrix with shape `[batch, dim]`.
- `text_embeddings`: numeric matrix with shape `[classes, dim]`.
- `labels`: integer target text index for each image row.
- `temperature`: positive scalar, default `0.07`.

## Outputs

- `logits`: cosine logits divided by temperature.
- `loss`: mean image-to-text cross-entropy.
- `accuracy`: top-1 image-to-text accuracy.
- `margins`: correct logit minus best wrong logit for each row.
- `mean_margin`: average margin.

## Workflow

1. Validate matrix dimensions, non-zero vectors, label range, and temperature.
2. L2-normalize image and text embeddings row-wise.
3. Compute image-to-text logits.
4. Compute cross-entropy, top-1 accuracy, and margins.
5. Return JSON-serializable metrics so recovery can compare clean, adversarial, and adapted states.

## Validation

Run the tests in `tests/test_contrastive_objective.py` or the Distiller skill-tree validator with `--run-tests`.

## Limitations

This skill uses Python standard-library math for portability. It is intended for deterministic reduced/proxy checks and numeric cross-checks, not high-throughput CLIP training.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…