Browse · People
Person · Latent Space wiki

Joshua Lochner

Creator of Transformers.js, bringing pretrained machine-learning models into browsers and JavaScript applications.

Joshua Lochner, known as Xenova, created Transformers.js, a JavaScript library for running pretrained machine-learning models locally in the browser. He joined Hugging Face in 2023. His work includes browser inference, model precision controls and collaboration with ONNX Runtime to support GPU acceleration across JavaScript environments.[2][3][5][4][6]

Optimizing local inference

In the February 9, 2026 v4 announcement, coauthored with Nico Martin, Lochner described a shift toward making local models run faster in resource-constrained environments. The release adopted a new WebGPU runtime rewritten in C++, developed by the ONNX Runtime team, and enabled GPU-accelerated execution in browsers, Node.js, Bun and Deno. The teams worked closely to test the runtime across supported model architectures.[6]

That performance work required changing how models were exported: the team reimplemented new models operation by operation, using specialized ONNX Runtime operators for attention, low-bit matrix multiplication and mixture-of-experts models. Lochner and Martin reported an approximately fourfold speedup for BERT-based embedding models after adopting com.microsoft.MultiHeadAttention.[6]

The release also addressed the cost of maintaining a growing library. The team split an over-8,000-line models.js file into focused modules and adopted pnpm workspaces so smaller dependent packages could share the core without separate repositories. ModelRegistry made required files, download metadata and cache status visible before loading; a standalone tokenizers library answered users’ requests to use tokenization independently of Transformers.js.[6]

These later runtime and maintenance decisions followed a much smaller initial project: getting Lochner’s own spam classifier into a browser extension.[5][6]

Origins and early decisions, 2023

At JSNation in June 2025, Lochner recalled creating a pretrained spam classifier in his spare time and wanting to run it as a browser extension. He judged the available tooling unsuitable: “So the next logical step was to do it myself.” His June 2023 presentation to the WebML Working Group likewise identified removing spam YouTube comments as the project’s origin.[5][3]

Lochner dated Transformers.js v1 to March 2023 and described v2, roughly two months later, as a rewrite from CommonJS to ECMAScript modules. He attributed the initial CommonJS choice partly to his inexperience as a developer coming from Python and machine learning. In his 2025 account, the switch improved support for workers and let him develop faster and more efficiently.[5]

On June 8, 2023, Lochner presented the library to the WebML Working Group to inform WebNN feature discussions. His workflow was to convert a model to ONNX with Hugging Face Optimum, write JavaScript and execute it through ONNX Runtime Web. At that time, he identified CPU speed, Wasm’s 4GB memory-addressing limit, model caching and missing tensor APIs as constraints. He wanted NumPy-like browser APIs for pre- and post-processing, including control over image-resizing interpolation, and named WebGPU support as his next major priority.[3]

WebGPU and precision controls, 2024

Lochner’s October 22, 2024 v3 announcement delivered WebGPU support through collaboration with ONNX Runtime Web. Developers could select GPU execution by setting device: 'webgpu' when loading a model. The release also replaced a simple quantized-or-full-precision choice with a broader dtype parameter, with available formats depending on the model.[4]

Per-module precision settings addressed a specific problem: encoders in models such as Whisper and Florence-2 can be especially sensitive to quantization. Developers could therefore assign different precision types to different components instead of applying one setting throughout. The same release moved the NPM package from @xenova/transformers to @huggingface/transformers and the repository into Hugging Face’s GitHub organization.[4]

Public views on browser AI

In the June 2023 Latent Space discussion, Lochner treated cheaper hosted embeddings and local embeddings as serving different use cases. He welcomed price reductions for projects embedding large amounts of data while arguing that client-side generation still had a role where sensitive data or repeated network requests made local execution useful.[1]

By June 2025, his guidance emphasized choosing models for users’ actual hardware, bandwidth and browser capabilities. He encouraged quantization to reduce downloads and runtime memory consumption while weighing accuracy against speed. He also described Transformers.js as an inference component: developers could use its model outputs and build surrounding tools and control logic to create agentic applications.[5]

Timeline

  1. role

    Joins Hugging Face
    Hugging Face[5]

  2. release

    Releases the first version of Transformers.js
    Transformers.js v1[5]

From the Latent Space archive

Original posts and separately reviewed explanations.

Sources

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6

Model source and teaching reviews passed. Human editorial review pending. This profile describes the sources as of 2026-09-17.

Latent Space

Join Latent Space.

Sign in with Google, or get the newsletter by email.

Loading Google sign-in…

or subscribe by email

Free. Unsubscribe any time.