Skip to content
Back to skills

Bbvi Score Function Gradient

ASecurity

Compute black-box variational inference score-function ELBO gradient estimates from samples, log-density values, and variational score functions.

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

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 bbvi_score_function_gradient --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Bbvi Score Function Gradient?

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

Security grade badge for Bbvi Score Function Gradient
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/vectorspacelab-bbvi-score-function-gradient/badge)](https://www.skillsdirectory.com/skills/vectorspacelab-bbvi-score-function-gradient)

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: bbvi_score_function_gradient
description: Compute black-box variational inference score-function ELBO gradient estimates from samples, log-density values, and variational score functions.
---

# BBVI Score-Function Gradient

## When To Use

Use this skill when implementing or auditing the core Black Box Variational Inference estimator from Ranganath, Gerrish, and Blei. It applies when you can sample from `q(z | lambda)`, evaluate `log p(x,z)`, evaluate `log q(z | lambda)`, and compute `grad_lambda log q(z | lambda)`.

Do not use it for pathwise/reparameterization gradients or for optimizer updates.

## Inputs

- `logp`: list of scalar log-joint values, one per sample.
- `logq`: list of scalar variational log-density values, one per sample.
- `score`: list of score values. A one-dimensional list represents one scalar parameter; a two-dimensional list represents sample-by-parameter scores.

## Outputs

- `learning_signal`: `logp - logq` for each sample.
- `gradient_terms`: per-sample score-function gradient terms.
- `gradient_estimate`: Monte Carlo average over samples.
- `diagnostics`: sample count, parameter dimension, and finite-value status.

## Workflow

1. Normalize score arrays to sample-by-parameter shape.
2. Validate matching sample counts and finite numeric values.
3. Compute per-sample learning signals.
4. Multiply each score row by its learning signal.
5. Average across samples to estimate the ELBO gradient.

## Validation

Run:

```bash
python tests/test_score_gradient.py
```

## Limitations

This skill does not reduce estimator variance and does not know model structure. Use a variance-reduction skill for Rao-Blackwellization and control variates.

Files in this skill

  • SKILL.md1.7 KB
  • scripts/score_gradient.py2.4 KB
  • tests/test_score_gradient.py993 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.