Traditional search engines use exact keyword matching (BM25 algorithms) to query data libraries. While fast, keyword indexing fails when querying concepts. If you search a research library for "local databases", a keyword index will miss articles that talk about "browser storage", "SQLite modules", or "offline-first architecture" unless those specific keywords are repeated.

With OmniBrief, our objective was to build a local semantic search engine capable of conceptual matching. By utilizing client-side vector embeddings and browser WebAssembly compiles, OmniBrief runs mathematical calculations locally inside your browser, completely offline, bypassing cloud databases entirely.

Key Technical Concepts Covered

  • Client-Side Embeddings: Running transformer models locally via ONNX pipelines.
  • MV3 Offscreen Documents: Working around service worker restrictions to load WebAssembly modules.
  • OPFS Storage: Saving 384-dimensional float arrays directly to system folders.
  • Cosine Similarity: Calculating array dot products in JavaScript.

Part of the engineering behind OmniBrief.

Tested with Chrome 149 (July 2026).

Porting Models with Transformers.js

To convert raw page content into dense multi-dimensional mathematical vectors, we used Xenova's transformers.js port. This framework allows developers to load pre-trained deep learning models in the browser using Microsoft's ONNX Runtime Web engine.

For OmniBrief, we utilized the all-MiniLM-L6-v2 model. This model outputs compact 384-dimensional floating-point vectors, striking a perfect balance between semantic accuracy and processing footprint (with a file footprint of only 23MB, which is permanently cached in browser memory on first boot).

The WebAssembly Barrier in MV3 Service Workers

In Google Chrome's Manifest V3 extension architecture, the central background process is a Service Worker. For security reasons, Chrome's Extension CSP blocks direct evaluation of WebAssembly (such as the ONNX compiler engine) inside service workers.

To bypass this restriction, OmniBrief utilizes Chrome's Offscreen Document API. The service worker spawns a silent, invisible HTML document (offscreen.html) whose window environment supports full WebAssembly compilation. Text strings are sent to the offscreen frame via messaging APIs, and the resulting vector float array is passed back:

// Creating the Offscreen Document in background.js
async function getOffscreenDocument() {
  const existingContexts = await chrome.runtime.getContexts({
    contextTypes: ['OFFSCREEN_DOCUMENT']
  });

  if (existingContexts.length > 0) {
    return;
  }

  await chrome.offscreen.createDocument({
    url: 'offscreen.html',
    reasons: ['WORKERS'], // Indicate WASM execution
    justification: 'Compute local vector embeddings'
  });
}

Inside the offscreen context, we initialize our embedding model:

// offscreen.js embedding pipeline
import { pipeline } from '@xenova/transformers';

let embedder;

async function getEmbedding(text) {
  if (!embedder) {
    embedder = await pipeline('feature-extraction', 'Xenova/all-MiniLM-L6-v2');
  }
  
  const output = await embedder(text, { pooling: 'mean', normalize: true });
  return Array.from(output.data); // Return array representation of 384 floats
}

Saving Vectors to the Origin Private File System (OPFS)

For fast, structured lookups, the generated float arrays must be stored on disk. Instead of writing them to chrome.storage.local (which degrades performance on large JSON datasets), OmniBrief writes them as binary files inside the browser's Origin Private File System (OPFS).

For each saved brief, the title, summary, and keywords vectors are written as separate files (e.g. summary_embedding.bin) in their corresponding page folder. When OmniBrief boots up, it reads these binary files directly into system RAM as a single flat typed array (Float32Array) for instant calculations.

Running Cosine Similarity Instantly

When a user inputs a query in the Search tab, OmniBrief vectorizes the query text locally, then calculates the Cosine Similarity between the query vector ($A$) and every stored document vector ($B$):

\[\text{similarity} = \frac{A \cdot B}{\|A\| \|B\|}(normalized)\]

Because the vectors are normalized during extraction, this equation simplifies to a simple dot product, which is executed instantly in JavaScript:

function calculateDotProduct(arrA, arrB) {
  let dotProduct = 0;
  for (let i = 0; i < arrA.length; i++) {
    dotProduct += arrA[i] * arrB[i];
  }
  return dotProduct;
}

Because the vectors are already resident in memory, scoring a typical local library - a few hundred to a few thousand briefs - completes in a few milliseconds, ordering results by relevance score and displaying match percentages dynamically. (Exact timing depends on library size, embedding dimension, and hardware.)

Conclusion: Fast, Secure Semantic Indexes

By compiling model engines to WebAssembly offscreen containers and performing vector math directly on-device, OmniBrief offers a fast, private semantic search system. Your research data stays precisely where it belongs-completely local to your machine.