Skip to content
Back to skills

Random Layer Mapping

ASecurity

Sample and audit RAIL-KD random teacher-to-student intermediate layer mappings for bounded knowledge distillation experiments.

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

Security analysis

A100/100

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

Scanned September 9, 2026

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

Installs into .claude/skills of the current project.

Are you the author of Random Layer Mapping?

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

Security grade badge for Random Layer Mapping
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/vectorspacelab-random-layer-mapping/badge)](https://www.skillsdirectory.com/skills/vectorspacelab-random-layer-mapping)

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: random_layer_mapping
description: Sample and audit RAIL-KD random teacher-to-student intermediate layer mappings for bounded knowledge distillation experiments.
---

# Random Layer Mapping

Use this skill when implementing or checking the RAIL-KD layer-selection mechanism. It is appropriate for transformer distillation or proxy experiments that need to select `m` teacher intermediate layers from an `n`-layer teacher at each epoch and align them with `m` student layers. Do not use it for deterministic PKD/CKD mapping search or attention-over-all-layers methods.

## Inputs

- `teacher_layer_count`: positive integer `n`.
- `student_layer_count`: positive integer `m`, with `m <= n`.
- `seed` and optional `epoch`: reproducibility controls.
- `sort_indices`: keep true for the paper-faithful monotonic alignment.

## Outputs

- A list of distinct zero-based teacher layer indices.
- Student-to-teacher mapping pairs.
- Optional coverage counts over repeated epochs.

## Workflow

1. Validate layer counts before sampling.
2. Use seeded random sampling without replacement to choose exactly `m` teacher layers.
3. Sort the selected teacher layers before pairing with student layers unless a diagnostic explicitly needs unsorted samples.
4. Pair student layers `0..m-1` with the selected teacher indices.
5. For multi-epoch experiments, record mappings and coverage so analysis can verify that randomization was exercised.

## Validation

Run:

```bash
python scripts/rail_mapping.py --teacher-layers 12 --student-layers 6 --epochs 4 --seed 13
python -m pytest tests
```

The tests are standard-library compatible through the Distiller simple test runner.

## Limitations

The script only handles mapping selection and audit statistics. It does not compute hidden-state losses, logits KD, or optimizer updates. Indexing is zero-based; convert explicitly if a downstream framework reports one-based layer numbers.

Files in this skill

  • SKILL.md1.9 KB
  • scripts/rail_mapping.py2.5 KB
  • tests/test_rail_mapping.py1015 B

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.