⎈ re:dvx
representation engineering: dynamic vector xtension
extract · calibrate · steer · deploy
Website · ⟡ hyperplex
re:dvx turns a handful of contrastive examples into a calibrated, deployable behavioral control system for compatible Hugging Face causal LMs. The Python package is redvx; the command is dvx. Define a behavioral axis (sycophantic ↔ candid, expansive ↔ grounded, …), extract a control vector from the residual stream, sweep it to inspect a usable operating range, optionally calibrate a prefill policy from response judgments — then steer, fixed or dynamic, and export the whole thing as a standalone bundle.
⎈ score the final prompt position → decide before token 1 → steer toward the opposite pole
Gallery wizard defaults
Run dvx or dvx wizard for the guided flow. Each setting is shown before use. New runs default to Qwen3-32B at the gallery revision, bfloat16, RunPod with 80 GB, five user-chosen adjective pairs, 13 gallery prompts plus four generated/reviewed domain prompts, four persona templates and four repeng-derived single-token starts (272 pairs). Apple Silicon and local CUDA are offered after opbdh checks available memory.
The wizard records all layers at the supplied token, emits a separate 16-token screening continuation on both persona sides, and asks for contamination review. It then fits centered PCA (or mean differences), removes the leading common component using two or four axes, and unit-normalizes the residual. The default steering mask is zero-based 20–52 and 63 for Qwen3-32B. No layer sweep or dynamic detector runs by default.
You review a coefficient sweep, test more prompts/values, and choose limits; automatic suggestions stop before repetition, empty output or truncation, and are not semantic correctness guarantees. The two limits map independently to −1 and +1. A fixed-steering HTML gallery and per-message activation chat precede optional detector calibration. Dynamic calibration asks whether each unsteered response needed steering, compares two strengths, then regenerates a detector-controlled gallery until accepted.
redvx.wizard.json saves the flow. Fits, screening evidence and galleries live under artifacts/wizard/; remote extraction caches sync under artifacts/wizard_remote/. Export includes an activation-hook adapter, JSON API/chat, model revision, per-axis bounds, accepted detector policies, reports, Dockerfile and opbdh configuration. Base model weights remain unchanged; this is not a LoRA adapter. The dependency minimum includes opbdh’s local execution planner.
Command-line API
The wizard and scripted commands share redvx.workflow.Workflow, Protocol and WizardEngine. Both use the gallery defaults above. redvx.wizard.json contains the shared configuration and progress; its name is retained so existing gallery sessions resume.
- Explicit method choices: supplied-token or prefill extraction; centered PCA or mean differences; common-component removal or no projection; normalization before or after removal; recorded layer mask, model revision and precision.
- Seeded initial tokens: the default draws four distinct starts per query and reuses them across templates. Both poles share the same token.
prefix_assignment: pair_independentmakes an independent draw per contrast pair, with replacement, as a separate experimental condition. - Reviewed extraction:
dvx train --phase extractsaves screening evidence and a review template. Every pair needs a decision before--phase fit; accepting a flagged pair requires a reason. Baredvx trainexits with code 2 when review is pending. - Shared bounds and calibration: the supplied-token default uses a bidirectional sweep over
±{0.5, 1, 2, 3, 4, 5, 6, 9}, plus zero. Sweeps retain full responses. Both bounds must be tested on every sweep prompt. Optional response-judgment calibration uses the same score/activation interpolation in both interfaces; scripted acceptance is bound to the saved comparison receipt. - Portable inference:
dvx exportincludes an adapter, chat/API server, vendored runtime, pinned model revision, vectors, fit/review evidence and checksums. Imported research artifacts keep their recorded method and coefficient scale; explicit--vectorexport retains their artifact harness.
Inspect or edit the complete recipe with dvx recipe show and dvx recipe set --file recipe.json. After extraction, use a new project for a changed recipe. See PROCESS.md and EXPERIMENTS.md. Recorded runs and evaluation status are on the benchmarks page.
Install
pip install redvx
dvx --help
Remote GPU execution (RunPod or Prime Intellect via opbdh) ships in the default install — there is no redvx[remote] extra.
Apple Silicon installs require PyTorch 2.14 or newer. Earlier MPS sampling
could emit tokens with zero probability, producing stray language or code even
without steering (upstream issue).
When upgrading an existing environment, restart its Python processes. From a
source checkout, python scripts/check_mps_sampling.py checks the sampler without
loading a model; any out-of-support draw makes the command fail.
Select Apple Silicon explicitly and save it for this project's local commands:
dvx runtime apple-silicon --dtype bfloat16 --dir ./my-project
dvx runtime --dir ./my-project --json # device, dtype, PyTorch, recommended GPU memory
dvx train --dir ./my-project --phase extract # saved device and precision
dvx runtime auto restores automatic CUDA → MPS → CPU selection; cpu and
cuda can also be selected explicitly. An unavailable explicit accelerator
raises an error before loading weights. This setting affects local execution;
--remote continues to select a cloud GPU. The Python API exposes
redvx.local_torch_device("apple-silicon") and redvx.local_torch_dtype("bfloat16")
for callers loading their own models. Bfloat16 needs a compatible model and
backend (MPS requires macOS 14 or newer); check outputs and activations for your
model before comparing experiments across precisions. Existing projects keep
float32 unless changed explicitly with --dtype. Device and precision choices
are saved in the experiment fingerprint.
Exported bundles retain recorded model precision and revision. A
Qwen3-32B extraction record
includes the initial Apple Silicon checks and generation excerpts.
The suffix generator reuses a returned KV cache within each continuation and
falls back to full-prefix forwards when a model returns no cache. Saved recipes
identify this extraction protocol separately from earlier uncached runs.
For larger extraction runs, the Python API accepts
train_control_vector(..., activation_batch_size=8). It groups equal-length
inputs without adding padding and restores the original pair order. The default
remains one prompt per forward pass; custom models must support batching to use
a larger value.
From a source checkout, scripts/reviewed_vector_run.py prepare --dir PROJECT
creates checkpointed target/reference banks for an experiment with common-direction
projection. Inspect the full screening audit, then write artifacts/reviewed-run/review.json
with the exact bank_sha256 and a decisions list containing bank, query, and
a boolean accept for every query. The script's train --dir PROJECT phase
requires that review, reuses only accepted pairs, checks batched versus individual
activations, and retains the raw and projected vectors. These are extraction
artifacts; calibration and held-out behavioral evaluation are separate steps.
Quickstart
The guided application walks the gallery protocol interactively:
dvx wizard
Choose axes and adjectives, review prompts and extraction/deployment defaults, review contamination, fit/project vectors, calibrate bounds, inspect a fixed gallery, chat, optionally calibrate a dynamic detector, and export. For generated domain prompts the wizard builds the pair plan first and validates actual tokenizer boundaries once the backend is ready. A new model run is not required to inspect saved JSON/HTML artifacts.
Chat with saved gallery vectors
From the directory containing your project and its artifacts, run:
dvx chat
When gallery vectors are present and the project has no registered vectors, chat offers a numbered picker and loads the selected vector's recorded model, revision and precision. It discovers JSON writers under artifacts/**/vectors/ and vectors/, plus the saved unit-normalized gallery variants. Our current gallery checkout offers delinquent, sensual, independent, novelty, surreal and swashbuckling, with raw variants where exported. Switching between compatible vectors reuses the loaded model.
Type a message normally, or use these controls before your next message:
:axis choose another axis
:set delinquent 5 select delinquency at coefficient +5
:set -5 change the current coefficient
:base unsteered response (coefficient 0)
:reset start a fresh conversation
:quit exit
Saved gallery chat starts unsteered and retains conversation history until :reset. Positive and negative pole labels appear in the picker. Its coefficients are raw values applied to the saved write vectors: ±5 are the tested gallery strengths, not calibrated limits or normalized ±1 controls. A saved writer alone does not enable dynamic detection. Registered project chat continues to use its recorded vectors and calibration settings.
Use dvx chat --list to inspect available artifacts without loading model weights, --axis delinquent to skip the picker, or --dir /path/to/project to select another directory. From a source checkout, prefix these commands with uv run.
Local inference supports CUDA and Apple Silicon with enough memory. The current Qwen3-32B gallery uses bfloat16: weights alone need roughly 64 GB, plus runtime memory. It fits our BigMac setup, but not a 36 GB Mac. The saved-vector loader checks estimated capacity before loading weights; these commands do not provision cloud GPUs. A quantized model would need a separate check of steering behavior.
Interactive comparisons
dvx test --interactive
- Select one or more saved vectors by number or name.
- Compare them separately, or combine them in each response.
- Enter coefficients for each vector, or one weight per vector for each combination.
- Enter prompts one per line; finish with a blank line. Choose the output token budget (default 512).
Every prompt gets an unsteered baseline. Selected vectors must share a model, revision and precision; the model loads once for the run. The test uses the saved vectors directly, without extraction or detector calibration. Full outputs, including truncated responses, are retained with their coefficients and artifact fingerprints.
Results follow the normal dvx test output path: timestamped JSON under artifacts/runs/, an entry in redvx.project.json test history, and the updated dynamic_safety_report.html in the project directory. They also appear in dvx serve. Existing gallery files remain the frozen results of their original runs.
Optional flags include --stack to choose combined steering, --coeffs -5 5 to supply coefficients, --prompts "Your prompt" to seed the prompt list, --max-tokens 256, and --dir /path/to/project.
Or drive the same workflow as scripted stages:
dvx project init --name my-steering-project
dvx recipe show > recipe.json
# Edit target, model/revision, axes, prompts and method choices before compute.
dvx recipe set --file recipe.json
dvx train --phase extract
# Read each screening.json and fill every decision in its review.json.
dvx train --phase fit
dvx sweep --prompts "A calibration question" --coeffs -1 0 1
# Inspect complete outputs; choose tested values, not assumed useful limits.
dvx bounds --min -1 --max 1
dvx test --fixed --coeffs -1 1 # static: base vs vector, no detector needed
dvx test --prompts "A fresh final-test question"
dvx export --output-dir dist_bundle
python dist_bundle/serve.py --device cuda --chat
For optional dynamic calibration, collect at least four response judgments in a JSON array of {"prompt": "...", "activation": 0.0} objects. Include pass-through and steering cases; activation is within −1..1. Run dvx calibrate --feedback feedback.json, inspect the resulting full comparisons, then use the printed receipt with dvx calibrate --accept-review RECEIPT. The model recomputes scores; it does not trust supplied score values. The wizard provides interactive baseline/strength comparisons for the same operation.
Examples and reproducible recipes
dvx example list, dvx example use NAME and dvx example preview select an axis and inspect the shared recipe without loading weights. Preview pair counts are plans; tokenizer boundaries are validated during extraction. Examples carry rubrics and preservation checks, not efficacy promises.
Shared state records extraction, calibration/review and final-test prompts separately. dvx test --prompts ... requires fresh final-test prompts.
Every test prompt is tagged by source: topical (the axis's own topic prompts, trait-relevant by design), generic (the shipped neutral prompts) or custom (--prompts, counted as on-target). For each prompt the run measures how far the steered output drifted from the unsteered baseline and summarises on-target versus off-target drift as a selectivity verdict, on the console and in the report. Axes carry a kind: a behavior axis (sycophancy, compliance) should move topical prompts and leave generic ones roughly alone, so the verdict is selective, diffuse or inert; a style axis (register, character) is expected to touch every prompt, so broad drift reads as broad, not as a failure. Set it with dvx axis create --kind style or dvx axis edit NAME --kind style. dvx test --fixed runs the static comparison alone (base against the recorded vector at each --coeffs value, default the chosen bounds) with a selectivity verdict per coefficient; it needs no detector calibration. The drift measure is lexical and computed on short greedy continuations: a screen, not a result. Exact text separation does not detect related paraphrases: group prompt families manually for research. All outputs, including truncated responses, remain inspectable. The staged experiments and comparator libraries are specified in EXPERIMENTS.md.
Shared-workflow dvx chat starts at zero and takes --activation -1..1; :dynamic requires an accepted policy. --coeff and --interactive tests explicitly select raw saved-vector controls for exploratory comparisons.
As a library
The CLI is a thin layer; everything is importable. Set REDVX_QUIET=1 (or redvx.hx.QUIET = True) to silence the terminal chrome.
from redvx import (
DynamicControlPipeline, get_chat_triplets, run_parameter_sweep,
export_deployment_bundle,
)
from redvx.templates import build_templated_pair
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-0.5B-Instruct")
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2.5-0.5B-Instruct")
pairs = [build_templated_pair(tokenizer, u, pos, neg)
for u, pos, neg in get_chat_triplets("sycophancy_vs_candid")]
pipeline = DynamicControlPipeline.from_contrast_pairs(
model=model, tokenizer=tokenizer, pairs=pairs,
layer_ids=range(10, 16), max_coeff=2.0,
)
result = pipeline.generate("Tell me my plan is flawless.", max_new_tokens=60)
print(result.metadata) # {'last_score': …, 'last_coefficient': …, 'triggered_side': …, 'mode': 'prefill_gate'}
print(result.generated_text)
Command-line workflow
Configure with dvx recipe, extract/review/fit with dvx train, inspect full sweeps with dvx sweep, select tested limits with dvx bounds, optionally calibrate from response judgments, test on fresh prompts, then export. Both CLI and wizard call the shared stages. The lower-level Python functions above retain explicit research alternatives and do not define the shared workflow defaults.
Custom axes and templates
Seed an axis's banks at creation time, then append more entries later without replacing what is already there. Both bank options are repeatable:
dvx axis create courteous_vs_rude \
--positive courteous --negative rude \
--adjective-pair courteous rude \
--adjective-pair gracious abrasive \
--topic-prompt "How should a host respond to an unexpected guest?"
dvx axis edit courteous_vs_rude \
--adjective-pair considerate dismissive \
--topic-prompt "What is a tactful way to correct someone?"
The shared recipe's templates array contains the exact persona templates used for extraction. Inspect it with dvx recipe show, edit the JSON, and load it with dvx recipe set --file recipe.json. Each string must contain {adjective} exactly once. The older templates.json helpers remain available to low-level research callers.
Live project server
dvx serve --open # http://127.0.0.1:7333
dvx serve opens a local project viewer and /examples recipe editor. Shared projects edit the same recipe JSON used by wizard and commands. Saving a recipe schedules no compute. The stdlib server is intended for local use.
How dynamic control works
- Score the unmodified final prompt state against the saved axis.
- Fit a piecewise-linear score/activation mapping from judgments of untreated and corrected responses, including pass-through cases.
- Review the controller's outputs and accept the policy. It maps to normalized −1..1, with each pole scaled to its chosen raw bound, then holds that coefficient through the response.
The score is not a probability, and holding a coefficient fixed does not guarantee coherence. Predictive validity and quality preservation need independent tests. Lower-level threshold controllers and independent corrective writers remain available for the experiments described in RESEARCH.md.
Development
git clone https://github.com/lumpenspace/redvx && cd redvx
uv sync --extra dev
uv run pytest # full suite, no GPU or network required
The website lives in web/ (Vite + React, deployed by the Pages workflow):
cd web && npm install && npm run dev # local preview; `npm run build` emits web/dist
⎈ re:dvx · Website · ⟡ hyperplex
Metadata
Release files for redvx 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| redvx-0.1.0.tar.gz | 268.4 kB | With provenance | Details for redvx-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| redvx-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for redvx-0.1.0-py3-none-any.whl |
Total release size: 567.8 kB
Release files / redvx-0.1.0.tar.gz
| Download URL | redvx-0.1.0.tar.gz |
|---|---|
| Size | 268.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5f50b85f34079243e7f7ad94fb87b3842825dae1043e0ea3a51717bac61c4c9f
|
|
BLAKE2b-256 checksum How to use checksums |
2fc6155704c796608c5647bf8ce4d47febbba72cc14badb2685edabdc6f8dd5d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.
Transparency logRelease files / redvx-0.1.0-py3-none-any.whl
| Download URL | redvx-0.1.0-py3-none-any.whl |
|---|---|
| Size | 299.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d33b875447a9c66ace0916c020748976668c6dca85a94b5103bddbe2aa148df4
|
|
BLAKE2b-256 checksum How to use checksums |
0f6d2864169269e2e25e76238c8c827c13a59573303a40f56e9695ba7e6459b3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.
Transparency logSecurity for redvx 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for redvx-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.