Yes. Transformers.js is a JavaScript library that can run a compatible model inside the browser. You do not install a Mac app or send the prompt to a chat API. The browser does need to download the library, runtime and model files initially.

Set up on Mac: browser and Terminal

Use an up-to-date Chrome build with WebGPU available on your Mac. First open a locally served page and check Boolean(navigator.gpu) in DevTools Console. If it reports false, do not override browser protections to force it; use a supported browser or consult the library’s CPU/WASM guidance.

  1. In a new folder, save the following as index.html. The import uses a versioned CDN example from the official project.
  2. In that folder, with Python 3 installed, run python3 -m http.server 8000 --bind 127.0.0.1.
  3. Open http://127.0.0.1:8000 and wait for the model weights to load.
<!doctype html>
<meta charset="utf-8">
<input id="prompt" value="Suggest a name for a small bookshop.">
<button id="run" disabled>Generate</button>
<pre id="output">Loading model…</pre>
<script type="module">
import { pipeline } from "https://cdn.jsdelivr.net/npm/@huggingface/transformers@4.3.2";
const output = document.querySelector("#output");
try {
  const generate = await pipeline("text-generation", "onnx-community/Qwen2.5-0.5B-Instruct",
                                  { device: "webgpu", dtype: "q4" });
  const button = document.querySelector("#run");
  output.textContent = "Model loaded.";
  button.disabled = false;
  button.onclick = async () => {
    button.disabled = true;
    try {
      const prompt = document.querySelector("#prompt").value;
      const [result] = await generate([{role: "user", content: prompt}],
                                      {max_new_tokens: 32});
      output.textContent = result.generated_text.at(-1).content;
    } catch (error) {
      output.textContent = error.message;
    } finally {
      button.disabled = false;
    }
  };
} catch (error) {
  output.textContent = error.message;
}
</script>

Check where it runs

Record separate results for a new prompt in the already loaded tab and for a reload while offline. If the first succeeds and the reload cannot fetch an asset, the example showed local generation in the loaded tab. Check which resource failed before treating that as a model or WebGPU error.

In DevTools Network, expect initial asset requests, including model files. The example does not call a hosted text-generation endpoint. To check offline generation, keep the model loaded, go offline, type a different prompt, and click Generate without closing the page; a fully offline reload requires hosting or caching all dependencies and weights. Use the package’s configuration options if building a fully local deployment.

Separate a browser capability check from a working model

Start with a small supported text model and a versioned library import. The initial page, JavaScript package, runtime and model files are different assets. The local page running in Chrome can load the library from a content delivery network and download weights from a model repository. The prompt in the example goes into the in-page generation function. That still leaves initial fetches for the assets needed to make the function work. In DevTools, look at the request types and initiators instead of treating every network entry as a prompt sent to an inference API.

Use the Transformers.js WebGPU guide when choosing the supported device setting for your library and browser. An available navigator.gpu interface is a first capability check. It leaves adapter selection, compatible model files and runtime execution to test. The example explicitly requests WebGPU. If a browser reports no adapter or an unsupported feature, keep the exact message. Check the browser’s normal support and the model’s expected asset variant before making changes. A CPU or WASM example is a different execution path and should get its own pass result.

Record the browser version, the library version, the exact model identifier and the requested precision. If the failure appears at import time, verify the JavaScript URL and any related module paths. If it starts resolving model files and then fails, look at the requested variant and response status. A missing quantized model artifact does not establish that WebGPU is unavailable, and a ready page does not prove that a prompt completed. Save the first successful run and record which stage passed.

Use the Network panel to identify the stage that needs internet

Start the example with the normal connection available. Open the Network panel and reload the local page. When the model loads, note requests from the page, the library import and any model or runtime downloads. Check their origin, status and resource type. Make the first generation request only after the model is ready and note whether any additional resources are requested then. This gives you a before-and-after record of a cold first setup.

Use a prompt with an expected fact. For example, enter “Use exactly one short sentence: the order reference is CEDAR-72 and the current bay is 5.” An answer is useful for this check only when it keeps both values. Save the result locally if you want to compare another device or library build. The example puts a small cap on new tokens, so an unfinished answer belongs in the record rather than counting as success because text appeared.

Disconnect once the page has completed the first request. Use a different input, such as reference PINE-08 and bay 3, and check that both new values appear in a finished result. Leave the page open for this first offline trial. A pass proves that the already loaded browser session can generate again from those assets. It does not prove the files are available after closing or reloading. Keep the online first load and the warm offline pass separate so you know which opportunity was tested.

For a cold check, keep the local static server running and reload without internet access. If a module or weight cannot be found, look at the first failed resource and its requested URL. A module or runtime can still point away from your local site even if every model weight is cached. If the page has to start from scratch in a new browser profile, include that as a separate test. Browser storage can be cleared, evicted or scoped differently, so ordinary caching and a packaged local deployment have different reliability.

Build an explicit local asset route if the reload must work

If offline restart is essential, serve the application and its dependencies locally. Keep a copy of the exact JavaScript build and required runtime assets recommended by the package, along with a complete model folder. Use the model’s native file layout and check the case and path of any referenced files. Put those assets under your local server and test it with the same origin you intend to reuse. Avoid changing the model and import location in the same test until you have an answer you can verify.

The Transformers.js environment reference documents allowing local files, changing the local model base path and disallowing remote model loading. For a bundled copy of the library, set the options before you initialize the pipeline. The example values below describe an intended local asset layout. They do not supply the model files or vendor runtime modules:

env.allowLocalModels = true;
env.localModelPath = "/models/";
env.allowRemoteModels = false;

Keep the model folder under the chosen server path, using the model identifier and filenames your pipeline resolves. Inspect the actual requests if it fails. The local-only model option addresses model-related fetches. A CDN import or runtime binary URL in the rest of the page must be made local independently. Confirm cold reload and a new answer with the network disconnected, not just the absence of a hosted text endpoint while the page stays open.

Use the symptoms to select the next fix

If the page itself does not load, check the static server terminal, address and port. If it loads but no model is available, inspect module and model requests separately. If the runtime reports a WebGPU problem, check the device and selected model variant against the current documentation. Then try the documented CPU path on a small supported model only if that serves your goal. Compare the results as separate configurations and keep the actual device and output beside the outcome.

If the answer comes from the loaded tab but the cold reload fails, leave the working tab available while correcting the missing dependency. If both fail after the library is changed, try the previously working version with the same local assets. If generation runs but the answer is incomplete, repeat with a short task and a suitable output allowance. The contents of the final answer and the browser’s resource log are useful evidence for two different layers of the setup.

Write down the exact files and versions, the user’s expected operating state, the device requested, and the results of the warm and cold checks. For desktop use, an already loaded page may answer the actual requirement. For deployment to someone else’s Mac, verify that a fresh browser profile can open the documented local server and answer without relying on your previous cache.

Verify what the deployment serves if a model file is reported missing

Open the failed request in the Network panel and inspect the full path and response. A deployment can return an HTML route fallback with a success status instead of the model file. In that case a later parser error may point at a tokenizer or model even though the underlying issue is the server path. Check that the response is the expected file and compare its name with the corresponding file in the packaged model folder. If the request goes to a remote host, check the import or runtime setting that initiated that request instead of replacing all the weights.

Use a short first request after a change. Record three events: when the page acknowledges that it is ready, when the generation starts, and when the answer containing all requested fields is shown. A progress bar that ends before the model is ready is a user-interface issue. A long load before the first task can coexist with fast repeated requests. Keep the first startup and a repeat separate before adjusting the model to improve latency.

For a handoff, record which assets must be available and their versioned locations. Include a real expected cold state, such as a new profile that has never opened the local page, and a fresh prompt that tests the model. If the cold case fails while warm chat works, choose whether the warm state is acceptable for the actual requirement or finish the local dependency path. Compare the model response to the source facts regardless of the loading state. Successful delivery of the files and a correct reply both have to work.

Verify the page at the address the reader will use

Repeat the check with the exact URL you intend to distribute. A developer server on localhost and a page published under a path such as /demo/ can resolve model files differently. The Network panel should show whether the page is looking under the deployed path or at the root of the host. For a browser capability check, use that same address: a local development origin and a published origin can behave differently if the latter fails to provide a secure context. Fix the path or origin indicated by the browser before changing device, model or output limits. Confirm the launch again from a fresh profile.

Who makes Transformers.js?

Joshua Lochner (Xenova) created the library; Hugging Face maintains it with contributors. Lochner publicly credits the team in the v3 announcement dated October 22, 2024. Hugging Face the company was founded in 2016; that is separate from the library’s first release. The v3 post verifies that release milestone, not the initial launch date.

References: WebGPU guide · Example model · Project repository · Company profile.