Upload index.html
Browse files- index.html +514 -15
index.html
CHANGED
|
@@ -197,16 +197,16 @@ textarea{width:100%;min-height:90px;font:inherit;font-size:.95rem;background:var
|
|
| 197 |
const ORG = "VeroLM"; // Hugging Face organization name
|
| 198 |
|
| 199 |
const T = {
|
| 200 |
-
en:{sErrRun:"Couldn’t start this model. Every available engine was tried; details follow.",optTemp:"Temperature",optTopK:"Top-k",optMax:"Max length",optEod:"EOD code",optStop:"Stop at EOD",navData:"Datasets",hData:"Datasets",subData:"Open datasets published by VeroLM on Hugging Face.",sErrCustom:"The model’s own runner failed to start. Check the browser console for details.",note:"Not every model runs directly in the browser. Mostly newer, compatible models do. If a model can’t run, its Run button is greyed out and can’t be clicked.",noRun:"Not available in the browser",navModels:"Models",h1:"Open models at every size.",lead:"Fast, efficient and mostly open source. We train language models from tiny to large and release them for everyone to use for free.",ctaModels:"Browse models",ctaHF:"Follow on Hugging Face",hModels:"Series and models",subModels:"Our current models on Hugging Face. Inspect opens the model page, Run tries it in your browser.",hAbout:"Our approach",subAbout:"VeroLM is an independent AI lab.",p1h:"Quality first",p1:"We build models that genuinely perform, not just models that exist.",p2h:"Speed and efficiency",p2:"Every model is as fast and optimized as we can make it, so it runs on the hardware people actually have.",p3h:"Open by default",p3:"Most of what we train is open source and free. Good AI shouldn’t sit behind a paywall.",p4h:"Experimentation",p4:"We constantly try rarely explored ideas in architecture, training and optimization.",foot:"Built with curiosity, released for everyone.",
|
| 201 |
inspect:"Inspect",run:"Run",close:"Close",model:"model",models:"models",ds:"dataset",dss:"datasets",dsTag:"Dataset",dl:"downloads",oopsT:"Oops, no models here yet.",oopsB:"New releases will show up here as soon as they’re published.",phPrompt:"Type something...",
|
| 202 |
sNoGpu:"WebGPU isn’t available in this browser, so the slower CPU mode will be used.",sGpu:"WebGPU is ready. The first run downloads the model and keeps it in your browser.",sLoad:"Loading model",sReady:"Model ready.",sGen:"Generating...",sErr:"Couldn’t open this model in the browser. It may not be published in a browser-ready (ONNX) format yet."},
|
| 203 |
-
tr:{sErrRun:"Model başlatılamadı. Kullanılabilir tüm motorlar denendi; ayrıntılar aşağıda.",optTemp:"Sıcaklık",optTopK:"Top-k",optMax:"Maks. uzunluk",optEod:"EOD kodu",optStop:"EOD’da dur",navData:"Veri setleri",hData:"Veri setleri",subData:"VeroLM’in Hugging Face’te yayınladığı açık veri setleri.",sErrCustom:"Modelin kendi çalıştırıcısı başlatılamadı. Ayrıntı için tarayıcı konsoluna bak.",note:"Her model doğrudan tarayıcıda çalışmaz, genellikle yeni ve uygun modeller çalışır. Çalışmayacak modellerde Çalıştır düğmesi sönük olur ve tıklanamaz.",noRun:"Bu model tarayıcıda çalışmaz",navModels:"Modeller",h1:"Her boyutta açık modeller.",lead:"Hızlı, verimli ve çoğunlukla açık kaynak. Küçükten büyüğe dil modelleri eğitiyor, herkesin ücretsiz kullanabilmesi için yayınlıyoruz.",ctaModels:"Modelleri incele",ctaHF:"Hugging Face’te takip et",hModels:"Seriler ve modeller",subModels:"Hugging Face’teki güncel modellerimiz. İncele ile model sayfasını aç, Çalıştır ile tarayıcında dene.",hAbout:"Yaklaşımımız",subAbout:"VeroLM, bağımsız bir yapay zeka laboratuvarı.",p1h:"Önce kalite",p1:"Sadece var olan değil, gerçekten iyi çalışan modeller üretiyoruz.",p2h:"Hız ve verimlilik",p2:"Her model, insanların elindeki donanımda çalışacak şekilde olabildiğince hızlı ve optimize.",p3h:"Varsayılan olarak açık",p3:"Eğittiklerimizin çoğu açık kaynak ve ücretsiz. İyi yapay zeka ücretli duvarların arkasında kalmamalı.",p4h:"Deneysellik",p4:"Mimari, eğitim ve optimizasyonda az denenmiş fikirleri sürekli deniyoruz.",foot:"Merakla geliştirildi, herkes için yayınlandı.",
|
| 204 |
inspect:"İncele",run:"Çalıştır",close:"Kapat",model:"model",models:"model",ds:"veri seti",dss:"veri seti",dsTag:"Veri seti",dl:"indirme",oopsT:"Oops, burada henüz model yok.",oopsB:"Yeni modeller yayınlandığında burada görünecek.",phPrompt:"Bir şey yaz...",
|
| 205 |
sNoGpu:"Bu tarayıcıda WebGPU yok, daha yavaş olan CPU modu kullanılacak.",sGpu:"WebGPU hazır. İlk çalıştırmada model indirilir ve tarayıcıda saklanır.",sLoad:"Model yükleniyor",sReady:"Model hazır.",sGen:"Yanıt üretiliyor...",sErr:"Model tarayıcıda açılamadı. Bu model henüz tarayıcı (ONNX) biçiminde yayınlanmamış olabilir."},
|
| 206 |
-
fr:{sErrRun:"Impossible de démarrer ce modèle. Tous les moteurs disponibles ont été essayés ; détails ci-dessous.",optTemp:"Température",optTopK:"Top-k",optMax:"Longueur max.",optEod:"Code EOD",optStop:"Arrêt à l’EOD",navData:"Jeux de données",hData:"Jeux de données",subData:"Jeux de données ouverts publiés par VeroLM sur Hugging Face.",sErrCustom:"Le runner propre au modèle n’a pas pu démarrer. Consultez la console du navigateur.",note:"Tous les modèles ne fonctionnent pas directement dans le navigateur, en général seuls les modèles récents et compatibles le font. Si un modèle ne peut pas s’exécuter, son bouton Exécuter est grisé et non cliquable.",noRun:"Ce modèle ne fonctionne pas dans le navigateur",navModels:"Modèles",h1:"Des modèles ouverts, à toutes les tailles.",lead:"Rapides, efficaces et surtout open source. Nous entraînons des modèles de langage du plus petit au plus grand et les publions pour que tout le monde puisse les utiliser gratuitement.",ctaModels:"Voir les modèles",ctaHF:"Suivre sur Hugging Face",hModels:"Séries et modèles",subModels:"Nos modèles actuels sur Hugging Face. Examiner ouvre la page du modèle, Exécuter l’essaie dans votre navigateur.",hAbout:"Notre approche",subAbout:"VeroLM est un laboratoire d’IA indépendant.",p1h:"La qualité d’abord",p1:"Nous construisons des modèles qui performent vraiment, pas seulement des modèles qui existent.",p2h:"Vitesse et efficacité",p2:"Chaque modèle est aussi rapide et optimisé que possible, pour tourner sur le matériel que les gens ont vraiment.",p3h:"Ouvert par défaut",p3:"La plupart de nos modèles sont open source et gratuits. Une bonne IA ne devrait pas être derrière un paywall.",p4h:"Expérimentation",p4:"Nous testons sans cesse des idées peu explorées en architecture, entraînement et optimisation.",foot:"Créé avec curiosité, publié pour tous.",
|
| 207 |
inspect:"Examiner",run:"Exécuter",close:"Fermer",model:"modèle",models:"modèles",ds:"jeu de données",dss:"jeux de données",dsTag:"Jeu de données",dl:"téléchargements",oopsT:"Oups, aucun modèle ici pour l’instant.",oopsB:"Les nouvelles versions apparaîtront ici dès leur publication.",phPrompt:"Écrivez quelque chose...",
|
| 208 |
sNoGpu:"WebGPU n’est pas disponible dans ce navigateur, le mode CPU, plus lent, sera utilisé.",sGpu:"WebGPU est prêt. Le premier lancement télécharge le modèle et le conserve dans votre navigateur.",sLoad:"Chargement du modèle",sReady:"Modèle prêt.",sGen:"Génération en cours...",sErr:"Impossible d’ouvrir ce modèle dans le navigateur. Il n’est peut-être pas encore publié au format ONNX."},
|
| 209 |
-
es:{sErrRun:"No se pudo iniciar este modelo. Se probaron todos los motores disponibles; detalles a continuación.",optTemp:"Temperatura",optTopK:"Top-k",optMax:"Longitud máx.",optEod:"Código EOD",optStop:"Parar en EOD",navData:"Conjuntos de datos",hData:"Conjuntos de datos",subData:"Conjuntos de datos abiertos publicados por VeroLM en Hugging Face.",sErrCustom:"El runner propio del modelo no pudo iniciarse. Revisa la consola del navegador.",note:"No todos los modelos funcionan directamente en el navegador, normalmente solo los modelos nuevos y compatibles. Si un modelo no puede ejecutarse, su botón Ejecutar aparece atenuado y no se puede pulsar.",noRun:"Este modelo no funciona en el navegador",navModels:"Modelos",h1:"Modelos abiertos de todos los tamaños.",lead:"Rápidos, eficientes y en su mayoría de código abierto. Entrenamos modelos de lenguaje, de pequeños a grandes, y los publicamos para que todos puedan usarlos gratis.",ctaModels:"Ver modelos",ctaHF:"Seguir en Hugging Face",hModels:"Series y modelos",subModels:"Nuestros modelos actuales en Hugging Face. Inspeccionar abre la página del modelo, Ejecutar lo prueba en tu navegador.",hAbout:"Nuestro enfoque",subAbout:"VeroLM es un laboratorio de IA independiente.",p1h:"Primero la calidad",p1:"Construimos modelos que realmente funcionan bien, no solo modelos que existen.",p2h:"Velocidad y eficiencia",p2:"Cada modelo es tan rápido y optimizado como podemos, para que funcione en el hardware que la gente realmente tiene.",p3h:"Abierto por defecto",p3:"La mayoría de lo que entrenamos es de código abierto y gratuito. La buena IA no debería estar detrás de un muro de pago.",p4h:"Experimentación",p4:"Probamos constantemente ideas poco exploradas en arquitectura, entrenamiento y optimización.",foot:"Hecho con curiosidad, publicado para todos.",
|
| 210 |
inspect:"Inspeccionar",run:"Ejecutar",close:"Cerrar",model:"modelo",models:"modelos",ds:"conjunto de datos",dss:"conjuntos de datos",dsTag:"Conjunto de datos",dl:"descargas",oopsT:"Vaya, aún no hay modelos aquí.",oopsB:"Las nuevas versiones aparecerán aquí en cuanto se publiquen.",phPrompt:"Escribe algo...",
|
| 211 |
sNoGpu:"WebGPU no está disponible en este navegador, se usará el modo CPU, más lento.",sGpu:"WebGPU está listo. La primera ejecución descarga el modelo y lo guarda en tu navegador.",sLoad:"Cargando modelo",sReady:"Modelo listo.",sGen:"Generando...",sErr:"No se pudo abrir este modelo en el navegador. Puede que aún no esté publicado en formato ONNX."}
|
| 212 |
};
|
|
@@ -359,7 +359,7 @@ async function load(){
|
|
| 359 |
// (d) built-in engine: any repo whose config.json names an architecture we implement natively and that ships safetensors weights.
|
| 360 |
// No per-repo code is needed or executed, so it works for any owner. A verolm.json with "builtin": false opts out.
|
| 361 |
let cfg = d.config || null;
|
| 362 |
-
if(!nativeKind(cfg) && f.includes("config.json")){
|
| 363 |
try{ cfg = await (await fetch("https://huggingface.co/" + m.id + "/resolve/main/config.json")).json(); }catch(e){}
|
| 364 |
}
|
| 365 |
const stFiles = f.includes("model.safetensors") ? ["model.safetensors"] : f.filter(n => /^model-\d+-of-\d+\.safetensors$/.test(n)).sort();
|
|
@@ -367,16 +367,16 @@ async function load(){
|
|
| 367 |
let nat = null;
|
| 368 |
if(kind && stFiles.length && !(m.manifest && m.manifest.builtin === false)){
|
| 369 |
nat = {kind, kinds, cfg, files:stFiles, unused:[]};
|
| 370 |
-
const am = String((cfg.auto_map || {}).AutoModelForCausalLM || "").split(".");
|
| 371 |
if(am.length === 2 && f.includes(am[0] + ".py")) nat.unused = await repoUnused(m.id, am[0], am[1]);
|
| 372 |
-
nat.cfg = Object.assign({}, nat.cfg, {__act:await repoActivation(m.id, am[0]), __gen:await repoGen(m.id, am[0])});
|
| 373 |
-
const ac = String((cfg.auto_map || {}).AutoConfig || "").split(".");
|
| 374 |
if(ac.length === 2 && f.includes(ac[0] + ".py")) nat.cfg = Object.assign({}, nat.cfg, {__defaults:await repoDefaults(m.id, ac[0])});
|
| 375 |
if(f.includes("generation_config.json")) try{
|
| 376 |
const gc = await (await fetch("https://huggingface.co/" + m.id + "/resolve/main/generation_config.json")).json();
|
| 377 |
nat.gen = {temperature:gc.temperature, top_k:gc.top_k, maxTokens:gc.max_new_tokens, eod_token_id:gc.eos_token_id};
|
| 378 |
}catch(e){}
|
| 379 |
-
const vs = await repoVocabs(m.id, f, cfg);
|
| 380 |
if(vs.length) nat.cfg = Object.assign({}, nat.cfg, {__vocabs:vs});
|
| 381 |
const pr = stFiles.length === 1 ? await probeNative(m.id, nat) : null;
|
| 382 |
if(pr && pr.error){ m.whyNot = pr.error; nat = null; } else if(pr && pr.kind){ nat.kind = pr.kind; nat.kinds = [pr.kind]; } // definite mismatch: don't offer an engine that would fail
|
|
@@ -385,7 +385,7 @@ async function load(){
|
|
| 385 |
if(!nat && !m.whyNot) m.whyNot = kind ? "built-in engine not applicable (sharded weights or disabled by verolm.json)" : "config.json names no built-in architecture (model_type " + JSON.stringify(cfg.model_type) + ")";
|
| 386 |
m.chain = [];
|
| 387 |
if(prior === "custom") m.chain.push("custom"); // the model's own runner knows the model best, so it goes first
|
| 388 |
-
if(nat){ m.native = nat; m.chain.push("native"); m.manifest = Object.assign({arch:nat.kind === "gpt" ? "byte-level GPT transformer" : "byte-level transformer"}, nat.gen || {}, m.manifest || {}); }
|
| 389 |
if(hasOnnx || prior === "transformers") m.chain.push("transformers");
|
| 390 |
m.runtime = m.chain[0] || null;
|
| 391 |
m.runnable = !!m.runtime;
|
|
@@ -433,7 +433,7 @@ function render(){
|
|
| 433 |
if(m.pipeline_tag) meta.append(el("span",{textContent:m.pipeline_tag}));
|
| 434 |
if(m.downloads != null) meta.append(el("span",{textContent:fmt(m.downloads)+" "+t("dl")}));
|
| 435 |
const run = el("button",{className:"btn green",type:"button",textContent:t("run")});
|
| 436 |
-
run.disabled = !m.runnable;
|
| 437 |
if(!m.runnable) run.title = t("noRun");
|
| 438 |
run.onclick = () => openRun(m);
|
| 439 |
grid.append(el("div",{className:"card"},
|
|
@@ -1059,9 +1059,501 @@ function mkVocab(itos, cfg){
|
|
| 1059 |
};
|
| 1060 |
}
|
| 1061 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1062 |
const NATIVE_ARCHS = {
|
| 1063 |
-
|
| 1064 |
-
|
|
|
|
| 1065 |
};
|
| 1066 |
/* ---- end built-in engines ---- */
|
| 1067 |
|
|
@@ -1171,8 +1663,15 @@ $("#rgo").onclick = async () => {
|
|
| 1171 |
}catch(e){
|
| 1172 |
console.error(e);
|
| 1173 |
engines.delete(current.id);
|
| 1174 |
-
const
|
| 1175 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1176 |
}
|
| 1177 |
go.disabled = false;
|
| 1178 |
};
|
|
|
|
| 197 |
const ORG = "VeroLM"; // Hugging Face organization name
|
| 198 |
|
| 199 |
const T = {
|
| 200 |
+
en:{sErrArch:"This model uses an architecture the in-browser engines don’t support yet (its weights don’t match any built-in layout). It can’t run here; details are in the browser console.",sErrRun:"Couldn’t start this model. Every available engine was tried; details follow.",optTemp:"Temperature",optTopK:"Top-k",optMax:"Max length",optEod:"EOD code",optStop:"Stop at EOD",navData:"Datasets",hData:"Datasets",subData:"Open datasets published by VeroLM on Hugging Face.",sErrCustom:"The model’s own runner failed to start. Check the browser console for details.",note:"Not every model runs directly in the browser. Mostly newer, compatible models do. If a model can’t run, its Run button is greyed out and can’t be clicked.",noRun:"Not available in the browser",navModels:"Models",h1:"Open models at every size.",lead:"Fast, efficient and mostly open source. We train language models from tiny to large and release them for everyone to use for free.",ctaModels:"Browse models",ctaHF:"Follow on Hugging Face",hModels:"Series and models",subModels:"Our current models on Hugging Face. Inspect opens the model page, Run tries it in your browser.",hAbout:"Our approach",subAbout:"VeroLM is an independent AI lab.",p1h:"Quality first",p1:"We build models that genuinely perform, not just models that exist.",p2h:"Speed and efficiency",p2:"Every model is as fast and optimized as we can make it, so it runs on the hardware people actually have.",p3h:"Open by default",p3:"Most of what we train is open source and free. Good AI shouldn’t sit behind a paywall.",p4h:"Experimentation",p4:"We constantly try rarely explored ideas in architecture, training and optimization.",foot:"Built with curiosity, released for everyone.",
|
| 201 |
inspect:"Inspect",run:"Run",close:"Close",model:"model",models:"models",ds:"dataset",dss:"datasets",dsTag:"Dataset",dl:"downloads",oopsT:"Oops, no models here yet.",oopsB:"New releases will show up here as soon as they’re published.",phPrompt:"Type something...",
|
| 202 |
sNoGpu:"WebGPU isn’t available in this browser, so the slower CPU mode will be used.",sGpu:"WebGPU is ready. The first run downloads the model and keeps it in your browser.",sLoad:"Loading model",sReady:"Model ready.",sGen:"Generating...",sErr:"Couldn’t open this model in the browser. It may not be published in a browser-ready (ONNX) format yet."},
|
| 203 |
+
tr:{sErrArch:"Bu model, tarayıcıdaki motorların henüz desteklemediği bir mimari kullanıyor (ağırlıkları hiçbir yerleşik düzenle eşleşmiyor). Burada çalıştırılamaz; ayrıntılar tarayıcı konsolunda.",sErrRun:"Model başlatılamadı. Kullanılabilir tüm motorlar denendi; ayrıntılar aşağıda.",optTemp:"Sıcaklık",optTopK:"Top-k",optMax:"Maks. uzunluk",optEod:"EOD kodu",optStop:"EOD’da dur",navData:"Veri setleri",hData:"Veri setleri",subData:"VeroLM’in Hugging Face’te yayınladığı açık veri setleri.",sErrCustom:"Modelin kendi çalıştırıcısı başlatılamadı. Ayrıntı için tarayıcı konsoluna bak.",note:"Her model doğrudan tarayıcıda çalışmaz, genellikle yeni ve uygun modeller çalışır. Çalışmayacak modellerde Çalıştır düğmesi sönük olur ve tıklanamaz.",noRun:"Bu model tarayıcıda çalışmaz",navModels:"Modeller",h1:"Her boyutta açık modeller.",lead:"Hızlı, verimli ve çoğunlukla açık kaynak. Küçükten büyüğe dil modelleri eğitiyor, herkesin ücretsiz kullanabilmesi için yayınlıyoruz.",ctaModels:"Modelleri incele",ctaHF:"Hugging Face’te takip et",hModels:"Seriler ve modeller",subModels:"Hugging Face’teki güncel modellerimiz. İncele ile model sayfasını aç, Çalıştır ile tarayıcında dene.",hAbout:"Yaklaşımımız",subAbout:"VeroLM, bağımsız bir yapay zeka laboratuvarı.",p1h:"Önce kalite",p1:"Sadece var olan değil, gerçekten iyi çalışan modeller üretiyoruz.",p2h:"Hız ve verimlilik",p2:"Her model, insanların elindeki donanımda çalışacak şekilde olabildiğince hızlı ve optimize.",p3h:"Varsayılan olarak açık",p3:"Eğittiklerimizin çoğu açık kaynak ve ücretsiz. İyi yapay zeka ücretli duvarların arkasında kalmamalı.",p4h:"Deneysellik",p4:"Mimari, eğitim ve optimizasyonda az denenmiş fikirleri sürekli deniyoruz.",foot:"Merakla geliştirildi, herkes için yayınlandı.",
|
| 204 |
inspect:"İncele",run:"Çalıştır",close:"Kapat",model:"model",models:"model",ds:"veri seti",dss:"veri seti",dsTag:"Veri seti",dl:"indirme",oopsT:"Oops, burada henüz model yok.",oopsB:"Yeni modeller yayınlandığında burada görünecek.",phPrompt:"Bir şey yaz...",
|
| 205 |
sNoGpu:"Bu tarayıcıda WebGPU yok, daha yavaş olan CPU modu kullanılacak.",sGpu:"WebGPU hazır. İlk çalıştırmada model indirilir ve tarayıcıda saklanır.",sLoad:"Model yükleniyor",sReady:"Model hazır.",sGen:"Yanıt üretiliyor...",sErr:"Model tarayıcıda açılamadı. Bu model henüz tarayıcı (ONNX) biçiminde yayınlanmamış olabilir."},
|
| 206 |
+
fr:{sErrArch:"Ce modèle utilise une architecture que les moteurs du navigateur ne prennent pas encore en charge (ses poids ne correspondent à aucune disposition intégrée). Il ne peut pas s’exécuter ici ; détails dans la console.",sErrRun:"Impossible de démarrer ce modèle. Tous les moteurs disponibles ont été essayés ; détails ci-dessous.",optTemp:"Température",optTopK:"Top-k",optMax:"Longueur max.",optEod:"Code EOD",optStop:"Arrêt à l’EOD",navData:"Jeux de données",hData:"Jeux de données",subData:"Jeux de données ouverts publiés par VeroLM sur Hugging Face.",sErrCustom:"Le runner propre au modèle n’a pas pu démarrer. Consultez la console du navigateur.",note:"Tous les modèles ne fonctionnent pas directement dans le navigateur, en général seuls les modèles récents et compatibles le font. Si un modèle ne peut pas s’exécuter, son bouton Exécuter est grisé et non cliquable.",noRun:"Ce modèle ne fonctionne pas dans le navigateur",navModels:"Modèles",h1:"Des modèles ouverts, à toutes les tailles.",lead:"Rapides, efficaces et surtout open source. Nous entraînons des modèles de langage du plus petit au plus grand et les publions pour que tout le monde puisse les utiliser gratuitement.",ctaModels:"Voir les modèles",ctaHF:"Suivre sur Hugging Face",hModels:"Séries et modèles",subModels:"Nos modèles actuels sur Hugging Face. Examiner ouvre la page du modèle, Exécuter l’essaie dans votre navigateur.",hAbout:"Notre approche",subAbout:"VeroLM est un laboratoire d’IA indépendant.",p1h:"La qualité d’abord",p1:"Nous construisons des modèles qui performent vraiment, pas seulement des modèles qui existent.",p2h:"Vitesse et efficacité",p2:"Chaque modèle est aussi rapide et optimisé que possible, pour tourner sur le matériel que les gens ont vraiment.",p3h:"Ouvert par défaut",p3:"La plupart de nos modèles sont open source et gratuits. Une bonne IA ne devrait pas être derrière un paywall.",p4h:"Expérimentation",p4:"Nous testons sans cesse des idées peu explorées en architecture, entraînement et optimisation.",foot:"Créé avec curiosité, publié pour tous.",
|
| 207 |
inspect:"Examiner",run:"Exécuter",close:"Fermer",model:"modèle",models:"modèles",ds:"jeu de données",dss:"jeux de données",dsTag:"Jeu de données",dl:"téléchargements",oopsT:"Oups, aucun modèle ici pour l’instant.",oopsB:"Les nouvelles versions apparaîtront ici dès leur publication.",phPrompt:"Écrivez quelque chose...",
|
| 208 |
sNoGpu:"WebGPU n’est pas disponible dans ce navigateur, le mode CPU, plus lent, sera utilisé.",sGpu:"WebGPU est prêt. Le premier lancement télécharge le modèle et le conserve dans votre navigateur.",sLoad:"Chargement du modèle",sReady:"Modèle prêt.",sGen:"Génération en cours...",sErr:"Impossible d’ouvrir ce modèle dans le navigateur. Il n’est peut-être pas encore publié au format ONNX."},
|
| 209 |
+
es:{sErrArch:"Este modelo usa una arquitectura que los motores del navegador aún no admiten (sus pesos no coinciden con ningún diseño integrado). No se puede ejecutar aquí; detalles en la consola.",sErrRun:"No se pudo iniciar este modelo. Se probaron todos los motores disponibles; detalles a continuación.",optTemp:"Temperatura",optTopK:"Top-k",optMax:"Longitud máx.",optEod:"Código EOD",optStop:"Parar en EOD",navData:"Conjuntos de datos",hData:"Conjuntos de datos",subData:"Conjuntos de datos abiertos publicados por VeroLM en Hugging Face.",sErrCustom:"El runner propio del modelo no pudo iniciarse. Revisa la consola del navegador.",note:"No todos los modelos funcionan directamente en el navegador, normalmente solo los modelos nuevos y compatibles. Si un modelo no puede ejecutarse, su botón Ejecutar aparece atenuado y no se puede pulsar.",noRun:"Este modelo no funciona en el navegador",navModels:"Modelos",h1:"Modelos abiertos de todos los tamaños.",lead:"Rápidos, eficientes y en su mayoría de código abierto. Entrenamos modelos de lenguaje, de pequeños a grandes, y los publicamos para que todos puedan usarlos gratis.",ctaModels:"Ver modelos",ctaHF:"Seguir en Hugging Face",hModels:"Series y modelos",subModels:"Nuestros modelos actuales en Hugging Face. Inspeccionar abre la página del modelo, Ejecutar lo prueba en tu navegador.",hAbout:"Nuestro enfoque",subAbout:"VeroLM es un laboratorio de IA independiente.",p1h:"Primero la calidad",p1:"Construimos modelos que realmente funcionan bien, no solo modelos que existen.",p2h:"Velocidad y eficiencia",p2:"Cada modelo es tan rápido y optimizado como podemos, para que funcione en el hardware que la gente realmente tiene.",p3h:"Abierto por defecto",p3:"La mayoría de lo que entrenamos es de código abierto y gratuito. La buena IA no debería estar detrás de un muro de pago.",p4h:"Experimentación",p4:"Probamos constantemente ideas poco exploradas en arquitectura, entrenamiento y optimización.",foot:"Hecho con curiosidad, publicado para todos.",
|
| 210 |
inspect:"Inspeccionar",run:"Ejecutar",close:"Cerrar",model:"modelo",models:"modelos",ds:"conjunto de datos",dss:"conjuntos de datos",dsTag:"Conjunto de datos",dl:"descargas",oopsT:"Vaya, aún no hay modelos aquí.",oopsB:"Las nuevas versiones aparecerán aquí en cuanto se publiquen.",phPrompt:"Escribe algo...",
|
| 211 |
sNoGpu:"WebGPU no está disponible en este navegador, se usará el modo CPU, más lento.",sGpu:"WebGPU está listo. La primera ejecución descarga el modelo y lo guarda en tu navegador.",sLoad:"Cargando modelo",sReady:"Modelo listo.",sGen:"Generando...",sErr:"No se pudo abrir este modelo en el navegador. Puede que aún no esté publicado en formato ONNX."}
|
| 212 |
};
|
|
|
|
| 359 |
// (d) built-in engine: any repo whose config.json names an architecture we implement natively and that ships safetensors weights.
|
| 360 |
// No per-repo code is needed or executed, so it works for any owner. A verolm.json with "builtin": false opts out.
|
| 361 |
let cfg = d.config || null;
|
| 362 |
+
if((!nativeKind(cfg) || (/gen55/i.test(String(cfg.model_type)) && cfg.theta == null)) && f.includes("config.json")){
|
| 363 |
try{ cfg = await (await fetch("https://huggingface.co/" + m.id + "/resolve/main/config.json")).json(); }catch(e){}
|
| 364 |
}
|
| 365 |
const stFiles = f.includes("model.safetensors") ? ["model.safetensors"] : f.filter(n => /^model-\d+-of-\d+\.safetensors$/.test(n)).sort();
|
|
|
|
| 367 |
let nat = null;
|
| 368 |
if(kind && stFiles.length && !(m.manifest && m.manifest.builtin === false)){
|
| 369 |
nat = {kind, kinds, cfg, files:stFiles, unused:[]};
|
| 370 |
+
const g55 = /gen55/i.test(String(cfg.model_type)), am = g55 ? [] : String((cfg.auto_map || {}).AutoModelForCausalLM || "").split(".");
|
| 371 |
if(am.length === 2 && f.includes(am[0] + ".py")) nat.unused = await repoUnused(m.id, am[0], am[1]);
|
| 372 |
+
if(!g55) nat.cfg = Object.assign({}, nat.cfg, {__act:await repoActivation(m.id, am[0]), __gen:await repoGen(m.id, am[0])});
|
| 373 |
+
const ac = g55 ? [] : String((cfg.auto_map || {}).AutoConfig || "").split(".");
|
| 374 |
if(ac.length === 2 && f.includes(ac[0] + ".py")) nat.cfg = Object.assign({}, nat.cfg, {__defaults:await repoDefaults(m.id, ac[0])});
|
| 375 |
if(f.includes("generation_config.json")) try{
|
| 376 |
const gc = await (await fetch("https://huggingface.co/" + m.id + "/resolve/main/generation_config.json")).json();
|
| 377 |
nat.gen = {temperature:gc.temperature, top_k:gc.top_k, maxTokens:gc.max_new_tokens, eod_token_id:gc.eos_token_id};
|
| 378 |
}catch(e){}
|
| 379 |
+
const vs = g55 ? [] : await repoVocabs(m.id, f, cfg);
|
| 380 |
if(vs.length) nat.cfg = Object.assign({}, nat.cfg, {__vocabs:vs});
|
| 381 |
const pr = stFiles.length === 1 ? await probeNative(m.id, nat) : null;
|
| 382 |
if(pr && pr.error){ m.whyNot = pr.error; nat = null; } else if(pr && pr.kind){ nat.kind = pr.kind; nat.kinds = [pr.kind]; } // definite mismatch: don't offer an engine that would fail
|
|
|
|
| 385 |
if(!nat && !m.whyNot) m.whyNot = kind ? "built-in engine not applicable (sharded weights or disabled by verolm.json)" : "config.json names no built-in architecture (model_type " + JSON.stringify(cfg.model_type) + ")";
|
| 386 |
m.chain = [];
|
| 387 |
if(prior === "custom") m.chain.push("custom"); // the model's own runner knows the model best, so it goes first
|
| 388 |
+
if(nat){ m.native = nat; m.chain.push("native"); m.manifest = Object.assign({arch:nat.kind === "gpt" ? "byte-level GPT transformer" : nat.kind === "notokengen55" ? "hierarchical byte hybrid" : "byte-level transformer"}, nat.gen || {}, m.manifest || {}); }
|
| 389 |
if(hasOnnx || prior === "transformers") m.chain.push("transformers");
|
| 390 |
m.runtime = m.chain[0] || null;
|
| 391 |
m.runnable = !!m.runtime;
|
|
|
|
| 433 |
if(m.pipeline_tag) meta.append(el("span",{textContent:m.pipeline_tag}));
|
| 434 |
if(m.downloads != null) meta.append(el("span",{textContent:fmt(m.downloads)+" "+t("dl")}));
|
| 435 |
const run = el("button",{className:"btn green",type:"button",textContent:t("run")});
|
| 436 |
+
run.dataset.id = m.id; run.disabled = !m.runnable;
|
| 437 |
if(!m.runnable) run.title = t("noRun");
|
| 438 |
run.onclick = () => openRun(m);
|
| 439 |
grid.append(el("div",{className:"card"},
|
|
|
|
| 1059 |
};
|
| 1060 |
}
|
| 1061 |
|
| 1062 |
+
/* ---- NoTokenLM Gen-5.5: byte-level hierarchical hybrid ----
|
| 1063 |
+
bytes -> (byte emb + hashed n-gram emb + ROSA) -> local encoder (conv, conv, windowed attn)
|
| 1064 |
+
-> entropy patches -> attention pooling -> trunk over patches (RWKV-7 / gated NoPE attention)
|
| 1065 |
+
-> local decoder (windowed attn) -> 256-way next-byte logits.
|
| 1066 |
+
Port of modeling_notoken_gen55.py. Everything is evaluated incrementally, one byte at a time; the trunk runs once per closed patch. */
|
| 1067 |
+
const G55_DEF = {
|
| 1068 |
+
d:768, n_block:5, pattern:["R","A","R","R"], ffn:1792, head_dim:64, lora_decay:64, lora_a:64, lora_v:64, lora_g:128,
|
| 1069 |
+
attn_gate:true, qk_norm:true, ln_scale:true,
|
| 1070 |
+
d_loc:256, enc_blocks:["conv","conv","attn"], n_dec:4, loc_heads:4, loc_window:32, conv_k:4, loc_ffn:704, pool_heads:8, dec_cross:false,
|
| 1071 |
+
hash_orders:[3,4,5,6,7,8], hash_rows:[103424,103424,103424,103424,103424,103424], hash_dim:32,
|
| 1072 |
+
seq_len:4096, patch_max_len:16, ent_d:256, ent_layers:8, ent_ffn:704, ent_k:4, vocab:257, rosa:true, deepembed:"byte", theta:null
|
| 1073 |
+
};
|
| 1074 |
+
function g55Cfg(cfg){
|
| 1075 |
+
const c = Object.assign({}, G55_DEF, cfg || {});
|
| 1076 |
+
c.pattern = Array.from(c.pattern); c.enc_blocks = Array.from(c.enc_blocks); c.hash_orders = Array.from(c.hash_orders); c.hash_rows = Array.from(c.hash_rows);
|
| 1077 |
+
c.n_hash = c.hash_orders.length; c.de_byte = c.deepembed === "byte"; c.rosa = !!c.rosa;
|
| 1078 |
+
return c;
|
| 1079 |
+
}
|
| 1080 |
+
// tensor name -> number of values, for the whole checkpoint
|
| 1081 |
+
function g55Spec(c){
|
| 1082 |
+
const S = new Map(), dl = c.d_loc, d = c.d, ff = c.loc_ffn, nb = c.n_block, hd = c.head_dim, H = d / hd, add = (n, len) => S.set(n, len);
|
| 1083 |
+
add("emb_in", c.vocab * dl);
|
| 1084 |
+
const loc = (p, kind) => {
|
| 1085 |
+
add(p + ".n1", dl); add(p + ".n2", dl); add(p + ".ffn.w1", dl * ff); add(p + ".ffn.w3", dl * ff); add(p + ".ffn.w2", ff * dl);
|
| 1086 |
+
if(kind === "attn") for(const w of ["wq", "wk", "wv", "wo"]) add(p + "." + w, dl * dl); else add(p + ".conv", c.conv_k * dl);
|
| 1087 |
+
if(c.de_byte) add(p + ".de", c.vocab * ff);
|
| 1088 |
+
};
|
| 1089 |
+
c.enc_blocks.forEach((k, i) => { if(k !== "conv" && k !== "attn") throw ntFail("Unknown encoder block type " + k); loc("enc." + i, k); });
|
| 1090 |
+
add("enc_nf", dl);
|
| 1091 |
+
add("pool.ws", dl * c.pool_heads); add("pool.wv", dl * dl); add("pool.wo", dl * dl); add("pool.up", dl * d); add("pool.len_emb", 16 * d); add("pool.pool_nf", d);
|
| 1092 |
+
c.pattern.forEach((k, j) => {
|
| 1093 |
+
const p = "trunk.l" + j;
|
| 1094 |
+
add(p + ".n1", nb * d); add(p + ".n2", nb * d); add(p + ".ffn.w1", nb * d * c.ffn); add(p + ".ffn.w3", nb * d * c.ffn); add(p + ".ffn.w2", nb * c.ffn * d);
|
| 1095 |
+
if(k === "A"){
|
| 1096 |
+
for(const w of ["wq", "wk", "wv", "wo"]) add(p + ".mix." + w, nb * d * d);
|
| 1097 |
+
if(c.qk_norm){ add(p + ".mix.qn", nb * hd); add(p + ".mix.kn", nb * hd); }
|
| 1098 |
+
if(c.attn_gate){ add(p + ".mix.gate_w", nb * d * H); add(p + ".mix.gate_b", nb * H); }
|
| 1099 |
+
}else if(k === "R"){
|
| 1100 |
+
for(const w of ["x_r", "x_w", "x_k", "x_v", "x_a", "x_g", "w0", "a0", "k_k", "k_a", "v0", "ln_w", "ln_b"]) add(p + ".mix." + w, nb * d);
|
| 1101 |
+
add(p + ".mix.w1", nb * d * c.lora_decay); add(p + ".mix.w2", nb * c.lora_decay * d);
|
| 1102 |
+
add(p + ".mix.a1", nb * d * c.lora_a); add(p + ".mix.a2", nb * c.lora_a * d);
|
| 1103 |
+
add(p + ".mix.g1", nb * d * c.lora_g); add(p + ".mix.g2", nb * c.lora_g * d);
|
| 1104 |
+
add(p + ".mix.v1", nb * d * c.lora_v); add(p + ".mix.v2", nb * c.lora_v * d);
|
| 1105 |
+
add(p + ".mix.r_k", nb * H * hd);
|
| 1106 |
+
for(const w of ["Wr", "Wk", "Wv", "Wo"]) add(p + ".mix." + w, nb * d * d);
|
| 1107 |
+
}else throw ntFail("Unknown trunk layer type " + k);
|
| 1108 |
+
});
|
| 1109 |
+
add("nf", d); add("down", d * dl); add("down_nf", dl); add("bos", dl);
|
| 1110 |
+
for(let i = 0; i < c.n_dec; i++) loc("dec." + i, "attn");
|
| 1111 |
+
add("dec_nf", dl); add("head", dl * 256);
|
| 1112 |
+
if(c.rosa){ add("rosa.pe", 257 * dl); add("rosa.lg", 16 * dl); add("rosa.lb", 16 * dl); add("rosa.boost", 16); }
|
| 1113 |
+
if(c.n_hash){
|
| 1114 |
+
add("hash_table", c.hash_rows.reduce((a, b) => a + b, 0) * c.hash_dim); add("hash_nw", c.n_hash * c.hash_dim); add("hash_proj", c.n_hash * c.hash_dim * dl);
|
| 1115 |
+
}
|
| 1116 |
+
add("patcher.emb", 256 * c.ent_d); add("patcher.nf", c.ent_d); add("patcher.head", c.ent_d * 256);
|
| 1117 |
+
for(let i = 0; i < c.ent_layers; i++){
|
| 1118 |
+
const p = "patcher.layers." + i;
|
| 1119 |
+
add(p + ".n1", c.ent_d); add(p + ".n2", c.ent_d); add(p + ".conv", c.ent_k * c.ent_d);
|
| 1120 |
+
add(p + ".ffn.w1", c.ent_d * c.ent_ffn); add(p + ".ffn.w3", c.ent_d * c.ent_ffn); add(p + ".ffn.w2", c.ent_ffn * c.ent_d);
|
| 1121 |
+
}
|
| 1122 |
+
return S;
|
| 1123 |
+
}
|
| 1124 |
+
// Validates config + tensor names/sizes WITHOUT weight data (shapes only), so it also runs on a safetensors header.
|
| 1125 |
+
function g55Plan(cfg0, bag){
|
| 1126 |
+
const c = g55Cfg(cfg0);
|
| 1127 |
+
if(c.dec_cross) throw ntFail("Decoder cross-attention variants aren't supported by the built-in Gen-5.5 engine.");
|
| 1128 |
+
if(c.deepembed !== "off" && c.deepembed !== "byte") throw ntFail("deepembed '" + c.deepembed + "' isn't supported by the built-in Gen-5.5 engine.");
|
| 1129 |
+
if(!(Number(c.theta) > 0)) throw ntFail("config.json has no calibrated patch threshold (theta).");
|
| 1130 |
+
if(c.d % c.head_dim || c.d_loc % c.loc_heads || (c.d_loc / c.loc_heads) % 2 || c.d_loc % c.pool_heads) throw ntFail("Invalid Gen-5.5 config: head sizes don't divide the model widths.");
|
| 1131 |
+
if(c.hash_rows.length !== c.n_hash) throw ntFail("Invalid Gen-5.5 config: hash_rows and hash_orders differ in length.");
|
| 1132 |
+
const spec = g55Spec(c), used = new Set();
|
| 1133 |
+
for(const [name, len] of spec){
|
| 1134 |
+
const k = bag.find(name);
|
| 1135 |
+
if(k == null) throw ntFail("Missing tensor " + name + ". " + tensorSummary([...bag.keys()]));
|
| 1136 |
+
const n = bag.get(k).shape.reduce((a, b) => a * b, 1);
|
| 1137 |
+
if(n !== len) throw ntFail("Tensor " + k + " has " + n + " values, expected " + len + ". config.json and the weights don't match.");
|
| 1138 |
+
used.add(k);
|
| 1139 |
+
}
|
| 1140 |
+
const extra = [...bag.keys()].filter(k => !used.has(k));
|
| 1141 |
+
if(extra.length) throw ntFail("Unsupported extra tensors (" + extra.slice(0, 4).join(", ") + (extra.length > 4 ? ", ..." : "") + "): this checkpoint is a different architecture variant than the built-in Gen-5.5 engine.");
|
| 1142 |
+
return {c, spec};
|
| 1143 |
+
}
|
| 1144 |
+
|
| 1145 |
+
/* ---- numeric helpers (row-major [in, out] weights: y = x @ W) ---- */
|
| 1146 |
+
function g55Rms(x, xo, w, n, y, yo, mul){
|
| 1147 |
+
let s = 0; for(let i = 0; i < n; i++){ const v = x[xo + i]; s += v * v; }
|
| 1148 |
+
const r = mul === undefined ? 1 / Math.sqrt(s / n + 1e-6) : mul / Math.sqrt(s / n + 1e-6);
|
| 1149 |
+
for(let i = 0; i < n; i++) y[yo + i] = x[xo + i] * r * w[i];
|
| 1150 |
+
}
|
| 1151 |
+
function g55Vm(x, xo, W, wo, nIn, nOut, y, yo, acc){
|
| 1152 |
+
if(!acc) for(let j = 0; j < nOut; j++) y[yo + j] = 0;
|
| 1153 |
+
let i = 0;
|
| 1154 |
+
for(; i + 3 < nIn; i += 4){ // four input rows per pass: a quarter of the loads/stores on y
|
| 1155 |
+
const x0 = x[xo + i], x1 = x[xo + i + 1], x2 = x[xo + i + 2], x3 = x[xo + i + 3];
|
| 1156 |
+
const o0 = wo + i * nOut, o1 = o0 + nOut, o2 = o1 + nOut, o3 = o2 + nOut;
|
| 1157 |
+
for(let j = 0; j < nOut; j++) y[yo + j] += x0 * W[o0 + j] + x1 * W[o1 + j] + x2 * W[o2 + j] + x3 * W[o3 + j];
|
| 1158 |
+
}
|
| 1159 |
+
for(; i < nIn; i++){
|
| 1160 |
+
const xi = x[xo + i], o = wo + i * nOut;
|
| 1161 |
+
for(let j = 0; j < nOut; j++) y[yo + j] += xi * W[o + j];
|
| 1162 |
+
}
|
| 1163 |
+
}
|
| 1164 |
+
const g55Sig = x => 1 / (1 + Math.exp(-x));
|
| 1165 |
+
const g55Silu = x => x / (1 + Math.exp(-x));
|
| 1166 |
+
|
| 1167 |
+
function g55Build(cfg0, tensors){
|
| 1168 |
+
const bag = tensors instanceof TensorBag ? tensors : new TensorBag(tensors), P = g55Plan(cfg0, bag), c = P.c, W = Object.create(null);
|
| 1169 |
+
for(const k of P.spec.keys()) W[k] = toFloat32(bag.get(k));
|
| 1170 |
+
const dl = c.d_loc, d = c.d, nb = c.n_block, hd = c.head_dim, H = d / hd, np = c.pattern.length, sl = (a, i, n) => a.subarray(i * n, (i + 1) * n);
|
| 1171 |
+
const M = {c, W, dl, d, nb, hd, H, np, dh:dl / c.loc_heads, dhp:dl / c.pool_heads};
|
| 1172 |
+
M.trunk = [];
|
| 1173 |
+
for(let b = 0; b < nb; b++){
|
| 1174 |
+
const row = [];
|
| 1175 |
+
for(let j = 0; j < np; j++){
|
| 1176 |
+
const p = "trunk.l" + j, kind = c.pattern[j], mx = p + ".mix.";
|
| 1177 |
+
const L = {kind, n1:sl(W[p + ".n1"], b, d), n2:sl(W[p + ".n2"], b, d), fw1:sl(W[p + ".ffn.w1"], b, d * c.ffn), fw3:sl(W[p + ".ffn.w3"], b, d * c.ffn), fw2:sl(W[p + ".ffn.w2"], b, c.ffn * d),
|
| 1178 |
+
s:c.ln_scale ? 1 / Math.sqrt(b * np + j + 1) : 1};
|
| 1179 |
+
if(kind === "A"){
|
| 1180 |
+
for(const w of ["wq", "wk", "wv", "wo"]) L[w] = sl(W[mx + w], b, d * d);
|
| 1181 |
+
if(c.qk_norm){ L.qn = sl(W[mx + "qn"], b, hd); L.kn = sl(W[mx + "kn"], b, hd); }
|
| 1182 |
+
if(c.attn_gate){ L.gw = sl(W[mx + "gate_w"], b, d * H); L.gb = sl(W[mx + "gate_b"], b, H); }
|
| 1183 |
+
}else{
|
| 1184 |
+
for(const w of ["x_r", "x_w", "x_k", "x_v", "x_a", "x_g", "w0", "a0", "k_k", "k_a", "v0", "ln_w", "ln_b"]) L[w] = sl(W[mx + w], b, d);
|
| 1185 |
+
L.w1 = sl(W[mx + "w1"], b, d * c.lora_decay); L.w2 = sl(W[mx + "w2"], b, c.lora_decay * d);
|
| 1186 |
+
L.a1 = sl(W[mx + "a1"], b, d * c.lora_a); L.a2 = sl(W[mx + "a2"], b, c.lora_a * d);
|
| 1187 |
+
L.g1 = sl(W[mx + "g1"], b, d * c.lora_g); L.g2 = sl(W[mx + "g2"], b, c.lora_g * d);
|
| 1188 |
+
L.v1 = sl(W[mx + "v1"], b, d * c.lora_v); L.v2 = sl(W[mx + "v2"], b, c.lora_v * d);
|
| 1189 |
+
L.r_k = sl(W[mx + "r_k"], b, H * hd);
|
| 1190 |
+
for(const w of ["Wr", "Wk", "Wv", "Wo"]) L[w] = sl(W[mx + w], b, d * d);
|
| 1191 |
+
}
|
| 1192 |
+
row.push(L);
|
| 1193 |
+
}
|
| 1194 |
+
M.trunk.push(row);
|
| 1195 |
+
}
|
| 1196 |
+
// output head with the per-row mean removed (logits = rms(u) @ (head - head.mean(1)))
|
| 1197 |
+
const hs = W["head"], hc = new Float32Array(dl * 256);
|
| 1198 |
+
for(let i = 0; i < dl; i++){ let m = 0; for(let o = 0; o < 256; o++) m += hs[i * 256 + o]; m /= 256; for(let o = 0; o < 256; o++) hc[i * 256 + o] = hs[i * 256 + o] - m; }
|
| 1199 |
+
M.headc = hc;
|
| 1200 |
+
const mx = Math.max(dl, c.loc_ffn, c.ent_d, c.ent_ffn, d, c.ffn, c.lora_g, c.lora_decay, 64);
|
| 1201 |
+
M.sc = { // scratch buffers, reused for every call
|
| 1202 |
+
a:new Float32Array(mx), b:new Float32Array(mx), g:new Float32Array(mx), u:new Float32Array(mx),
|
| 1203 |
+
q:new Float32Array(dl), k:new Float32Array(dl), v:new Float32Array(dl), y:new Float32Array(dl), t:new Float32Array(dl),
|
| 1204 |
+
lg:new Float32Array(256), sc:new Float32Array(Math.max(c.loc_window, 16, 8) + 2),
|
| 1205 |
+
x:new Float32Array(d), h:new Float32Array(d), h2:new Float32Array(d), vf:new Float32Array(d), ya:new Float32Array(d), o:new Float32Array(d),
|
| 1206 |
+
f1:new Float32Array(c.ffn), f3:new Float32Array(c.ffn),
|
| 1207 |
+
xr:new Float32Array(d), xw:new Float32Array(d), xk:new Float32Array(d), xv:new Float32Array(d), xa:new Float32Array(d), xg:new Float32Array(d),
|
| 1208 |
+
r:new Float32Array(d), kk:new Float32Array(d), vv:new Float32Array(d), kx:new Float32Array(d), aa:new Float32Array(d), lw:new Float32Array(d), gg:new Float32Array(d),
|
| 1209 |
+
low:new Float32Array(Math.max(c.lora_decay, c.lora_a, c.lora_v, c.lora_g)), pq:new Float32Array(d), pk:new Float32Array(d), pv:new Float32Array(d),
|
| 1210 |
+
gt:new Float32Array(H + 1), pool:new Float32Array(dl), pool2:new Float32Array(dl), enc:new Float32Array(dl), ent:new Float32Array(c.n_hash * c.hash_dim), hrow:new Float32Array(dl),
|
| 1211 |
+
gl:new Float32Array(dl), sct:new Float32Array(4097)
|
| 1212 |
+
};
|
| 1213 |
+
return M;
|
| 1214 |
+
}
|
| 1215 |
+
|
| 1216 |
+
/* ---- ROSA: online suffix automaton, same bookkeeping as rosa_features() ---- */
|
| 1217 |
+
const G55_EDGES = [1, 2, 3, 4, 6, 8, 12, 16, 24, 32, 48, 64, 128, 256];
|
| 1218 |
+
function g55Bucket(m){ if(m <= 0) return 0; for(let i = 0; i < G55_EDGES.length; i++) if(m <= G55_EDGES[i]) return i + 1; return 15; }
|
| 1219 |
+
function g55RosaReset(R){ R.nxt = [new Map()]; R.link = [-1]; R.ln = [0]; R.pos = [-1]; R.last = 0; }
|
| 1220 |
+
function g55RosaStep(R, xs, i){
|
| 1221 |
+
const c = xs[i]; R.p1 = 0; R.bk = 0;
|
| 1222 |
+
if(c === 0){ g55RosaReset(R); return; }
|
| 1223 |
+
const {nxt, link, ln, pos} = R, cur = nxt.length;
|
| 1224 |
+
nxt.push(new Map()); link.push(0); ln.push(ln[R.last] + 1); pos.push(i);
|
| 1225 |
+
let p = R.last;
|
| 1226 |
+
while(p !== -1 && !nxt[p].has(c)){ nxt[p].set(c, cur); p = link[p]; }
|
| 1227 |
+
if(p === -1) link[cur] = 0;
|
| 1228 |
+
else{
|
| 1229 |
+
const q = nxt[p].get(c);
|
| 1230 |
+
if(ln[p] + 1 === ln[q]) link[cur] = q;
|
| 1231 |
+
else{
|
| 1232 |
+
const cl = nxt.length;
|
| 1233 |
+
nxt.push(new Map(nxt[q])); link.push(link[q]); ln.push(ln[p] + 1); pos.push(pos[q]);
|
| 1234 |
+
while(p !== -1 && nxt[p].get(c) === q){ nxt[p].set(c, cl); p = link[p]; }
|
| 1235 |
+
link[q] = cl; link[cur] = cl;
|
| 1236 |
+
}
|
| 1237 |
+
}
|
| 1238 |
+
R.last = cur;
|
| 1239 |
+
const m = link[cur];
|
| 1240 |
+
if(m > 0 && pos[m] + 1 <= i){ R.p1 = xs[pos[m] + 1] + 1; R.bk = g55Bucket(Math.min(ln[m], 8192)); pos[m] = i; }
|
| 1241 |
+
}
|
| 1242 |
+
|
| 1243 |
+
function g55Mix32(h){
|
| 1244 |
+
h ^= h >>> 16; h = Math.imul(h, 0x7feb352d); h ^= h >>> 15; h = Math.imul(h, 0x846ca68b); h ^= h >>> 16; return h >>> 0;
|
| 1245 |
+
}
|
| 1246 |
+
|
| 1247 |
+
/* ---- per-run state: every cache needed to advance by one byte ---- */
|
| 1248 |
+
function g55Grow(a, need, Ctor){ if(a.length >= need) return a; const n = new Ctor(Math.max(need, a.length * 2)); n.set(a); return n; }
|
| 1249 |
+
function g55NewState(M, cap){
|
| 1250 |
+
const c = M.c, dl = M.dl, d = M.d, S = {
|
| 1251 |
+
n:0, cap, x:new Uint8Array(cap), doc:new Int32Array(cap), logits:new Float32Array(256),
|
| 1252 |
+
pn:Array.from({length:c.ent_layers}, () => new Float32Array(cap * c.ent_d)), // patcher: normalised layer inputs
|
| 1253 |
+
eh:c.enc_blocks.map(k => k === "conv" ? new Float32Array(cap * dl) : null), // encoder conv history
|
| 1254 |
+
ek:c.enc_blocks.map(k => k === "attn" ? new Float32Array(cap * dl) : null), ev:c.enc_blocks.map(k => k === "attn" ? new Float32Array(cap * dl) : null),
|
| 1255 |
+
dk:Array.from({length:c.n_dec}, () => new Float32Array(cap * dl)), dv:Array.from({length:c.n_dec}, () => new Float32Array(cap * dl)),
|
| 1256 |
+
psc:new Float32Array(cap * c.pool_heads), phv:new Float32Array(cap * dl), // pooling scores / values per byte
|
| 1257 |
+
fpos:0, sNext:true, pStart:0, nStarted:0, nClosed:0, pdocs:[], gl:new Float32Array(64 * dl),
|
| 1258 |
+
hPrev:new Uint32Array(Math.max(9, Math.max(...c.hash_orders, 1) + 1)), hCur:new Uint32Array(Math.max(9, Math.max(...c.hash_orders, 1) + 1)),
|
| 1259 |
+
R:{p1:0, bk:0}, lastDoc:-1, cosT:null, sinT:null,
|
| 1260 |
+
tr:{S:[], xp:[], K:[], V:[]}
|
| 1261 |
+
};
|
| 1262 |
+
g55RosaReset(S.R);
|
| 1263 |
+
const half = M.dh >> 1, hh = M.dh;
|
| 1264 |
+
S.cosT = new Float32Array(cap * half); S.sinT = new Float32Array(cap * half);
|
| 1265 |
+
for(let p = 0; p < cap; p++) for(let i = 0; i < half; i++){ const f = p * Math.pow(10000, -(2 * i) / hh); S.cosT[p * half + i] = Math.cos(f); S.sinT[p * half + i] = Math.sin(f); }
|
| 1266 |
+
for(let b = 0; b < M.nb; b++) for(let j = 0; j < M.np; j++){
|
| 1267 |
+
if(c.pattern[j] === "R"){ S.tr.S.push(new Float32Array(M.H * M.hd * M.hd)); S.tr.xp.push(new Float32Array(d)); S.tr.K.push(null); S.tr.V.push(null); }
|
| 1268 |
+
else{ S.tr.S.push(null); S.tr.xp.push(null); S.tr.K.push(new Float32Array(64 * d)); S.tr.V.push(new Float32Array(64 * d)); }
|
| 1269 |
+
}
|
| 1270 |
+
return S;
|
| 1271 |
+
}
|
| 1272 |
+
|
| 1273 |
+
// causal windowed attention of one new position (relative RoPE, window = loc_window, same document only)
|
| 1274 |
+
function g55LocalAttn(M, S, blk, hn, t, Kc, Vc, out){
|
| 1275 |
+
const {dl, dh, c} = M, sc = M.sc, Hh = c.loc_heads, half = dh >> 1, w = c.loc_window, q = sc.q, k = sc.k, v = sc.v, y = sc.y, cs = S.cosT, sn = S.sinT, doc = S.doc;
|
| 1276 |
+
g55Vm(hn, 0, blk.wq, 0, dl, dl, q, 0); g55Vm(hn, 0, blk.wk, 0, dl, dl, k, 0); g55Vm(hn, 0, blk.wv, 0, dl, dl, v, 0);
|
| 1277 |
+
for(let h = 0; h < Hh; h++){
|
| 1278 |
+
const o = h * dh, co = t * half;
|
| 1279 |
+
for(let i = 0; i < half; i++){
|
| 1280 |
+
const cc = cs[co + i], ss = sn[co + i];
|
| 1281 |
+
const q1 = q[o + i], q2 = q[o + half + i]; q[o + i] = q1 * cc - q2 * ss; q[o + half + i] = q1 * ss + q2 * cc;
|
| 1282 |
+
const k1 = k[o + i], k2 = k[o + half + i]; k[o + i] = k1 * cc - k2 * ss; k[o + half + i] = k1 * ss + k2 * cc;
|
| 1283 |
+
}
|
| 1284 |
+
}
|
| 1285 |
+
Kc.set(k, t * dl); Vc.set(v, t * dl);
|
| 1286 |
+
const lo = Math.max(0, t - w + 1), inv = 1 / Math.sqrt(dh), sct = sc.sct, dt = doc[t];
|
| 1287 |
+
for(let h = 0; h < Hh; h++){
|
| 1288 |
+
const o = h * dh; let mx = -Infinity;
|
| 1289 |
+
for(let p = lo; p <= t; p++){
|
| 1290 |
+
if(doc[p] !== dt){ sct[p - lo] = -Infinity; continue; }
|
| 1291 |
+
let s = 0; const po = p * dl + o; for(let i = 0; i < dh; i++) s += q[o + i] * Kc[po + i];
|
| 1292 |
+
s *= inv; sct[p - lo] = s; if(s > mx) mx = s;
|
| 1293 |
+
}
|
| 1294 |
+
let sum = 0; for(let p = lo; p <= t; p++){ const e = sct[p - lo] === -Infinity ? 0 : Math.exp(sct[p - lo] - mx); sct[p - lo] = e; sum += e; }
|
| 1295 |
+
for(let i = 0; i < dh; i++) y[o + i] = 0;
|
| 1296 |
+
for(let p = lo; p <= t; p++){ const a = sct[p - lo] / sum; if(a === 0) continue; const po = p * dl + o; for(let i = 0; i < dh; i++) y[o + i] += a * Vc[po + i]; }
|
| 1297 |
+
}
|
| 1298 |
+
g55Vm(y, 0, blk.wo, 0, dl, dl, out, 0);
|
| 1299 |
+
}
|
| 1300 |
+
|
| 1301 |
+
// one local block (encoder or decoder) for the new position. x (dl) is updated in place.
|
| 1302 |
+
function g55LocalBlock(M, S, p, kind, x, t, byte, hist, Kc, Vc){
|
| 1303 |
+
const {dl, c} = M, W = M.W, sc = M.sc, ff = c.loc_ffn, h = sc.a, tmp = sc.t;
|
| 1304 |
+
g55Rms(x, 0, W[p + ".n1"], dl, h, 0);
|
| 1305 |
+
if(kind === "attn"){
|
| 1306 |
+
g55LocalAttn(M, S, {wq:W[p + ".wq"], wk:W[p + ".wk"], wv:W[p + ".wv"], wo:W[p + ".wo"]}, h, t, Kc, Vc, tmp);
|
| 1307 |
+
for(let i = 0; i < dl; i++) x[i] += tmp[i];
|
| 1308 |
+
}else{
|
| 1309 |
+
hist.set(h.subarray(0, dl), t * dl);
|
| 1310 |
+
const cw = W[p + ".conv"], K = c.conv_k, doc = S.doc;
|
| 1311 |
+
for(let i = 0; i < dl; i++) x[i] += cw[(K - 1) * dl + i] * h[i];
|
| 1312 |
+
for(let i = 0; i < K - 1; i++){
|
| 1313 |
+
const tp = t - (K - 1 - i); if(tp < 0 || doc[tp] !== doc[t]) continue;
|
| 1314 |
+
const o = tp * dl, wo = i * dl; for(let j = 0; j < dl; j++) x[j] += cw[wo + j] * hist[o + j];
|
| 1315 |
+
}
|
| 1316 |
+
}
|
| 1317 |
+
const h2 = sc.b, g = sc.g, u = sc.u;
|
| 1318 |
+
g55Rms(x, 0, W[p + ".n2"], dl, h2, 0);
|
| 1319 |
+
g55Vm(h2, 0, W[p + ".ffn.w1"], 0, dl, ff, g, 0); g55Vm(h2, 0, W[p + ".ffn.w3"], 0, dl, ff, u, 0);
|
| 1320 |
+
if(c.de_byte){ const de = W[p + ".de"], o = byte * ff; for(let j = 0; j < ff; j++) g[j] = g55Silu(g[j]) * u[j] * (1 + de[o + j]); }
|
| 1321 |
+
else for(let j = 0; j < ff; j++) g[j] = g55Silu(g[j]) * u[j];
|
| 1322 |
+
g55Vm(g, 0, W[p + ".ffn.w2"], 0, ff, dl, x, 0, true);
|
| 1323 |
+
}
|
| 1324 |
+
|
| 1325 |
+
// attention pooling of the closed patch [s, s+n) -> sc.o (d)
|
| 1326 |
+
function g55Pool(M, S, s, n){
|
| 1327 |
+
const {dl, d, c, dhp} = M, W = M.W, sc = M.sc, Hp = c.pool_heads, pool = sc.pool, sct = sc.sct;
|
| 1328 |
+
for(let h = 0; h < Hp; h++){
|
| 1329 |
+
let mx = -Infinity; for(let k = 0; k < n; k++){ const v = S.psc[(s + k) * Hp + h]; sct[k] = v; if(v > mx) mx = v; }
|
| 1330 |
+
let sum = 0; for(let k = 0; k < n; k++){ sct[k] = Math.exp(sct[k] - mx); sum += sct[k]; }
|
| 1331 |
+
for(let i = 0; i < dhp; i++) pool[h * dhp + i] = 0;
|
| 1332 |
+
for(let k = 0; k < n; k++){ const a = sct[k] / sum, o = (s + k) * dl + h * dhp; for(let i = 0; i < dhp; i++) pool[h * dhp + i] += a * S.phv[o + i]; }
|
| 1333 |
+
}
|
| 1334 |
+
g55Vm(pool, 0, W["pool.wo"], 0, dl, dl, sc.pool2, 0);
|
| 1335 |
+
g55Vm(sc.pool2, 0, W["pool.up"], 0, dl, d, sc.ya, 0);
|
| 1336 |
+
const le = W["pool.len_emb"], lo = (Math.min(Math.max(n, 1), 16) - 1) * d;
|
| 1337 |
+
for(let i = 0; i < d; i++) sc.ya[i] += le[lo + i];
|
| 1338 |
+
g55Rms(sc.ya, 0, W["pool.pool_nf"], d, sc.pv, 0);
|
| 1339 |
+
}
|
| 1340 |
+
|
| 1341 |
+
// one patch (sc.pv, document id) through the 20-layer trunk; leaves rms_norm(nf) of the result in sc.o. mutates S.tr.
|
| 1342 |
+
function g55TrunkStep(M, S, docId){
|
| 1343 |
+
const {c, d, hd, H, nb, np} = M, sc = M.sc, T = S.tr, W = M.W, x = sc.x, h = sc.h, h2 = sc.h2, vf = sc.vf, N = hd, npt = S.nClosed; // npt = index of this patch
|
| 1344 |
+
const newDoc = docId !== S.lastDoc, ffn = c.ffn;
|
| 1345 |
+
x.set(sc.pv); vf.fill(0);
|
| 1346 |
+
for(let b = 0; b < nb; b++) for(let j = 0; j < np; j++){
|
| 1347 |
+
const L = M.trunk[b][j], idx = b * np + j;
|
| 1348 |
+
g55Rms(x, 0, L.n1, d, h, 0, L.s);
|
| 1349 |
+
const y = sc.ya;
|
| 1350 |
+
if(L.kind === "A"){
|
| 1351 |
+
const q = sc.pq, k = sc.pk, v = sc.pv2 || (sc.pv2 = new Float32Array(d));
|
| 1352 |
+
g55Vm(h, 0, L.wq, 0, d, d, q, 0); g55Vm(h, 0, L.wk, 0, d, d, k, 0); g55Vm(h, 0, L.wv, 0, d, d, v, 0);
|
| 1353 |
+
if(c.qk_norm) for(let hh = 0; hh < H; hh++){ g55Rms(q, hh * hd, L.qn, hd, q, hh * hd); g55Rms(k, hh * hd, L.kn, hd, k, hh * hd); }
|
| 1354 |
+
T.K[idx] = g55Grow(T.K[idx], (npt + 1) * d, Float32Array); T.V[idx] = g55Grow(T.V[idx], (npt + 1) * d, Float32Array);
|
| 1355 |
+
const Kc = T.K[idx], Vc = T.V[idx]; Kc.set(k, npt * d); Vc.set(v, npt * d);
|
| 1356 |
+
const inv = 1 / Math.sqrt(hd), sct = sc.sct.length > npt + 1 ? sc.sct : (sc.sct = new Float32Array((npt + 1) * 2));
|
| 1357 |
+
if(c.attn_gate) g55Vm(h, 0, L.gw, 0, d, H, sc.gt, 0);
|
| 1358 |
+
for(let hh = 0; hh < H; hh++){
|
| 1359 |
+
const o = hh * hd; let mx = -Infinity;
|
| 1360 |
+
for(let p = 0; p <= npt; p++){
|
| 1361 |
+
if(S.pdocs[p] !== docId){ sct[p] = -Infinity; continue; }
|
| 1362 |
+
let s = 0; const po = p * d + o; for(let i = 0; i < hd; i++) s += q[o + i] * Kc[po + i];
|
| 1363 |
+
s *= inv; sct[p] = s; if(s > mx) mx = s;
|
| 1364 |
+
}
|
| 1365 |
+
let sum = 0; for(let p = 0; p <= npt; p++){ const e = sct[p] === -Infinity ? 0 : Math.exp(sct[p] - mx); sct[p] = e; sum += e; }
|
| 1366 |
+
const gate = c.attn_gate ? g55Sig(sc.gt[hh] + L.gb[hh]) : 1;
|
| 1367 |
+
for(let i = 0; i < hd; i++) sc.o[o + i] = 0;
|
| 1368 |
+
for(let p = 0; p <= npt; p++){ const a = sct[p] / sum; if(a === 0) continue; const po = p * d + o; for(let i = 0; i < hd; i++) sc.o[o + i] += a * Vc[po + i]; }
|
| 1369 |
+
for(let i = 0; i < hd; i++) sc.o[o + i] *= gate;
|
| 1370 |
+
}
|
| 1371 |
+
g55Vm(sc.o, 0, L.wo, 0, d, d, y, 0);
|
| 1372 |
+
}else{
|
| 1373 |
+
const St = T.S[idx], xp = T.xp[idx];
|
| 1374 |
+
if(newDoc){ St.fill(0); xp.fill(0); }
|
| 1375 |
+
const xr = sc.xr, xw = sc.xw, xk = sc.xk, xv = sc.xv, xa = sc.xa, xg = sc.xg;
|
| 1376 |
+
for(let i = 0; i < d; i++){
|
| 1377 |
+
const dx = xp[i] - h[i];
|
| 1378 |
+
xr[i] = h[i] + dx * L.x_r[i]; xw[i] = h[i] + dx * L.x_w[i]; xk[i] = h[i] + dx * L.x_k[i];
|
| 1379 |
+
xv[i] = h[i] + dx * L.x_v[i]; xa[i] = h[i] + dx * L.x_a[i]; xg[i] = h[i] + dx * L.x_g[i];
|
| 1380 |
+
}
|
| 1381 |
+
xp.set(h);
|
| 1382 |
+
const r = sc.r, k = sc.kx, v = sc.vv, low = sc.low, lw = sc.lw, aa = sc.aa, gg = sc.gg, kk = sc.kk;
|
| 1383 |
+
g55Vm(xr, 0, L.Wr, 0, d, d, r, 0); g55Vm(xk, 0, L.Wk, 0, d, d, k, 0); g55Vm(xv, 0, L.Wv, 0, d, d, v, 0);
|
| 1384 |
+
const Ld = c.lora_decay; g55Vm(xw, 0, L.w1, 0, d, Ld, low, 0); for(let i = 0; i < Ld; i++) low[i] = Math.tanh(low[i]);
|
| 1385 |
+
g55Vm(low, 0, L.w2, 0, Ld, d, lw, 0); const EH = Math.exp(-0.5);
|
| 1386 |
+
for(let i = 0; i < d; i++) lw[i] = Math.exp(-g55Sig(L.w0[i] + lw[i]) * EH); // lw now holds the per-channel decay exp(log_w)
|
| 1387 |
+
if(b === 0 && j === 0) vf.set(v);
|
| 1388 |
+
else{
|
| 1389 |
+
const Lv = c.lora_v; g55Vm(xv, 0, L.v1, 0, d, Lv, low, 0); g55Vm(low, 0, L.v2, 0, Lv, d, sc.o, 0);
|
| 1390 |
+
for(let i = 0; i < d; i++) v[i] += (vf[i] - v[i]) * g55Sig(L.v0[i] + sc.o[i]);
|
| 1391 |
+
}
|
| 1392 |
+
const La = c.lora_a; g55Vm(xa, 0, L.a1, 0, d, La, low, 0); g55Vm(low, 0, L.a2, 0, La, d, aa, 0);
|
| 1393 |
+
for(let i = 0; i < d; i++) aa[i] = g55Sig(L.a0[i] + aa[i]);
|
| 1394 |
+
const Lg = c.lora_g; g55Vm(xg, 0, L.g1, 0, d, Lg, low, 0); for(let i = 0; i < Lg; i++) low[i] = g55Sig(low[i]);
|
| 1395 |
+
g55Vm(low, 0, L.g2, 0, Lg, d, gg, 0);
|
| 1396 |
+
for(let hh = 0; hh < H; hh++){
|
| 1397 |
+
const o = hh * N; let s = 0;
|
| 1398 |
+
for(let i = 0; i < N; i++){ const z = k[o + i] * L.k_k[o + i]; kk[o + i] = z; s += z * z; }
|
| 1399 |
+
const inv = 1 / Math.sqrt(s + 1e-24); for(let i = 0; i < N; i++) kk[o + i] *= inv;
|
| 1400 |
+
}
|
| 1401 |
+
for(let i = 0; i < d; i++) k[i] *= 1 + (aa[i] - 1) * L.k_a[i];
|
| 1402 |
+
for(let hh = 0; hh < H; hh++){
|
| 1403 |
+
const o = hh * N, so = hh * N * N;
|
| 1404 |
+
let mu = 0, va = 0;
|
| 1405 |
+
for(let i = 0; i < N; i++){
|
| 1406 |
+
let skk = 0; const ro = so + i * N; for(let jj = 0; jj < N; jj++) skk += St[ro + jj] * kk[o + jj];
|
| 1407 |
+
const vi = v[o + i]; let yy = 0;
|
| 1408 |
+
for(let jj = 0; jj < N; jj++){
|
| 1409 |
+
const sv = St[ro + jj] * lw[o + jj] - skk * (kk[o + jj] * aa[o + jj]) + vi * k[o + jj];
|
| 1410 |
+
St[ro + jj] = sv; yy += sv * r[o + jj];
|
| 1411 |
+
}
|
| 1412 |
+
y[o + i] = yy; mu += yy;
|
| 1413 |
+
}
|
| 1414 |
+
mu /= N; for(let i = 0; i < N; i++){ const z = y[o + i] - mu; va += z * z; } va /= N;
|
| 1415 |
+
const rs = 1 / Math.sqrt(va + 64e-5); let bonus = 0;
|
| 1416 |
+
for(let i = 0; i < N; i++) bonus += r[o + i] * k[o + i] * L.r_k[o + i];
|
| 1417 |
+
for(let i = 0; i < N; i++) y[o + i] = ((y[o + i] - mu) * rs * L.ln_w[o + i] + L.ln_b[o + i] + bonus * v[o + i]) * gg[o + i];
|
| 1418 |
+
}
|
| 1419 |
+
g55Vm(y, 0, L.Wo, 0, d, d, sc.o, 0); y.set(sc.o.subarray(0, d));
|
| 1420 |
+
}
|
| 1421 |
+
for(let i = 0; i < d; i++) x[i] += y[i];
|
| 1422 |
+
g55Rms(x, 0, L.n2, d, h2, 0, L.s);
|
| 1423 |
+
g55Vm(h2, 0, L.fw1, 0, d, ffn, sc.f1, 0); g55Vm(h2, 0, L.fw3, 0, d, ffn, sc.f3, 0);
|
| 1424 |
+
for(let i = 0; i < ffn; i++) sc.f1[i] = g55Silu(sc.f1[i]) * sc.f3[i];
|
| 1425 |
+
g55Vm(sc.f1, 0, L.fw2, 0, ffn, d, x, 0, true);
|
| 1426 |
+
}
|
| 1427 |
+
S.lastDoc = docId;
|
| 1428 |
+
g55Rms(x, 0, W["nf"], d, sc.o, 0);
|
| 1429 |
+
}
|
| 1430 |
+
|
| 1431 |
+
/* ---- advance by one byte. Fills S.logits (next-byte logits) when wantLogits. ---- */
|
| 1432 |
+
function g55Step(M, S, b, wantLogits){
|
| 1433 |
+
const {c, W, dl, d} = M, sc = M.sc, t = S.n, ed = c.ent_d, Hn = c.n_hash;
|
| 1434 |
+
if(t >= S.cap) throw new Error("Gen-5.5 state is full.");
|
| 1435 |
+
S.x[t] = b; S.doc[t] = t === 0 ? 0 : S.doc[t - 1] + (S.x[t - 1] === 0 ? 1 : 0);
|
| 1436 |
+
const dc = S.doc[t];
|
| 1437 |
+
// patch start of this byte (decided by the previous step)
|
| 1438 |
+
if(S.sNext){ S.pStart = t; S.nStarted++; S.pdocs.push(dc); }
|
| 1439 |
+
// --- entropy patcher (frozen causal TCN)
|
| 1440 |
+
let h = sc.g; const pe = W["patcher.emb"]; for(let i = 0; i < ed; i++) h[i] = pe[b * ed + i];
|
| 1441 |
+
const hb = sc.a, tmp = sc.b;
|
| 1442 |
+
for(let l = 0; l < c.ent_layers; l++){
|
| 1443 |
+
const p = "patcher.layers." + l, cw = W[p + ".conv"], K = c.ent_k, dil = 1 << l, pn = S.pn[l];
|
| 1444 |
+
g55Rms(h, 0, W[p + ".n1"], ed, hb, 0); pn.set(hb.subarray(0, ed), t * ed);
|
| 1445 |
+
for(let i = 0; i < ed; i++) h[i] += cw[(K - 1) * ed + i] * hb[i];
|
| 1446 |
+
for(let i = 0; i < K - 1; i++){
|
| 1447 |
+
const tp = t - (K - 1 - i) * dil; if(tp < 0 || S.doc[tp] !== dc) continue;
|
| 1448 |
+
const o = tp * ed, wo = i * ed; for(let j = 0; j < ed; j++) h[j] += cw[wo + j] * pn[o + j];
|
| 1449 |
+
}
|
| 1450 |
+
g55Rms(h, 0, W[p + ".n2"], ed, hb, 0);
|
| 1451 |
+
const ef = c.ent_ffn; g55Vm(hb, 0, W[p + ".ffn.w1"], 0, ed, ef, sc.f1, 0); g55Vm(hb, 0, W[p + ".ffn.w3"], 0, ed, ef, sc.f3, 0);
|
| 1452 |
+
for(let j = 0; j < ef; j++) sc.f1[j] = g55Silu(sc.f1[j]) * sc.f3[j];
|
| 1453 |
+
g55Vm(sc.f1, 0, W[p + ".ffn.w2"], 0, ef, ed, h, 0, true);
|
| 1454 |
+
}
|
| 1455 |
+
g55Rms(h, 0, W["patcher.nf"], ed, hb, 0); g55Vm(hb, 0, W["patcher.head"], 0, ed, 256, sc.lg, 0);
|
| 1456 |
+
let mxl = -Infinity; for(let i = 0; i < 256; i++) if(sc.lg[i] > mxl) mxl = sc.lg[i];
|
| 1457 |
+
let se = 0; for(let i = 0; i < 256; i++) se += Math.exp(sc.lg[i] - mxl);
|
| 1458 |
+
const lse = mxl + Math.log(se); let ent = 0; for(let i = 0; i < 256; i++){ const lp = sc.lg[i] - lse; ent -= Math.exp(lp) * lp; }
|
| 1459 |
+
// does the NEXT byte start a patch? (only depends on bytes seen so far)
|
| 1460 |
+
const force = b === 0 || ent > Number(c.theta);
|
| 1461 |
+
if(t === 0) S.fpos = 0;
|
| 1462 |
+
if(force) S.fpos = t + 1;
|
| 1463 |
+
const sNext = force || (((t + 1) - S.fpos) % c.patch_max_len === 0);
|
| 1464 |
+
// --- byte embedding: emb_in + ROSA + hashed n-grams
|
| 1465 |
+
const x = sc.enc, ei = W["emb_in"]; for(let i = 0; i < dl; i++) x[i] = ei[b * dl + i];
|
| 1466 |
+
let p1 = 0, bk = 0;
|
| 1467 |
+
if(c.rosa){
|
| 1468 |
+
g55RosaStep(S.R, S.x, t); p1 = S.R.p1; bk = S.R.bk;
|
| 1469 |
+
const rpe = W["rosa.pe"], rlg = W["rosa.lg"], rlb = W["rosa.lb"];
|
| 1470 |
+
for(let i = 0; i < dl; i++) x[i] += rpe[p1 * dl + i] * rlg[bk * dl + i] + rlb[bk * dl + i];
|
| 1471 |
+
}
|
| 1472 |
+
if(Hn){
|
| 1473 |
+
const hc = S.hCur, hp = S.hPrev, u = (b + 1) >>> 0, hd2 = c.hash_dim, tab = W["hash_table"], ent2 = sc.ent, maxN = Math.max(...c.hash_orders);
|
| 1474 |
+
hc[1] = u; for(let n = 2; n <= maxN; n++) hc[n] = (Math.imul(hp[n - 1], 0x9E3779B1) + u) >>> 0;
|
| 1475 |
+
let off = 0;
|
| 1476 |
+
for(let oi = 0; oi < Hn; oi++){
|
| 1477 |
+
const n = c.hash_orders[oi], nr = c.hash_rows[oi], valid = t >= n - 1 && S.doc[t - (n - 1)] === dc;
|
| 1478 |
+
const row = off + (g55Mix32((hc[n] ^ (Math.imul(n, 0x85EBCA6B) >>> 0)) >>> 0) % nr);
|
| 1479 |
+
for(let i = 0; i < hd2; i++) ent2[oi * hd2 + i] = valid ? tab[row * hd2 + i] : 0;
|
| 1480 |
+
off += nr;
|
| 1481 |
+
}
|
| 1482 |
+
for(let n = 1; n <= maxN; n++) hp[n] = hc[n];
|
| 1483 |
+
const nh = Hn * hd2; g55Rms(ent2, 0, W["hash_nw"], nh, sc.pk, 0);
|
| 1484 |
+
g55Vm(sc.pk, 0, W["hash_proj"], 0, nh, dl, x, 0, true);
|
| 1485 |
+
}
|
| 1486 |
+
// --- local encoder
|
| 1487 |
+
c.enc_blocks.forEach((kind, i) => g55LocalBlock(M, S, "enc." + i, kind, x, t, b, S.eh[i], S.ek[i], S.ev[i]));
|
| 1488 |
+
g55Rms(x, 0, W["enc_nf"], dl, x, 0);
|
| 1489 |
+
// pooling inputs for this byte
|
| 1490 |
+
const Hp = c.pool_heads, ws = W["pool.ws"];
|
| 1491 |
+
g55Vm(x, 0, ws, 0, dl, Hp, sc.gt, 0);
|
| 1492 |
+
for(let hh = 0; hh < Hp; hh++) S.psc[t * Hp + hh] = 5 * Math.tanh(sc.gt[hh] / 5);
|
| 1493 |
+
g55Vm(x, 0, W["pool.wv"], 0, dl, dl, sc.pool, 0); S.phv.set(sc.pool.subarray(0, dl), t * dl);
|
| 1494 |
+
// --- the patch ends here: pool it and advance the trunk by one step
|
| 1495 |
+
if(sNext){
|
| 1496 |
+
const s = S.pStart, n = t - s + 1;
|
| 1497 |
+
g55Pool(M, S, s, n);
|
| 1498 |
+
g55TrunkStep(M, S, S.pdocs[S.nClosed]);
|
| 1499 |
+
S.gl = g55Grow(S.gl, (S.nClosed + 1) * dl, Float32Array);
|
| 1500 |
+
g55Vm(sc.o, 0, W["down"], 0, d, dl, sc.gl, 0);
|
| 1501 |
+
g55Rms(sc.gl, 0, W["down_nf"], dl, sc.t, 0); S.gl.set(sc.t.subarray(0, dl), S.nClosed * dl);
|
| 1502 |
+
S.nClosed++;
|
| 1503 |
+
}
|
| 1504 |
+
S.sNext = sNext;
|
| 1505 |
+
// --- decoder input: encoder output + latent of the latest closed patch (BOS if none / other document)
|
| 1506 |
+
const didx = S.nClosed, u = sc.hrow, bos = W["bos"];
|
| 1507 |
+
if(didx > 0 && S.pdocs[didx - 1] === dc){ const o = (didx - 1) * dl; for(let i = 0; i < dl; i++) u[i] = x[i] + S.gl[o + i]; }
|
| 1508 |
+
else for(let i = 0; i < dl; i++) u[i] = x[i] + bos[i];
|
| 1509 |
+
for(let i = 0; i < c.n_dec; i++) g55LocalBlock(M, S, "dec." + i, "attn", u, t, b, null, S.dk[i], S.dv[i]);
|
| 1510 |
+
if(wantLogits){
|
| 1511 |
+
g55Rms(u, 0, W["dec_nf"], dl, sc.t, 0);
|
| 1512 |
+
g55Vm(sc.t, 0, M.headc, 0, dl, 256, S.logits, 0);
|
| 1513 |
+
if(c.rosa && p1 > 0) S.logits[p1 - 1] += W["rosa.boost"][bk];
|
| 1514 |
+
}
|
| 1515 |
+
S.n = t + 1;
|
| 1516 |
+
}
|
| 1517 |
+
|
| 1518 |
+
/* ---- sampling + streaming ---- */
|
| 1519 |
+
async function g55Generate(M, prompt, onToken, o){
|
| 1520 |
+
const c = M.c, limit = c.seq_len, maxIn = Math.max(0, Math.min(o.maxTokens, limit));
|
| 1521 |
+
let bytes = Array.from(new TextEncoder().encode(prompt));
|
| 1522 |
+
if(!bytes.length) bytes = [32];
|
| 1523 |
+
if(bytes.length + maxIn > limit) bytes = bytes.slice(-Math.max(1, limit - maxIn));
|
| 1524 |
+
const maxNew = Math.min(maxIn, limit - bytes.length);
|
| 1525 |
+
if(!maxNew) return;
|
| 1526 |
+
const S = g55NewState(M, bytes.length + maxNew), dec = new TextDecoder("utf-8"), eod = o.eod === undefined ? 0 : o.eod;
|
| 1527 |
+
for(let p = 0; p < bytes.length; p++){
|
| 1528 |
+
g55Step(M, S, bytes[p], p === bytes.length - 1);
|
| 1529 |
+
if(p % 6 === 5) await new Promise(r => setTimeout(r, 0)); // keep the page responsive while the prompt is read
|
| 1530 |
+
}
|
| 1531 |
+
const lg = new Float32Array(256);
|
| 1532 |
+
for(let n = 0; n < maxNew; n++){
|
| 1533 |
+
lg.set(S.logits);
|
| 1534 |
+
let pick = 0;
|
| 1535 |
+
if(!(o.temperature > 0)){ for(let i = 1; i < 256; i++) if(lg[i] > lg[pick]) pick = i; }
|
| 1536 |
+
else{
|
| 1537 |
+
let thr = -Infinity;
|
| 1538 |
+
if(o.topK > 0 && o.topK < 256) thr = Array.from(lg).sort((a, b) => b - a)[o.topK - 1];
|
| 1539 |
+
let mx = -Infinity; for(let i = 0; i < 256; i++) if(lg[i] >= thr && lg[i] > mx) mx = lg[i];
|
| 1540 |
+
let sum = 0; const pr = new Float64Array(256);
|
| 1541 |
+
for(let i = 0; i < 256; i++) if(lg[i] >= thr){ pr[i] = Math.exp((lg[i] - mx) / o.temperature); sum += pr[i]; }
|
| 1542 |
+
let r = Math.random() * sum; pick = 255;
|
| 1543 |
+
for(let i = 0; i < 256; i++){ r -= pr[i]; if(pr[i] > 0 && r <= 0){ pick = i; break; } }
|
| 1544 |
+
}
|
| 1545 |
+
if(pick === eod && o.stopAtEod) break;
|
| 1546 |
+
if(pick !== 0) onToken(dec.decode(new Uint8Array([pick]), {stream:true}));
|
| 1547 |
+
if(n === maxNew - 1) break;
|
| 1548 |
+
g55Step(M, S, pick, true);
|
| 1549 |
+
await new Promise(r => setTimeout(r, 0));
|
| 1550 |
+
}
|
| 1551 |
+
}
|
| 1552 |
+
|
| 1553 |
const NATIVE_ARCHS = {
|
| 1554 |
+
notokengen55:{build:g55Build, plan:g55Plan, generate:g55Generate, supports:cfg => /gen55/i.test(String(cfg.model_type))}, // hierarchical byte-level hybrid (patcher + RWKV-7/attention trunk)
|
| 1555 |
+
notokenlm:{build:ntBuild, plan:ntPlan, generate:ntGenerate, supports:cfg => !/gen55/i.test(String(cfg.model_type)) && (cfg.vocab_size || 256) === 256}, // byte-level only
|
| 1556 |
+
gpt:{build:gptBuild, plan:gptPlan, generate:ntGenerate, supports:cfg => !/gen55/i.test(String(cfg.model_type))} // byte-level (256) or character-level with a vocabulary file
|
| 1557 |
};
|
| 1558 |
/* ---- end built-in engines ---- */
|
| 1559 |
|
|
|
|
| 1663 |
}catch(e){
|
| 1664 |
console.error(e);
|
| 1665 |
engines.delete(current.id);
|
| 1666 |
+
const full = String((e && e.message) || e);
|
| 1667 |
+
console.error("[" + current.id + "] full error:", full);
|
| 1668 |
+
if(/Missing tensor|not found in model\.safetensors|Unsupported extra tensors|different architecture/i.test(full)){
|
| 1669 |
+
current.runnable = false; current.whyNot = full; // definite architecture mismatch: remember it
|
| 1670 |
+
stat.textContent = t("sErrArch");
|
| 1671 |
+
document.querySelectorAll("button[data-id]").forEach(b => { if(b.dataset.id === current.id){ b.disabled = true; b.title = t("noRun"); } });
|
| 1672 |
+
}else{
|
| 1673 |
+
stat.textContent = t("sErrRun") + " [" + full.slice(0, 300) + (full.length > 300 ? "…" : "") + "]";
|
| 1674 |
+
}
|
| 1675 |
}
|
| 1676 |
go.disabled = false;
|
| 1677 |
};
|