Use fp16 ONNX with graph optimizations disabled
Browse files- index.html +5 -4
index.html
CHANGED
|
@@ -107,13 +107,14 @@ async function loadModel() {
|
|
| 107 |
try {
|
| 108 |
const { pipeline, TextStreamer } = await import('https://cdn.jsdelivr.net/npm/@huggingface/transformers@3.5.2');
|
| 109 |
window.__TextStreamer = TextStreamer;
|
| 110 |
-
let device = 'wasm'
|
| 111 |
-
if (navigator.gpu) { try { if (await navigator.gpu.requestAdapter()) { device = 'webgpu';
|
| 112 |
-
statusEl.firstChild.textContent = `⏳ Downloading the GPU Mart model (one-time, cached after) — ${device.toUpperCase()} mode…`;
|
| 113 |
barWrap.style.display = 'block';
|
| 114 |
const files = {};
|
| 115 |
generator = await pipeline('text-generation', MODEL_ID, {
|
| 116 |
-
device, dtype,
|
|
|
|
| 117 |
progress_callback: p => {
|
| 118 |
if (p.status === 'progress' && p.total) {
|
| 119 |
files[p.file] = [p.loaded, p.total];
|
|
|
|
| 107 |
try {
|
| 108 |
const { pipeline, TextStreamer } = await import('https://cdn.jsdelivr.net/npm/@huggingface/transformers@3.5.2');
|
| 109 |
window.__TextStreamer = TextStreamer;
|
| 110 |
+
let device = 'wasm';
|
| 111 |
+
if (navigator.gpu) { try { if (await navigator.gpu.requestAdapter()) { device = 'webgpu'; } } catch (e) {} }
|
| 112 |
+
statusEl.firstChild.textContent = `⏳ Downloading the GPU Mart model (~1.2 GB, one-time, cached after) — ${device.toUpperCase()} mode…`;
|
| 113 |
barWrap.style.display = 'block';
|
| 114 |
const files = {};
|
| 115 |
generator = await pipeline('text-generation', MODEL_ID, {
|
| 116 |
+
device, dtype: 'fp16',
|
| 117 |
+
session_options: { graphOptimizationLevel: 'disabled' },
|
| 118 |
progress_callback: p => {
|
| 119 |
if (p.status === 'progress' && p.total) {
|
| 120 |
files[p.file] = [p.loaded, p.total];
|