项目
在 GitHub 查看
nathanrs/gpt2-webgl
关于
基于浏览器和 WebGL2 实现的 GPT-2,可视化展示 Transformer 块和注意力矩阵。
人工智能与机器学习可以做什么
- Full GPT-2 small (117M) forward pass in the GPU via WebGL2 shaders
- BPE tokenization using js-tiktoken in the browser (no WASM fetch)
- Simple Python script to download the pretrained weights
实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- 0
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文GPT-2 WebGL Inference Demo
A browser-based, WebGL2 implementation of GPT-2.

Features
- Full GPT-2 small (117M) forward pass in the GPU via WebGL2 shaders
- BPE tokenization using
js-tiktokenin the browser (no WASM fetch) - Simple Python script to download the pretrained weights
Prerequisites
- Node.js ≥ 16.x and npm
- Python ≥ 3.8
- A modern browser with WebGL2 support (Chrome, Firefox, Safari, Edge)
Download the GPT-2 Weights
We rely on HuggingFace’s transformers to pull down the official GPT-2 weights and emit raw Float32Array blobs:
- Install Python dependencies:
pip install torch numpy transformers - Run the downloader:
This will fetch:python download_weights.pywte.bin(token embeddings)wpe.bin(positional embeddings)c_attn_q_w_0.bin…c_attn_q_w_11.binc_attn_k_w_0.bin… etc.lm_head_w.bin,lm_head_b.bin- And a generated
manifest.jsonmapping names → URLs
Front-end Setup with Vite
We use Vite to bundle TS, serve ESM modules & handle js-tiktoken:
- Install JS dependencies:
npm install - Start the local dev server:
npm run dev - Open your browser at
http://localhost:5173
Any changes under src/ will trigger HMR and live-reload.
License
MIT
探索相关项目
加载中…