跪拜 Guibai
← All articles
JavaScript · Frontend

A Decorative DSH Plugin Turns Every AI Prompt Into a Unique, Spinning Nebula

By 风卿 ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

For teams building on DeepSeek Harness, this plugin shows how far a purely cosmetic feature can go with deterministic hashing and Canvas 2D, and it provides a clean reference for adding privacy-conscious, offline visualizations to a web tool without pulling in heavy ML dependencies.

Summary

dsh-spiral adds a small floating window to the DeepSeek Harness web GUI. When you press Enter, the prompt is hashed through a deterministic pipeline: n-gram features are projected into 8192 hash buckets, smoothed with an FFT Gaussian kernel, and folded into a 256-segment brightness profile that modulates a pre-generated particle field on a Canvas 2D nebula. A separate semantic footprint map records the history of submissions as a trajectory.

The design deliberately avoids semantic modeling: no model files, no network requests, no reading of input beyond the submit event, and all computation stays in the browser. The 130 KB bundle runs at about 0.8 ms per analysis. The plugin respects prefers-reduced-motion, pauses when the tab is hidden, and responds to CSS theme tokens. The author openly lists the limitations: hash collisions, lossy quantization, and a fixed palette mean the galaxy is a reproducible visual fingerprint, not a mathematically unique identifier.

Takeaways
— The plugin uses a deterministic hash embedding pipeline: NFKC normalization, n-gram features, 8192 hash buckets, FFT Gaussian smoothing, and L2 normalization.
— The 8192-dimensional spectrum is not 8192 light points; it is folded into a 256-segment brightness profile that modulates a fixed set of roughly 1100 particles.
— Switching between the 8192 and 5120 performance settings only changes particle density (880 to 545 arm particles), not the computed geometry.
— The same prompt always produces the same galaxy profile and coordinates because no Math.random() affects the core algorithm.
— The plugin never reads input box content while typing; it captures only on submit, and persists data to localStorage as base64.
— The full pipeline runs in about 0.8 ms per analysis on a local machine, and the canvas sustains 60 fps on a 520×352 viewport.
— The color scheme is limited to 6 schemeBase values mapped to 4 color families across 3 palettes, so colors repeat by design.
— The author replaced an initial plan to run a local bge-small-zh-v1.5 ONNX model with a hash-based approach to keep the plugin zero-dependency and privacy-preserving.
Conclusions

The plugin's honesty about its limitations is more useful than its visual appeal: it explicitly labels the output as a visual fingerprint, not a semantic or unique identifier, which sets realistic expectations for users.

Choosing a fixed random projection over UMAP means the footprint map loses any claim to semantic proximity, but the author argues the trade-off is right for a decorative feature that must never leak data or require user trust.

The distinction between the 8192-dim spectrum, the 256-segment profile, and the constant particle count is a good example of how visual complexity can be driven by a compact control signal rather than by data volume.

By keeping the embedding function isolated in analyze(), the code makes it trivial to swap in real semantic embeddings later without touching the rendering or storage layers.

Concepts & terms
Deterministic hash embedding
A technique that maps text to a fixed-length vector using hash functions and feature weighting, without any learned model. It guarantees that identical inputs produce identical outputs, but does not capture semantic similarity.
FFT Gaussian smoothing
Applying a Gaussian filter to a signal by multiplying its Fourier transform with the transform of a Gaussian kernel, then inverse transforming. It spreads discrete impulses into continuous, blurred peaks efficiently.
Fixed random projection
Projecting a vector onto a small number of random basis vectors that are fixed in advance (here, Rademacher vectors). It maps high-dimensional data to a lower-dimensional space while approximately preserving distances, but without learning from data.
Source: juejin.cn ↗ Google Translate ↗ Backup ↗