Skip to content
Back to skills

Cic Contrastive Loss

ASecurity

Compute CIC normalized skill-transition contrastive loss, logits, margins, and tiny dependency-free training updates.

  • 247 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added September 9, 2026
toolspythongobashgit

Security analysis

A100/100

Scanned September 9, 2026

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

Installs into .claude/skills of the current project.

Are you the author of Cic Contrastive Loss?

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

Security grade badge for Cic Contrastive Loss
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/vectorspacelab-cic-contrastive-loss/badge)](https://www.skillsdirectory.com/skills/vectorspacelab-cic-contrastive-loss)

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

SKILL.md
---
name: cic_contrastive_loss
description: Compute CIC normalized skill-transition contrastive loss, logits, margins, and tiny dependency-free training updates.
---

# CIC Contrastive Loss

Use this skill when implementing the CIC representation-learning objective from paired transition tuples and continuous skills. It owns the normalized query/key logits, diagonal-positive labels, cross-entropy loss, and reduced optimizer update diagnostics.

## Inputs

- `tau`: transition tuple matrix `[batch, transition_dim]`.
- `skills`: continuous skill matrix `[batch, skill_dim]`.
- `query_weights`: linear weights mapping skills to embedding space.
- `key_weights`: linear weights mapping transitions to embedding space.
- `temperature`: positive scalar.

## Outputs

- `loss`: diagonal-positive cross entropy.
- `logits`: normalized query-key similarity matrix divided by temperature.
- `positive_logit_margin`: mean diagonal logit minus mean off-diagonal logit.
- `training_trace` when running the reduced update helper.

## Workflow

1. Encode skills as queries and transition tuples as keys with linear maps.
2. Normalize each query and key vector to unit length.
3. Compute `query @ key.T / temperature`.
4. Treat diagonal entries as positives and off-diagonal entries as negatives.
5. Compute cross entropy and positive-pair margin.
6. For reduced recovery, run the provided finite-difference gradient step and record parameter changes.

## Validation

Run:

```bash
python scripts/cic_loss.py --demo
python tests/test_cic_loss.py
```

## Limitations

The script is dependency-free and designed for tiny reduced recovery, not efficient full-scale RL training. A production implementation should use an autodiff framework such as PyTorch.

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…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.