✨ From vibe coding to vibe deployment. UBOS MCP turns ideas into infra with one message.

Learn more
Andrii Bidochko
  • Updated: June 11, 2026
  • 6 min read

Clark Hash: Stateless Sparse Johnson‑Lindenstrauss Quantization for Neural Embeddings

Direct Answer

Clark Hash introduces a stateless, sparse Johnson‑Lindenstrauss (JL) quantization codec that compresses neural embeddings to a fixed‑width, scalar‑quantized representation without any training or corpus‑level statistics. By shrinking a 384‑dimensional sentence vector from 1,536 bytes to just 48 bytes, it makes large‑scale embedding storage practical for multilingual AI systems while preserving cosine‑based similarity.

Background: Why This Problem Is Hard

Modern language models generate high‑dimensional floating‑point embeddings for every text fragment, image, or audio snippet. These vectors power search, recommendation, and retrieval pipelines, but their storage cost grows linearly with the number of items. A single million‑record corpus of 384‑dimensional float32 vectors consumes roughly 1.5 GB of RAM, which quickly becomes a bottleneck for latency‑critical services and edge deployments.

Existing compression strategies fall into two broad camps:

  • Learning‑based quantizers such as product quantization or residual quantization require a costly training phase, periodic re‑training as the data distribution drifts, and often rely on global codebooks that must be shared across all nodes.
  • Dimensionality‑reduction tricks like PCA or random projection can reduce size but typically need a pre‑computed rotation matrix, and the resulting vectors still need floating‑point storage or complex decoding logic.

Both approaches introduce operational overhead—training pipelines, versioning of codebooks, and additional latency for decoding—making them ill‑suited for fast‑moving production environments where new embeddings arrive continuously.

What the Researchers Propose

The Clark Hash method sidesteps these hurdles by combining three simple, deterministic steps into a single stateless codec:

  1. Normalization: Each incoming embedding is L2‑normalized, ensuring that cosine similarity can be approximated by a dot product on the compressed codes.
  2. Sparse Signed JL Projection: A deterministic, sparsely populated matrix with entries in {‑1, 0, +1} projects the normalized vector into a lower‑dimensional space. Because the matrix is fixed and sparse, the projection can be computed on‑the‑fly with negligible memory.
  3. Clipping & Scalar Quantization: The projected values are clipped to a small range and then uniformly quantized to an 8‑bit integer per dimension, yielding a fixed‑width byte string.

Crucially, the codec does not learn any parameters, store rotation matrices, or depend on corpus statistics. It is therefore truly stateless—any new vector can be encoded instantly, and the same decoder can reconstruct similarity scores without additional metadata.

How It Works in Practice

The end‑to‑end workflow can be visualized as a pipeline of independent modules:

  • Encoder Service: Receives a raw embedding from a model (e.g., multilingual MiniLM), normalizes it, applies the sparse JL matrix, clips, and quantizes. The output is a 48‑byte sketch that is written to a key‑value store.
  • Storage Layer: Stores the sketches as opaque blobs. Because each sketch has a constant size, indexing structures become trivial and memory fragmentation is eliminated.
  • Query Engine: Keeps the query vector in full‑precision floating point, runs the same JL projection (without quantization), and computes a dot product against each stored sketch. The dot product directly approximates the original cosine similarity.

What distinguishes Clark Hash from prior JL‑based compressors is the combination of sparsity and scalar quantization. The sparsity reduces the number of arithmetic operations per dimension, while the scalar quantization compresses the projected values to a single byte without needing a learned codebook.

Clark Hash illustration showing the encoding pipeline from raw embedding to 48‑byte sketch

Evaluation & Results

The authors benchmarked Clark Hash on a multilingual sentence‑similarity suite comprising 9,304 labeled pairs across 29 language subsets. Using a MiniLM encoder (384‑dimensional outputs), they compared three metrics:

  • Storage Reduction: 48 bytes per vector versus 1,536 bytes for dense float32 storage—a 32× compression factor.
  • Correlation with Dense Cosine: Macro Pearson correlation of 0.910 on the STS‑17 benchmark and 0.946 on STS‑22, indicating that the compressed sketches retain most of the semantic signal.
  • Latency: Encoding a vector takes under 0.2 ms on a single CPU core, and similarity scoring incurs less than 5 % overhead compared to dense dot‑product evaluation.

These results demonstrate that a stateless codec can achieve near‑dense quality while delivering massive storage savings and negligible computational cost. Importantly, the evaluation covered multiple languages, confirming that the method works uniformly across diverse scripts and tokenization schemes.

Why This Matters for AI Systems and Agents

Embedding compression is a silent enabler for any AI product that relies on large‑scale similarity search—think conversational agents that retrieve relevant knowledge snippets, recommendation engines that match user profiles, or multimodal search platforms that align text and images. By shrinking the storage footprint, Clark Hash makes it feasible to keep entire corpora in RAM, dramatically reducing latency for real‑time retrieval.

For AI agents that orchestrate multiple services, the stateless nature of the codec eliminates the need for a separate model‑training pipeline to maintain codebooks. This reduces operational complexity and aligns with the continuous‑learning paradigm where new embeddings are generated on the fly.

From a product perspective, the storage savings translate directly into lower cloud‑infrastructure costs. Companies can host larger knowledge bases on cheaper instances or even move the index to edge devices, enabling offline or low‑bandwidth scenarios.

Integrating Clark Hash into existing pipelines is straightforward. For example, the Chroma DB integration can store the 48‑byte sketches as vector payloads, while the Workflow automation studio can orchestrate the encoding step as a micro‑service within a larger AI workflow.

What Comes Next

While Clark Hash delivers impressive compression, several avenues remain open for exploration:

  • Adaptive Sparsity: Dynamically adjusting the sparsity pattern based on embedding distribution could further improve accuracy without sacrificing speed.
  • Hybrid Quantization: Combining scalar quantization with lightweight residual coding might close the remaining gap to dense cosine similarity.
  • Hardware Acceleration: Implementing the sparse JL projection on GPUs or specialized ASICs could push encoding latency below 0.1 ms, enabling high‑throughput streaming scenarios.
  • Broader Modalities: Extending the codec to image or audio embeddings, which often have higher dimensionality, would test the limits of the sparsity‑quantization trade‑off.

Practitioners interested in rapid prototyping can experiment with the open‑source Rust implementation and integrate it via the Enterprise AI platform by UBOS. For startups looking to embed this capability into a product, the UBOS for startups page offers a quick‑start guide and pricing details.

In summary, Clark Hash provides a practical, stateless codec for embedding compression that aligns with the operational realities of modern AI systems. Its blend of sparse Johnson‑Lindenstrauss projection and scalar quantization delivers a compelling balance of storage efficiency, speed, and semantic fidelity, opening the door to scalable multilingual sentence similarity at a fraction of the cost.

For a deeper dive into the methodology and experimental setup, consult the original Clark Hash paper.


Andrii Bidochko

CTO UBOS

Andrii Bidochko is an AI entrepreneur and researcher focused on AI agents, reinforcement learning, and autonomous systems. He writes about the technologies shaping the future of machine intelligence, from frontier models and agent architectures to real-world AI applications.

Sign up for our newsletter

Stay up to date with the roadmap progress, announcements and exclusive discounts feel free to sign up with your email.

Sign In

Register

Reset Password

Please enter your username or email address, you will receive a link to create a new password via email.