CoolFace
Apppublic

whitphx/transformersjs-bench-leaderboard

sourceHugging Faceupdated 11mo agoView on Hugging Face
0likes
App README

Transformers.js Benchmark Leaderboard

A Gradio-based leaderboard that displays benchmark results from a HuggingFace Dataset repository.

Features

  • โ€”๐Ÿ“Š Display benchmark results in a searchable/filterable table
  • โ€”๐Ÿ” Filter by model name, task, platform, device, mode, and dtype
  • โ€”๐Ÿ”„ Refresh data on demand from HuggingFace Dataset
  • โ€”๐Ÿ“ˆ View performance metrics (load time, inference time, p50/p90 percentiles)

Setup

  1. 1.Install dependencies:
bash
   uv sync
  1. 1.Configure environment variables:
bash
   cp .env.example .env

Edit .env and set:

  • โ€”HF_DATASET_REPO: Your HuggingFace dataset repository (e.g., username/transformersjs-benchmarks)
  • โ€”HF_TOKEN: Your HuggingFace API token (optional, for private datasets)

Usage

Run the leaderboard:

bash
uv run python -m leaderboard.app

Or using the installed script:

bash
uv run leaderboard

The leaderboard will be available at: http://localhost:7861

Data Format

The leaderboard reads JSONL files from the HuggingFace Dataset repository. Each line should be a JSON object with the following structure:

json
{
  "id": "benchmark-id",
  "platform": "web",
  "modelId": "Xenova/all-MiniLM-L6-v2",
  "task": "feature-extraction",
  "mode": "warm",
  "repeats": 3,
  "batchSize": 1,
  "device": "wasm",
  "browser": "chromium",
  "dtype": "fp32",
  "headed": false,
  "status": "completed",
  "timestamp": 1234567890,
  "result": {
    "metrics": {
      "load_ms": {"p50": 100, "p90": 120},
      "first_infer_ms": {"p50": 10, "p90": 15},
      "subsequent_infer_ms": {"p50": 8, "p90": 12}
    },
    "environment": {
      "cpuCores": 10,
      "memory": {"deviceMemory": 8}
    }
  }
}

Deployment on Hugging Face Spaces

This leaderboard is designed to be deployed on Hugging Face Spaces using the Gradio SDK.

Quick Deploy

  1. 1.Create a new Space on Hugging Face:
  2. 2.Go to https://huggingface.co/new-space
  3. 3.Choose Gradio as the SDK
  4. 4.Set the Space name (e.g., transformersjs-benchmark-leaderboard)
  1. 1.Upload files to your Space:
bash
   # Clone your Space repository
   git clone https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE_NAME
   cd YOUR_SPACE_NAME

   # Copy leaderboard files
   cp -r /path/to/leaderboard/* .

   # Commit and push
   git add .
   git commit -m "Initial leaderboard deployment"
   git push
  1. 1.Configure Space secrets:
  2. 2.Go to your Space settings โ†’ Variables and secrets
  3. 3.Add the following secrets:
  4. 4.HF_DATASET_REPO: Your dataset repository (e.g., username/benchmark-results)
  5. 5.HF_TOKEN: Your HuggingFace API token (for private datasets)
  1. 1.Space will automatically deploy and be available at:
   https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE_NAME

Space Configuration

The Space is configured via the YAML frontmatter in README.md:

yaml
---
title: Transformers.js Benchmark Leaderboard
emoji: ๐Ÿ†
colorFrom: blue
colorTo: purple
sdk: gradio
sdk_version: 5.49.1
app_file: src/leaderboard/app.py
pinned: false
---

Key configuration options:

  • โ€”sdk: Must be gradio for Gradio apps
  • โ€”sdk_version: Gradio version (matches your pyproject.toml)
  • โ€”app_file: Path to the main Python file (relative to repository root)
  • โ€”pinned: Set to true to pin the Space on your profile

Requirements

The Space will automatically install dependencies from pyproject.toml:

  • โ€”gradio>=5.9.1
  • โ€”pandas
  • โ€”huggingface-hub
  • โ€”python-dotenv

Environment Variables

Set these in your Space settings or in a .env file (not recommended for production):

VariableRequiredDescription
HF_DATASET_REPOYesHuggingFace dataset repository containing benchmark results
HF_TOKENNoHuggingFace API token (only for private datasets)

Auto-Restart

Spaces automatically restart when:

  • โ€”Code is pushed to the repository
  • โ€”Dependencies are updated
  • โ€”Environment variables are changed

Monitoring

  • โ€”View logs in the Space's Logs tab
  • โ€”Check status in the Settings tab
  • โ€”Monitor resource usage (CPU, memory)

Development

The leaderboard is built with:

  • โ€”Gradio: Web UI framework
  • โ€”Pandas: Data manipulation
  • โ€”HuggingFace Hub: Dataset loading

Local Development

  1. 1.Install dependencies:
bash
   uv sync
  1. 1.Set environment variables:
bash
   export HF_DATASET_REPO="your-username/benchmark-results"
   export HF_TOKEN="your-hf-token"  # Optional
  1. 1.Run locally:
bash
   uv run python -m leaderboard.app
  1. 1.Access at: http://localhost:7861