Skip to content
Back to skills

Residual Joint Model

ASecurity

Compute residual EBM sequence scores and normalized importance weights from fixed LM proposal log probabilities and scalar energies.

  • 247 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 9, 2026
testingpythonbash

Security analysis

A100/100

Scanned September 9, 2026

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

Installs into .claude/skills of the current project.

Are you the author of Residual Joint Model?

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

Security grade badge for Residual Joint Model
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/vectorspacelab-residual-joint-model/badge)](https://www.skillsdirectory.com/skills/vectorspacelab-residual-joint-model)

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

SKILL.md
---
name: residual_joint_model
description: Compute residual EBM sequence scores and normalized importance weights from fixed LM proposal log probabilities and scalar energies.
---

# Residual Joint Model

Use this skill when implementing a residual energy-based text model where a fixed locally normalized language model proposes whole continuations and a sequence-level energy model corrects their probabilities.

Do not use this skill to train the base language model, normalize token-level vocabulary distributions, or read the original paper repository. It only handles sequence-level residual scoring and candidate-set normalization.

## Inputs

- `prefix`: context shared by all candidate continuations.
- `candidates`: records with `id`, `text`, optional `lm_logprob`, and required `energy`.
- Optional score mode:
  - `joint`: rank by `lm_logprob - energy`.
  - `energy`: rank by `-energy` when proposal log probabilities are unavailable.

## Outputs

- Per-candidate `joint_logscore` when `lm_logprob` is present.
- Per-candidate unnormalized and normalized importance weights proportional to `exp(-energy)`.
- Stable ranking and selected candidate id.

## Workflow

1. Keep base-LM log probabilities immutable. They represent the fixed proposal distribution from the paper.
2. Compute residual joint log scores as `lm_logprob - energy`.
3. Compute normalized importance weights with a log-sum-exp transformation over `-energy`.
4. Select by joint score when proposal log probabilities are available; otherwise select by normalized energy weight.
5. Record whether a result used full joint scoring or energy-only reweighting.

## Validation

Run:

```bash
python scripts/residual_joint.py --demo
python -m pytest tests
```

The tests verify exact score arithmetic, stable normalization, and deterministic selection.

## Limitations

Candidate-set normalization is not the full partition function over all text. It is valid as proposal-sample reweighting evidence or as a reduced proxy, not as a full perplexity claim unless the proposal sample size and estimator protocol match the paper target.

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.