Skip to content
Back to skills

Graph Structure Attention

ASecurity

Build graph-derived sparse attention masks for Graphically Structured Diffusion Model style recovery experiments and checks.

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

Works with

  • cli

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

Installs into .claude/skills of the current project.

Are you the author of Graph Structure Attention?

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

Security grade badge for Graph Structure Attention
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/vectorspacelab-graph-structure-attention/badge)](https://www.skillsdirectory.com/skills/vectorspacelab-graph-structure-attention)

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: graph_structure_attention
description: Build graph-derived sparse attention masks for Graphically Structured Diffusion Model style recovery experiments and checks.
---

# Graph Structure Attention

Use this skill when a task gives a graphical model or factor graph and you need the GSDM-style attention contract: one token per variable, self-attention on every token, symmetrized variable dependencies, and optional factor-clique attention.

Do not use this skill to learn graph structure from data. The paper assumes a supplied graphical-model sketch and uses it to constrain a diffusion denoiser.

## Inputs

- `nodes`: ordered variable ids.
- `edges`: directed or undirected pairs of variable ids.
- `factors`: optional lists of node ids that share an undirected factor.
- Optional BCMF dimensions `m`, `n`, and `k` for the paper's matrix-factorization graph.

## Outputs

- Dense boolean mask `mask`.
- Packed sparse representation with `attendable_indices` and `valid_indices_mask`.
- Node metadata and simple mask statistics.

## Workflow

1. Build or receive an ordered node list.
2. Add self-edges for all nodes.
3. Add graph edges in both directions.
4. For each factor scope, add all pairwise co-scope edges.
5. Pack each row of the mask to a fixed-width attendable-index array.
6. Use `scripts/graph_attention.py` for deterministic construction and validation.

## CLI

```bash
python scripts/graph_attention.py --bcmf 2 2 2 --output /tmp/gsdm_graph.json
```

## Validation

```bash
python -m pytest tests
```

The tests verify BCMF node counts, expected local dependencies, absence of unrelated edges, and round-trip reconstruction from packed sparse indices.

## Limitations

The skill validates the structural mask only. It does not implement transformer layers or train a diffusion model.

Files in this skill

  • SKILL.md1.8 KB
  • scripts/graph_attention.py4.9 KB
  • tests/test_graph_attention.py1.1 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.