Skip to content
Back to skills

Components

ASecurity

"Routes PyTorch Metric Learning questions about losses, miners,

  • 247 stars
  • 0 votes
  • 0 copies
  • 4 views
  • Added September 9, 2026
developmentangular

Security analysis

A100/100

Pro scans all 4 files and shows the line behind each finding

Scanned September 9, 2026

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

Installs into .claude/skills of the current project.

Are you the author of Components?

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

Security grade badge for Components
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/vectorspacelab-components/badge)](https://www.skillsdirectory.com/skills/vectorspacelab-components)

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

Download with Pro
SKILL.md
---
name: components
description: "Routes PyTorch Metric Learning questions about losses, miners,
  distances, reducers, regularizers, self-supervised wrappers, and custom
  component implementations."
disable-model-invocation: true
metadata:
  disco-role: operating
license: MIT
---

# Components

Use this sub-skill when the user needs to choose, combine, or customize the metric-learning primitives that sit below training and evaluation.

## Typical triggers

- "Which loss should I use for triplets, pairs, proxies, or self-supervision?"
- "How do I pick a miner for this batch?"
- "How do I swap the distance, reducer, or regularizer?"
- "Why does this loss need labels, a miner output, or `indices_tuple`?"
- "How do I write a custom loss or miner?"
- "Why am I getting no valid triplets, a distance-compatibility error, or a shape error?"

## In scope

- Distances: `LpDistance`, `CosineSimilarity`, `DotProductSimilarity`, `SNRDistance`, and `BatchedDistance`.
- Reducers: `MeanReducer`, `AvgNonZeroReducer`, `ThresholdReducer`, `DivisorReducer`, `PerAnchorReducer`, `MultipleReducers`, `DoNothingReducer`, `SumReducer`, `ClassWeightedReducer`.
- Regularizers: `LpRegularizer`, `CenterInvariantRegularizer`, `RegularFaceRegularizer`, `SparseCentersRegularizer`, `ZeroMeanRegularizer`.
- Miners: `TripletMarginMiner`, `MultiSimilarityMiner`, `BatchHardMiner`, `BatchEasyHardMiner`, `DistanceWeightedMiner`, `PairMarginMiner`, `AngularMiner`, `HDCMiner`, `UniformHistogramMiner`, `EmbeddingsAlreadyPackagedAsTriplets`.
- Loss families and wrappers: `TripletMarginLoss`, `ContrastiveLoss`, `MultiSimilarityLoss`, `NTXentLoss`, `AngularLoss`, `ArcFaceLoss`, `CosFaceLoss`, `NormalizedSoftmaxLoss`, `ProxyAnchorLoss`, `ProxyNCALoss`, `SelfSupervisedLoss`, `CrossBatchMemory`, `MultipleLosses`, `SmoothAPLoss`, `VICRegLoss`, and related metric/classification losses.
- Custom component authoring with `BaseMetricLossFunction`, `BaseMiner`, `loss_and_miner_utils`, and `TorchInitWrapper`.

## Out of scope

- Trainer setup, hooks, logging, and checkpointing belong in `training`.
- Accuracy calculators, testers, and nearest-neighbor inference belong in `evaluation`.
- Dataset download and sampler configuration belong in `data`.

## How to use this sub-skill

1. Start with `references/losses-miners-and-customization.md` for the compact component catalog and compatibility rules.
2. Run `scripts/smoke_components.py` on toy tensors when you need a quick sanity check for a component stack or a custom extension.
3. Read `references/troubleshooting.md` when the failure mentions labels, `indices_tuple`, no valid tuples, or an incompatible distance/reducer/regularizer.
4. For custom loss/miner implementations, follow the distilled extension patterns and use the bundled `loss_and_miner_utils` helpers instead of re-deriving tuple conversion logic.

## Common routing decisions

- If the user asks which loss or miner to use, stay here.
- If the user asks why a component rejects labels, margins, or tuple shapes, stay here.
- If the user asks how to wire the chosen component into a trainer or tester, route to `training` or `evaluation` after the component choice is settled.

## Useful public facts

- Most metric losses and miners accept a `distance` object.
- Some losses can be called with `indices_tuple` instead of labels when the tuple has already been mined.
- Classification-style losses typically need `num_classes` and `embedding_size`, and some require an optimizer for their class weights.
- `CrossBatchMemory` wraps another loss and adds queue behavior; `SelfSupervisedLoss` adapts a pair or tuple loss to two views.
- `MultipleLosses` and `MultipleReducers` require matching keys or parallel lists.

## Read next

- `references/losses-miners-and-customization.md` for the component catalog and extension notes.
- `references/troubleshooting.md` for predictable component-level failures.
- `scripts/smoke_components.py` for a tiny direct smoke check.

Files in this skill

  • SKILL.md3.9 KB
  • references/losses-miners-and-customization.md6.5 KB
  • references/troubleshooting.md3.1 KB
  • scripts/smoke_components.py1.9 KB

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.