Run this model with HF Jobs
Run nmysore/attention-manifolds on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/nmysore/attention-manifolds. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/nmysore/attention-manifolds on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use nmysore/attention-manifolds with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use nmysore/attention-manifolds with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("nmysore/attention-manifolds", device_map="auto") - Notebooks
- Google Colab
- Kaggle
SplineQK-3B: Learned B-Spline Coordinate Curves for Llama-3.2-3B-Instruct
Per-coordinate B-spline curves on Q/K projections for mechanistic interpretability and AI safety research.
What is this?
This adapter wraps every Q and K projection coordinate in Llama-3.2-3B-Instruct with a learned cubic B-spline curve. The original linear projection is frozen; the spline reshapes each coordinate independently.
- Identity initialization:
f(z) = zβ the augmented model reproduces standard attention exactly before training - Trained on Wikipedia: 1.8M spline coefficients learned with next-token prediction, all 3.2B backbone weights frozen
- PPL improvement: 11.91 β 11.09 (6.9% reduction)
- KV cache compatible: wraps projections, does not monkeypatch attention
- Intervention interface: scale or negate learned curves to study model behavior
AI Safety & Interpretability
The learned curves encode safety-relevant behavior that can be inspected and modified:
- Scaling the curves monotonically shifts refusal/compliance rates across safety-sensitive prompts
- Negating the curves reverses trained safety behavior while preserving benign prompt quality
- Per-layer analysis reveals distributed safety encoding across all 28 layers
- Local support: each B-spline coefficient affects only a bounded activation interval
See the paper and code for details.
Quick Start
from transformers import AutoModelForCausalLM, AutoTokenizer
from spline_qk import load_splines
model = AutoModelForCausalLM.from_pretrained(
"meta-llama/Llama-3.2-3B-Instruct",
dtype=torch.float32, attn_implementation="eager"
).eval()
tokenizer = AutoTokenizer.from_pretrained("meta-llama/Llama-3.2-3B-Instruct")
# Load trained spline curves
load_splines("nmysore/spline-qk-3b/trained", model)
Interactive Inference with Interventions
python interactive_infer.py \
--checkpoint trained --calibrated calibrated \
--device cuda
Commands: /sweep <prompt>, /sensitivity <prompt>, /negate-all, /scale -1.0 0 3 6
Files
trained/β Best checkpoint (epoch 3, PPL 11.09), 28 layer files + manifestcalibrated/β Identity-initialized checkpoint for intervention baselines
Training Details
| Parameter | Value |
|---|---|
| Base model | Llama-3.2-3B-Instruct |
| Layers adapted | All 28 |
| Basis functions | 16 per curve (cubic) |
| Trainable params | 1,835,008 |
| Training data | Clean Wikipedia |
| Block size | 512 |
| Epochs | 3 |
| Optimizer | AdamW (lr=0.001) |
| Device | 1ΓA100 80GB |
Citation
@article{mysore2026splineqk,
title={Learned B-Spline Coordinate Curves for Transformer Attention},
author={Mysore, Naveen},
journal={arXiv preprint},
year={2026}
}
Model tree for nmysore/attention-manifolds
Base model
meta-llama/Llama-3.2-3B-Instruct