LiteRT.js, Google's high performance Web AI Inference

JULY 9, 2026
Ping Yu Software Engineer
Marko Ristić Software Engineer
Matthew Soulanille Software Engineer
Chintan Parikh Product Manager

We are excited to announce LiteRT.js, a JavaScript binding of LiteRT for running AI directly inside the web browser. By bringing the trusted on-device inference library LiteRT to the web, web developers can now run ML and AI models with maximum performance entirely locally. This means enhanced user privacy, zero server costs, and ultra-low latency for real-time experiences. For developers with existing .tflite models, LiteRT.js makes deployment to mobile and desktop web browsers smoother than ever, serving as a powerful evolution from TensorFlow.js for executing .tflite models.我们激动地宣布 LiteRT.js,它是 LiteRT 的 JavaScript 绑定,用于在 Web 浏览器中直接运行 AI。通过将备受信赖的端侧推理库 LiteRT 引入 Web,开发者现在可以在本地以最高性能运行机器学习和 AI 模型。这意味着更强的用户隐私保护、零服务器成本以及实时体验的超低延迟。对于拥有现有 .tflite 模型的开发者,LiteRT.js 使部署到移动和桌面浏览器比以往更加顺畅,成为 TensorFlow.js 执行 .tflite 模型的有力演进。

While prior web AI solutions like TensorFlow.js relied on less performant JavaScript-based kernels, we are now making our native, cross-platform runtime with all its optimizations directly available to web developers through WebAssembly. LiteRT.js unlocks impressive performance by running your .tflite models directly in the browser leveraging the state-of-the-art hardware acceleration of LiteRT, including XNNPACK for CPU, ML Drift for GPU, and the upcoming WebNN for NPUs.虽然以往像 TensorFlow.js 这样的 Web AI 解决方案依赖性能较低的基于 JavaScript 的内核,但我们现在通过 WebAssembly 将我们原生的跨平台运行时及其所有优化直接提供给 Web 开发者。LiteRT.js 通过直接在浏览器中运行您的 .tflite 模型,并利用 LiteRT 最先进的硬件加速(包括用于 CPU 的 XNNPACK、用于 GPU 的 ML Drift 以及即将推出的用于 NPU 的 WebNN),实现了令人印象深刻的性能。

Our initial release provides all the tools needed to get started, including the new LiteRT.js npm package and a collection of demos showcasing real-world implementation.我们的初始版本提供了所有入门所需的工具,包括新的 LiteRT.js npm 包以及一系列展示实际实现的演示。

How LiteRT.js benefits web developersLiteRT.js 如何惠及 Web 开发者

With LiteRT.js, web developers can integrate models into their apps written in JavaScript or TypeScript to handle complex tasks like text generation, object detection, and audio processing entirely client-side. As LiteRT.js shares a unified cross-platform stack with LiteRT, your web applications automatically benefit from the latest performance upgrades, quantization improvements, and hardware optimizations developed for Android, iOS, and desktop.借助 LiteRT.js,Web 开发者可以将模型集成到用 JavaScript 或 TypeScript 编写的应用中,完全在客户端处理文本生成、物体检测和音频处理等复杂任务。由于 LiteRT.js 与 LiteRT 共享统一的跨平台栈,您的 Web 应用会自动受益于为 Android、iOS 和桌面开发的最新性能升级、量化改进和硬件优化。

By leveraging LiteRT's lowering flow and runtime, you get simple conversion of models from a variety of Python ML frameworks and native hardware acceleration across all major accelerators (CPU / GPU / NPU). To help you unlock these AI capabilities easily, here are the main highlights of LiteRT.js:通过利用 LiteRT 的降级流程和运行时,您可以轻松转换来自多种 Python 机器学习框架的模型,并在所有主要加速器(CPU/GPU/NPU)上获得原生硬件加速。为帮助您轻松解锁这些 AI 能力,以下是 LiteRT.js 的主要亮点:

1.PyTorch conversion & tailored quantization1. PyTorch 转换与定制量化

With LiteRT Torch, PyTorch models can be converted in a single step, making them instantly ready to leverage advanced browser-based hardware acceleration. Get started today by following the LiteRT Torch guide.通过 LiteRT Torch,PyTorch 模型可以一步转换,立即准备好利用先进的基于浏览器的硬件加速。立即按照 LiteRT Torch 指南开始使用。

For further optimization, AI Edge Quantizer allows you to configure tailored quantization schemes across different model layers. This achieves substantial size reductions and performance gains while preserving overall model quality. Explore the quantization colab to see this in action.为了进一步优化,AI Edge Quantizer 允许您在不同模型层配置定制量化方案。这可以在保持整体模型质量的同时,实现显著的尺寸缩减和性能提升。探索量化 Colab 以查看实际效果。

2.Native hardware acceleration across CPU, GPU, and NPU2. 跨 CPU、GPU 和 NPU 的原生硬件加速

LiteRT.js enables high-performance AI inference for a diverse variety of hardware backends.LiteRT.js 为多种硬件后端提供高性能 AI 推理。

  • CPU: utilizes XNNPACK, Google's highly optimized library for on-device CPU acceleration, providing robust multi-thread support and a relaxed SIMD build for enhanced performance.CPU:利用 XNNPACK,这是 Google 用于端侧 CPU 加速的高度优化库,提供强大的多线程支持和宽松的 SIMD 构建,以增强性能。
  • GPU: powered by ML Drift, Google's leading solution for on-device GPU acceleration. LiteRT.js leverages WebGPU to enable state-of-the-art GPU acceleration on the web.GPU:由 ML Drift 驱动,这是 Google 领先的端侧 GPU 加速解决方案。LiteRT.js 利用 WebGPU 在 Web 上实现最先进的 GPU 加速。
  • NPU: harnesses the emerging WebNN API (currently experimental in Chrome and Edge) to target dedicated NPUs for power-efficient, ultra low-latency inference.NPU:利用新兴的 WebNN API(目前在 Chrome 和 Edge 中为实验性),针对专用 NPU 实现高能效、超低延迟推理。

Ready to accelerate your web applications? Dive into the LiteRT.js documentation to get started.准备好加速您的 Web 应用了吗?深入了解 LiteRT.js 文档开始使用。

diagram1
LiteRT.js Architecture Overview LiteRT.js 架构概述

Performance and real-world impact性能与现实世界影响

To demonstrate the real-world impact of the unified runtime and hardware-accelerated backends, we evaluated LiteRT.js against existing web solutions. Across classical computer vision and audio processing models, LiteRT.js delivers significant speedups—outperforming other web runtimes by up to 3x across both CPU and GPU inference.为了展示统一运行时和硬件加速后端的实际影响,我们针对现有的 Web 解决方案评估了 LiteRT.js。在经典的计算机视觉和音频处理模型中,LiteRT.js 实现了显著的加速——在 CPU 和 GPU 推理上均比其他 Web 运行时快达 3 倍。

Benchmarking w_ yolo26n 1600x900
Note: Performance benchmarks conducted on a 2024 Apple MacBook Pro with M4 Apple Silicon in a controlled browser environment. Individual user performance may vary based on local GPU capabilities, thermal throttling, and browser driver optimization. 注意:性能基准测试在受控浏览器环境中使用配备 M4 Apple Silicon 的 2024 款 Apple MacBook Pro 进行。个人用户性能可能因本地 GPU 能力、热降频和浏览器驱动优化而异。

To ground these claims in real-world efficiency, we benchmarked popular AI models using LiteRT.js across three distinct web execution backends: CPU (via XNNPACK), WebGPU, and WebNN (via Apple CoreML). For demanding real-time applications like object tracking, audio transcription, or image manipulation, leveraging the GPU or NPU via WebGPU or WebNN delivers 5-60x speedup compared to standard CPU execution, ensuring lower latency without compromising performance.为了将这些声明建立在真实效率之上,我们使用 LiteRT.js 对流行 AI 模型进行了基准测试,覆盖三种不同的 Web 执行后端:CPU(通过 XNNPACK)、WebGPU 和 WebNN(通过 Apple CoreML)。对于物体跟踪、音频转录或图像处理等要求苛刻的实时应用,通过 WebGPU 或 WebNN 利用 GPU 或 NPU,与标准 CPU 执行相比可实现 5-60 倍的加速,确保更低延迟而不影响性能。

Classical model perf (1)
Note: Performance benchmarks conducted on a 2024 Apple MacBook Pro with M4 Apple Silicon in a controlled browser environment. Individual user performance may vary based on local GPU capabilities, thermal throttling, and browser driver optimization.

See it in action查看实际效果

To see LiteRT.js in action, explore our live implementations. LiteRT.js demo source code is available on the LiteRT GitHub repository and via Ultralytics.要查看 LiteRT.js 的实际效果,请探索我们的实时实现。LiteRT.js 演示源代码可在 LiteRT GitHub 仓库和 Ultralytics 上获取。

LiteRT Ultralytics YOLO integrationLiteRT Ultralytics YOLO 集成

Ultralytics is an artificial intelligence company that specializes in building computer vision tools and models. It is best known as the creator of the YOLO (You Only Look Once) framework, family of real-time object detection and image segmentation models.Ultralytics 是一家专注于构建计算机视觉工具和模型的人工智能公司。它最为人所知的是作为 YOLO(You Only Look Once)框架的创造者,该框架是一系列实时物体检测和图像分割模型。

We are excited to share official LiteRT export support built directly into the Ultralytics Python package. Easily deploy Ultralytics YOLO models across mobile, edge, and browsers—and go from compilation to runtime in just a few lines of code.我们很高兴地分享,Ultralytics Python 包中直接内置了官方 LiteRT 导出支持。轻松将 Ultralytics YOLO 模型部署到移动端、边缘设备和浏览器——只需几行代码即可从编译到运行时。

Demo: YOLO26, family of real-time vision models演示:YOLO26,实时视觉模型系列

Depth Estimation深度估计

Depth Anything - monocular depth estimation showcases how to transform a standard webcam feed into an interactive 3D point cloud in real-time. Powered by LiteRT.js via WebGPU, it uses the Depth-Anything-V2 model to instantly calculate depth data and map video pixels into a responsive 3D space.Depth Anything - 单目深度估计展示了如何将标准网络摄像头流实时转换为交互式 3D 点云。由 LiteRT.js 通过 WebGPU 驱动,它使用 Depth-Anything-V2 模型即时计算深度数据,并将视频像素映射到响应式 3D 空间。

Demo: Monocular depth estimation using DepthAnything and WebGPU.演示:使用 DepthAnything 和 WebGPU 的单目深度估计。

Image Upscaling图像放大

Upscale images by 4x in the browser using the Real-ESRGAN model with LiteRT.js, which works by upscaling 128x128 pixel patches to 512x512 which are then reassembled into the final image.使用 LiteRT.js 和 Real-ESRGAN 模型在浏览器中将图像放大 4 倍,其工作原理是将 128x128 像素的块放大到 512x512,然后重新组合成最终图像。

Get started with LiteRT.js开始使用 LiteRT.js

Integrating LiteRT.js into your development workflow is straightforward, whether you’re launching a fresh implementation or migrating an existing application to our high-performance runtime. LiteRT.js abstracts the complexities of hardware-level optimization, enabling you to deliver responsive, privacy-focused experiences without the overhead of manual platform tuning.将 LiteRT.js 集成到您的开发工作流程中非常简单,无论您是启动全新实现还是将现有应用迁移到我们的高性能运行时。LiteRT.js 抽象了硬件级优化的复杂性,使您能够提供响应迅速、注重隐私的体验,而无需手动调整平台的开销。

The following snippet highlights the streamlined process for initializing, compiling, and running a .tflite model with GPU acceleration. Using clean, modern JavaScript, you can load your model, feed input tensors, and capture high-speed inference results in real-time. For more detailed instructions, demos, and guidance, please refer to our documentation here.以下代码片段展示了使用 GPU 加速初始化、编译和运行 .tflite 模型的简化流程。使用简洁现代的 JavaScript,您可以加载模型、输入张量,并实时捕获高速推理结果。有关更详细的说明、演示和指导,请参阅我们的文档。

import { loadLiteRt, loadAndCompile, Tensor } from '@litertjs/core';

await loadLiteRt('path/to/wasm/directory/');

const model = await loadAndCompile('path/to/your/model.tflite',{ accelerator: webgpu });

const inputTypedArray = new Float32Array(1 * 3 * 244 * 244);

const inputTensor = new Tensor(inputTypedArray, [1, 3, 244, 244]);

const results = await model.run(inputTensor);

// results is a Tensor stored on GPU. To move it to CPU & convert to a typedArray we use
const resultArray = (await results[0].moveTo('wasm')).toTypedArray();
JavaScript JavaScript

What’s next下一步计划

We are committed to continually expanding LiteRT.js performance, model coverage, and developer tooling. Looking ahead, our development roadmap centers on advancing WebNN integration for native NPU performance and delivering highly optimized support for on-device generative AI.我们致力于持续扩展 LiteRT.js 的性能、模型覆盖范围和开发者工具。展望未来,我们的发展路线图着重于推进 WebNN 集成以实现原生 NPU 性能,并为端侧生成式 AI 提供高度优化的支持。

  • Models: Find pretrained .tflite models on Kaggle or LiteRT Hugging Face Community.模型:在 Kaggle 或 LiteRT Hugging Face 社区查找预训练的 .tflite 模型。
  • Start building: Explore the LiteRT.js Documentation.开始构建:探索 LiteRT.js 文档。
  • Get the package: Download @litertjs/core on npm.获取包:在 npm 上下载 @litertjs/core。
  • Contribute: Share your feedback, report bugs, or contribute on our GitHub issues page.贡献:在我们的 GitHub 问题页面分享反馈、报告错误或贡献代码。
  • LLM support: LiteRT-LM.js, adds browser support for LLMs via our JavaScript API.LLM 支持:LiteRT-LM.js,通过我们的 JavaScript API 为浏览器增加对 LLM 的支持。
  • TensorFlow.js users: See here for how to leverage LiteRT.js for model inference in existing TensorFlow.js pipelines.TensorFlow.js 用户:请在此处了解如何在现有 TensorFlow.js 管线中利用 LiteRT.js 进行模型推理。

Acknowledgements致谢

Ultralytics, for providing YOLO26 media and performance data. Jason Mayes for LiteRT.js demos.感谢 Ultralytics 提供 YOLO26 媒体和性能数据。感谢 Jason Mayes 提供 LiteRT.js 演示。