Prompt Chain

Evaluate LLMs Locally with Transformers.js

Promptfoo example running a fully local, offline LLM eval with Transformers.js - no API keys required.

Works with transformers.js

85
Spark score
out of 100
Updated last month
Version code-scan-action-0.1
Models
qwen 2 5

Add to Favorites

Why it matters

Set up a completely local LLM evaluation environment using Transformers.js. This asset requires no API keys or external services, enabling private and secure model testing.

Outcomes

What it gets done

01

Demonstrate local LLM evaluation

02

Integrate with Transformers.js

03

Eliminate need for API keys and external services

Install

Add it to your toolbox

Run in your project directory:

curl -fsSL https://spark.entire.vc/get/pfoo-provider-transformers-local | bash

Steps

Steps in the chain

01
Install Transformers.js dependency
02
Initialize example project
03
Navigate to project directory
04
Run evaluation

Overview

Provider Transformers Local

A promptfoo example running a fully local, offline LLM evaluation with Transformers.js, using small ONNX models for generation and embeddings. Use when you need offline, API-key-free, or privacy-sensitive LLM evaluation and can accept smaller local models.

What it does

This example demonstrates a completely local LLM evaluation setup using Transformers.js - no API keys or external services required. It shows local text generation with onnx-community/Qwen3-0.6B-ONNX (the latest Qwen3 model with thinking capabilities, 600MB), local embeddings with Xenova/all-MiniLM-L6-v2 for similarity assertions (23MB), and fully offline evaluation after the initial model download.

When to use - and when NOT to

Use this example when you need to run evals with no external API dependency - offline environments, cost-free testing, or privacy-sensitive data that shouldn't leave the machine. It is not intended for comparing against frontier hosted models - the local models here are small (0.6B parameters) and chosen for feasibility on ordinary hardware, not top-tier output quality.

Inputs and outputs

Install the optional dependency and run:

npm install @huggingface/transformers
npx promptfoo@latest init --example provider-transformers-local
cd provider-transformers-local
npx promptfoo@latest eval

The first run downloads both models (Qwen3-0.6B-ONNX ~600MB, all-MiniLM-L6-v2 ~23MB); subsequent runs use the cache and are much faster. Providers are configured as transformers:text-generation:onnx-community/Qwen3-0.6B-ONNX (with maxNewTokens, temperature, topP, doSample) and, for embeddings, transformers:feature-extraction:Xenova/all-MiniLM-L6-v2 set as defaultTest.options.provider.embedding.

Integrations

Integrates Transformers.js as a fully local provider backend, running entirely on CPU by default. For faster inference, device: webgpu can be used if supported; dtype: q4 reduces memory footprint via quantized models; and -j 1 helps on systems with limited RAM.

Who it's for

Teams needing offline, API-key-free, or privacy-sensitive LLM evaluation who accept smaller local models in exchange for zero external dependency and zero per-request cost.

Source README

provider-transformers-local (Fully Local LLM Evaluation)

This example demonstrates a completely local LLM evaluation setup using Transformers.js - no API keys or external services required.

Prerequisites

Install the optional Transformers.js dependency:

npm install @huggingface/transformers

Usage

npx promptfoo@latest init --example provider-transformers-local
cd provider-transformers-local
npx promptfoo@latest eval

What This Example Shows

  • Local text generation with onnx-community/Qwen3-0.6B-ONNX (latest Qwen3 model with thinking capabilities)
  • Local embeddings with Xenova/all-MiniLM-L6-v2 for similarity assertions
  • Fully offline evaluation after initial model download
  • No API keys needed

Models Used

Model Task Size Purpose
onnx-community/Qwen3-0.6B-ONNX Text Generation ~600MB Generate responses
Xenova/all-MiniLM-L6-v2 Embeddings ~23MB Similarity assertions

First Run

The first evaluation downloads both models (cached for subsequent runs):

Downloading Qwen3-0.6B-ONNX... ~600MB
Downloading all-MiniLM-L6-v2... ~23MB

Subsequent runs use cached models and are much faster.

Configuration Highlights

providers:
  - id: transformers:text-generation:onnx-community/Qwen3-0.6B-ONNX
    config:
      maxNewTokens: 100
      temperature: 0.6
      topP: 0.95
      doSample: true

defaultTest:
  options:
    provider:
      embedding:
        id: transformers:feature-extraction:Xenova/all-MiniLM-L6-v2

Notes

  • Runs entirely on CPU by default
  • For faster inference, use device: webgpu if your system supports it
  • Use dtype: q4 for smaller memory footprint with quantized models
  • Run with -j 1 for systems with limited RAM

FAQ

Common questions

Discussion

Questions & comments · 0

Sign In Sign in to leave a comment.