Poucet demo: web/ at 6cac1b8
Browse filesFiles changed (5)
- assets/index-wrasL7ZU.jsAdded+4
- assets/poucet_web_bg-EKZ7t1Wd.wasmAdded+3
- assets/worker-BYAMVPsw.jsAdded+5
- index.html+3-1
- manifest.json+34
1234(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))n(s);new MutationObserver(s=>{for(const l of s)if(l.type==="childList")for(const u of l.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&n(u)}).observe(document,{childList:!0,subtree:!0});function o(s){const l={};return s.integrity&&(l.integrity=s.integrity),s.referrerPolicy&&(l.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?l.credentials="include":s.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function n(s){if(s.ep)return;s.ep=!0;const l=o(s);fetch(s.href,l)}})();const K="Poucet: a small model that remembers what you tell it",T={title:K,"brand.tagline":"a 30M-parameter language model with a pebble memory","lang.label":"Language","intro.heading":"Meet Poucet","intro.what":"Poucet is a very small language model (30 million parameters, about the size of a children's-book reader). It learned English from child-directed text and a made-up world. When you tell it something, it may keep a pebble: a short, exact piece of what you wrote, with a note of how often it helped later.","intro.not":"It is not an assistant. It knows almost nothing about the real world, it cannot follow instructions, and its English is that of a young child. Ask it about what you told it, in a short question.","intro.local":"Everything stays in this browser. The model runs on this device; your lines and its pebbles are stored here, in this browser's private storage, and never sent anywhere. You can export them, delete them, or clear the site's data at any time.","intro.size":"The first visit downloads the model once (about {mb} MB) from Hugging Face; later visits load it from this browser's cache.","intro.start":"Wake Poucet","intro.how.heading":"How to talk to it","intro.how.tell":'Type a fact about your life, for example "My sister Inès lives in Lyon." Poucet reads it and may keep a pebble.',"intro.how.ask":'End a line with a question mark to ask, for example "Where does Inès live?" Poucet answers with its memory, and beside it the same model with its memory switched off.',"intro.how.colours":"Each answer word is tinted by where it came from: memory, habit (its weights) or unknown.","load.base":"Model file (port and tokenizer)","load.backbone":"Backbone weights","load.engine":"Starting the engine","load.store":"Restoring the memory","load.done":"Ready","load.failed":"Poucet could not start: {error}","load.mb":"{done} / {total} MB","visits.first":"First visit. Nothing is stored yet.","visits.back":"Back after {days}. {pebbles} pebbles restored.","visits.back.folded":"Back after {days}. {pebbles} pebbles restored, {folded} folded into habit since.","visits.verified":"The memory is exactly as you left it (state {hash}).","visits.mismatch":"The stored memory does not match what was saved last time (expected {expected}, found {found}).","visits.recovered":"The memory file was damaged; the backup copy was restored.","duration.minutes":"{n} minutes","duration.hours":"{n} hours","duration.days":"{n} days","duration.moment":"a moment","talk.heading":"Talk","talk.placeholder":"Tell Poucet something, or ask a question ending with ?","talk.send":"Send","talk.hint":"A line ending with ? is answered. Any other line is read and may be remembered. Enter sends, Shift+Enter adds a line.","talk.examples.heading":"Try these","talk.examples.note":"Lines typed the way the demo build reads them best (English only). Click one to put it in the box, then send it. Each pair was checked in a fresh visit, alone and with all the other facts told before the questions. The last question is about something you never said.","talk.examples.tell":"Tell it","talk.examples.ask":"Then ask","talk.poucet":"Poucet","talk.preamble":"Poucet's own words, read at the start of every visit so that your first lines are remembered more often (on their own, the first lines of a visit are rarely read back). They are never stored.","talk.you":"You","talk.withMemory":"With memory","talk.memoryOff":"Memory off","talk.unknown":"does not know yet","talk.empty":"Nothing said yet.","talk.thinking":"reading…","talk.speed":"{rate} tokens/s","receipt.wrote":"kept a new pebble #{id}","receipt.credited":"pebble #{id} helped: {nats} nats","receipt.harmed":"pebble #{id} got in the way: {nats} nats","receipt.reinstated":"brought back pebble #{id} from the reserve","receipt.erased":"erased pebble #{id}","receipt.toReserve":"moved pebble #{id} to the reserve","receipt.nothing":"nothing to learn","readout.memory":"memory","readout.habit":"habit","readout.unknown":"unknown","legend.heading":"Colours","tip.readout":"From","tip.pOpen":"p(open)","tip.pClosed":"p(closed)","tip.mass":"memory mass","tip.sources":"read from","tip.noSources":"no pebble read","pebbles.heading":"Pebbles","pebbles.count":"{live} live, {reserve} in reserve","pebbles.empty":"No pebble yet. Tell Poucet something about your life.","pebbles.col.text":"Text","pebbles.col.origin":"Origin","pebbles.col.status":"Status","pebbles.col.E":"E (nats)","pebbles.col.net":"r − h","pebbles.col.age":"Age","pebbles.col.actions":"","pebbles.pin":"Pin","pebbles.unpin":"Unpin","pebbles.forget":"Forget","pebbles.forget.confirm":"Forget pebble #{id} for good?","pebbles.age.days":"{n} d","pebbles.showReserve":"Show the reserve","origin.world":"world","origin.user":"you","origin.parent":"parent","origin.self":"self","status.quarantine":"new","status.earned":"earned","status.reserve":"reserve","status.retired":"retired","life.heading":"Life","life.day":"Day {day}","life.store":"{bytes} stored","life.own.heading":"Own life","life.own.text":"The day file holds every pebble and its ledger. Export it to keep it, to move it to another browser, or to fold it into habit at night with the project's night script.","life.export":"Export the day file","life.import":"Import a day file","life.import.done":"Imported: {pebbles} pebbles.","life.import.failed":"This file is not a day file of this model: {error}","life.reset":"Forget everything","life.reset.confirm":"Delete every pebble stored in this browser?","life.scripted.heading":"Scripted life","life.scripted.text":"A scripted life (the world stream of the pilot, with the habit files of its nights) arrives with the pilot (milestone M5).","footer.model":"Model","footer.runtime":"Runtime","footer.verified":"files verified","footer.local":"Nothing leaves this browser unless you export it.","footer.code":"Code and specification","settings.heading":"Settings","settings.runtime":"Runtime","settings.runtime.webslm":"webslm (the Hugging Face checkpoint) with the pebble port","settings.runtime.engine":"poucet-engine (the reference engine, all in one module)","settings.device":"Device","settings.device.auto":"automatic","settings.device.cpu":"CPU","settings.device.webgpu":"WebGPU","settings.apply":"Apply and reload","settings.close":"Close","error.generic":"Something went wrong: {error}","intro.nights":"This version keeps pebbles only. Poucet does not fold them into its weights at night: the pre-registered night test failed (folding new facts in erased what the model already knew), so the memory-off answer will not learn from what you tell it.","load.habit":"Exploratory habit","life.nights.heading":"Nights","life.nights.off":"Store only. No night runs here: the memory-off twin stays the gestation base, whatever you tell Poucet.","life.nights.exploratory":"Exploratory habit (not pre-registered)","life.nights.exploratory.none":"none (the gestation base)","life.nights.exploratory.option":"{set}, after night {night}","life.nights.exploratory.note":"Exploratory habit files are published with the model: M3B is one night, M5A the habit after each night that was kept of five nights in a row (each file holds every night up to it). They were made outside the pre-registration, from another stream than yours, and erase some of what the base knew, more with each night. Applying one changes the weights only, not your pebbles.","life.nights.exploratory.applied":"Exploratory habit applied (night {night}).","life.nights.exploratory.failed":"The exploratory habit could not be applied: {error}","intro.build.demo":'This page runs the demo build of Poucet (maxgfr/poucet-demo): the same model, trained a little longer on lines typed the way visitors type them. It is exploratory and was not pre-registered. On held-out lines of that kind it answered about 42% of the questions from what it was told; otherwise it says "does not know yet". On freer phrasing it does much worse, and it is not an assistant. The canonical model of the experiment is in the settings.',"intro.build.canonical":"This page runs the canonical model of the experiment (maxgfr/poucet), as pre-registered. It was trained on a made-up world and rarely reads back lines typed the way visitors type them; the demo build in the settings does.","intro.english":"Poucet reads and writes English only: type your lines in English, even when this page is in another language.","settings.model":"Model","settings.model.demo":"demo build (maxgfr/poucet-demo, exploratory, not pre-registered)","settings.model.canonical":"canonical base (maxgfr/poucet, pre-registered)","load.embedder":"Embedding model (chooses what a question reads)","talk.mode.chat":`Chat mode: every line you state is kept as a pebble, and the pebbles' credit decides what stays; Poucet's own address picks what a question reads. It reads back more of what you told it than stream mode, but about something it was never told it says "does not know yet" a little less often, so it is not the default. Stream mode is at ?mode=stream; a variant where an embedding model picks what a question reads is at ?mode=chat-meaning.`,"talk.mode.chatMeaning":"Chat mode by meaning: every line you state is kept as a pebble, and the pebbles' credit decides what stays. A small embedding model ({repo}, {license} licence) picks the pebbles a question reads; Poucet's own memory then points at the answer inside them. It reads back less of what you told it than the other modes. Stream mode is at ?mode=stream, chat mode at ?mode=chat.","talk.mode.stream":"Stream mode: a line is kept as a pebble only when it surprises Poucet, and Poucet's own address picks what a question reads. Chat mode (every line kept) is at ?mode=chat; with an embedding model picking what a question reads, at ?mode=chat-meaning.","footer.address":"Address by meaning"},_="Poucet : un petit modèle qui se souvient de ce que vous lui dites",J={title:_,"brand.tagline":"un modèle de langue de 30 M de paramètres, avec une mémoire de cailloux","lang.label":"Langue","intro.heading":"Voici Poucet","intro.what":"Poucet est un tout petit modèle de langue (30 millions de paramètres, à peu près le niveau d'un lecteur d'albums). Il a appris l'anglais dans des textes adressés aux enfants et dans un monde inventé. Quand vous lui dites quelque chose, il peut garder un caillou : un court extrait exact de ce que vous avez écrit, avec une note de combien il a servi ensuite.","intro.not":"Ce n'est pas un assistant. Il ne sait presque rien du monde réel, il ne suit pas d'instructions et son anglais est celui d'un jeune enfant. Interrogez-le sur ce que vous lui avez dit, par une question courte, en anglais.","intro.local":"Tout reste dans ce navigateur. Le modèle tourne sur cet appareil ; vos phrases et ses cailloux sont rangés ici, dans le stockage privé de ce navigateur, et ne sont envoyés nulle part. Vous pouvez les exporter, les effacer ou supprimer les données du site à tout moment.","intro.size":"La première visite télécharge le modèle une fois (environ {mb} Mo) depuis Hugging Face ; les visites suivantes le chargent depuis le cache de ce navigateur.","intro.start":"Réveiller Poucet","intro.how.heading":"Comment lui parler","intro.how.tell":"Écrivez un fait de votre vie, en anglais, par exemple « My sister Inès lives in Lyon. » Poucet le lit et peut garder un caillou.","intro.how.ask":"Terminez une ligne par un point d'interrogation pour poser une question, par exemple « Where does Inès live? » Poucet répond avec sa mémoire et, à côté, le même modèle mémoire coupée.","intro.how.colours":"Chaque mot de réponse est teinté selon sa source : mémoire, habitude (ses poids) ou inconnu.","load.base":"Fichier du modèle (port et tokeniseur)","load.backbone":"Poids du réseau","load.engine":"Démarrage du moteur","load.store":"Restauration de la mémoire","load.done":"Prêt","load.failed":"Poucet n'a pas pu démarrer : {error}","load.mb":"{done} / {total} Mo","visits.first":"Première visite. Rien n'est encore rangé.","visits.back":"De retour après {days}. {pebbles} cailloux restaurés.","visits.back.folded":"De retour après {days}. {pebbles} cailloux restaurés, {folded} passés dans l'habitude depuis.","visits.verified":"La mémoire est exactement comme vous l'avez laissée (état {hash}).","visits.mismatch":"La mémoire rangée ne correspond pas à la dernière sauvegarde (attendu {expected}, trouvé {found}).","visits.recovered":"Le fichier de mémoire était abîmé ; la copie de secours a été restaurée.","duration.minutes":"{n} minutes","duration.hours":"{n} heures","duration.days":"{n} jours","duration.moment":"un instant","talk.heading":"Parler","talk.placeholder":"Dites quelque chose à Poucet, ou posez une question finissant par ?","talk.send":"Envoyer","talk.hint":"Une ligne finissant par ? reçoit une réponse. Toute autre ligne est lue et peut être retenue. Entrée envoie, Maj+Entrée ajoute une ligne.","talk.examples.heading":"Essayez ceux-ci","talk.examples.note":"Des lignes tapées comme la version de démonstration les lit le mieux (en anglais seulement). Cliquez sur une ligne pour la mettre dans la zone de saisie, puis envoyez-la. Chaque paire a été vérifiée dans une visite neuve, seule et avec tous les autres faits dits avant les questions. La dernière question porte sur quelque chose que vous n'avez jamais dit.","talk.examples.tell":"Dites-lui","talk.examples.ask":"Puis demandez","talk.poucet":"Poucet","talk.preamble":"Les mots de Poucet lui-même, lus au début de chaque visite pour que vos premières lignes soient retenues plus souvent (sans eux, les premières lignes d'une visite sont rarement relues). Ils ne sont jamais retenus eux-mêmes.","talk.you":"Vous","talk.withMemory":"Avec mémoire","talk.memoryOff":"Mémoire coupée","talk.unknown":"ne sait pas encore","talk.empty":"Rien n'a encore été dit.","talk.thinking":"lecture…","talk.speed":"{rate} jetons/s","receipt.wrote":"a gardé un nouveau caillou n°{id}","receipt.credited":"le caillou n°{id} a servi : {nats} nats","receipt.harmed":"le caillou n°{id} a gêné : {nats} nats","receipt.reinstated":"a ressorti le caillou n°{id} de la réserve","receipt.erased":"a effacé le caillou n°{id}","receipt.toReserve":"a rangé le caillou n°{id} dans la réserve","receipt.nothing":"rien à apprendre","readout.memory":"mémoire","readout.habit":"habitude","readout.unknown":"inconnu","legend.heading":"Couleurs","tip.readout":"Source","tip.pOpen":"p(ouvert)","tip.pClosed":"p(fermé)","tip.mass":"masse mémoire","tip.sources":"lu dans","tip.noSources":"aucun caillou lu","pebbles.heading":"Cailloux","pebbles.count":"{live} actifs, {reserve} en réserve","pebbles.empty":"Aucun caillou pour l'instant. Dites à Poucet quelque chose de votre vie.","pebbles.col.text":"Texte","pebbles.col.origin":"Origine","pebbles.col.status":"Statut","pebbles.col.E":"E (nats)","pebbles.col.net":"r − h","pebbles.col.age":"Âge","pebbles.col.actions":"","pebbles.pin":"Épingler","pebbles.unpin":"Désépingler","pebbles.forget":"Oublier","pebbles.forget.confirm":"Oublier définitivement le caillou n°{id} ?","pebbles.age.days":"{n} j","pebbles.showReserve":"Afficher la réserve","origin.world":"monde","origin.user":"vous","origin.parent":"parent","origin.self":"lui-même","status.quarantine":"nouveau","status.earned":"mérité","status.reserve":"réserve","status.retired":"retiré","life.heading":"Vie","life.day":"Jour {day}","life.store":"{bytes} rangés","life.own.heading":"Votre vie","life.own.text":"Le fichier du jour contient tous les cailloux et leur registre. Exportez-le pour le garder, le passer à un autre navigateur, ou le replier dans l'habitude la nuit avec le script de nuit du projet.","life.export":"Exporter le fichier du jour","life.import":"Importer un fichier du jour","life.import.done":"Importé : {pebbles} cailloux.","life.import.failed":"Ce fichier n'est pas un fichier du jour de ce modèle : {error}","life.reset":"Tout oublier","life.reset.confirm":"Effacer tous les cailloux rangés dans ce navigateur ?","life.scripted.heading":"Vie scénarisée","life.scripted.text":"Une vie scénarisée (le flux du monde du pilote, avec les fichiers d'habitude de ses nuits) arrive avec le pilote (jalon M5).","footer.model":"Modèle","footer.runtime":"Moteur","footer.verified":"fichiers vérifiés","footer.local":"Rien ne quitte ce navigateur, sauf si vous l'exportez.","footer.code":"Code et spécification","settings.heading":"Réglages","settings.runtime":"Moteur","settings.runtime.webslm":"webslm (le checkpoint Hugging Face) avec le port des cailloux","settings.runtime.engine":"poucet-engine (le moteur de référence, en un seul module)","settings.device":"Matériel","settings.device.auto":"automatique","settings.device.cpu":"CPU","settings.device.webgpu":"WebGPU","settings.apply":"Appliquer et recharger","settings.close":"Fermer","error.generic":"Un problème est survenu : {error}","intro.nights":"Cette version garde seulement des cailloux. Poucet ne les replie pas dans ses poids la nuit : le test de nuit pré-enregistré a échoué (replier de nouveaux faits effaçait ce que le modèle savait déjà), donc la réponse mémoire coupée n'apprendra pas de ce que vous lui dites.","load.habit":"Habitude exploratoire","life.nights.heading":"Nuits","life.nights.off":"Mémoire seule. Aucune nuit ne tourne ici : le jumeau mémoire coupée reste le modèle de base, quoi que vous disiez à Poucet.","life.nights.exploratory":"Habitude exploratoire (non pré-enregistrée)","life.nights.exploratory.none":"aucune (le modèle de base)","life.nights.exploratory.option":"{set}, après la nuit {night}","life.nights.exploratory.note":"Des fichiers d'habitude exploratoires sont publiés avec le modèle : M3B est une nuit, M5A l'habitude après chaque nuit retenue de cinq nuits de suite (chaque fichier contient toutes les nuits jusqu'à elle). Ils ont été faits hors pré-enregistrement, à partir d'un autre flux que le vôtre, et effacent une partie de ce que le modèle de base savait, davantage à chaque nuit. En appliquer un change seulement les poids, pas vos cailloux.","life.nights.exploratory.applied":"Habitude exploratoire appliquée (nuit {night}).","life.nights.exploratory.failed":"L'habitude exploratoire n'a pas pu être appliquée : {error}","intro.build.demo":"Cette page fait tourner la version de démonstration de Poucet (maxgfr/poucet-demo) : le même modèle, entraîné un peu plus longtemps sur des lignes tapées comme les tapent les visiteurs. Elle est exploratoire et n'a pas été pré-enregistrée. Sur des lignes de ce genre qu'il n'avait jamais vues, il a répondu à environ 42 % des questions à partir de ce qu'on lui avait dit ; sinon il dit « ne sait pas encore ». Sur des formulations plus libres il fait bien moins bien, et ce n'est pas un assistant. Le modèle canonique de l'expérience se choisit dans les réglages.","intro.build.canonical":"Cette page fait tourner le modèle canonique de l'expérience (maxgfr/poucet), tel que pré-enregistré. Il a été entraîné sur un monde inventé et relit rarement des lignes tapées comme les tapent les visiteurs ; la version de démonstration, dans les réglages, le fait.","intro.english":"Poucet lit et écrit en anglais seulement : tapez vos lignes en anglais, même quand cette page est dans une autre langue.","settings.model":"Modèle","settings.model.demo":"version de démonstration (maxgfr/poucet-demo, exploratoire, non pré-enregistrée)","settings.model.canonical":"base canonique (maxgfr/poucet, pré-enregistrée)","load.embedder":"Modèle d'embeddings (choisit ce qu'une question lit)","talk.mode.chat":"Mode conversation : chaque ligne où vous affirmez quelque chose est gardée comme caillou, et le crédit des cailloux décide de ce qui reste ; l'adresse de Poucet choisit ce qu'une question lit. Il retrouve davantage de ce que vous lui avez dit que le mode flux, mais sur ce qu'on ne lui a jamais dit il répond « ne sait pas encore » un peu moins souvent : ce n'est donc pas le mode par défaut. Le mode flux est à ?mode=stream ; une variante où un modèle d'embeddings choisit ce qu'une question lit est à ?mode=chat-meaning.","talk.mode.chatMeaning":"Mode conversation par le sens : chaque ligne où vous affirmez quelque chose est gardée comme caillou, et le crédit des cailloux décide de ce qui reste. Un petit modèle d'embeddings ({repo}, licence {license}) choisit les cailloux qu'une question lit ; la mémoire de Poucet pointe ensuite la réponse à l'intérieur. Il retrouve moins de ce que vous lui avez dit que les autres modes. Le mode flux est à ?mode=stream, le mode conversation à ?mode=chat.","talk.mode.stream":"Mode flux : une ligne n'est gardée comme caillou que si elle surprend Poucet, et l'adresse de Poucet choisit ce qu'une question lit. Le mode conversation (chaque ligne gardée) est à ?mode=chat ; avec un modèle d'embeddings qui choisit ce qu'une question lit, à ?mode=chat-meaning.","footer.address":"Adresse par le sens"},k={en:T,fr:J},Q=Object.keys(k),A="poucet.lang";let y="en";function X(){const t=new URLSearchParams(location.search).get("lang"),e=localStorage.getItem(A),o=(navigator.language||"en").slice(0,2).toLowerCase();for(const n of[t,e,o])if(n&&n in k)return n;return"en"}function P(t){y=t in k?t:"en",localStorage.setItem(A,y),document.documentElement.lang=y,document.title=i("title");for(const e of document.querySelectorAll("[data-i18n]"))e.textContent=i(e.dataset.i18n);for(const e of document.querySelectorAll("[data-i18n-placeholder]"))e.setAttribute("placeholder",i(e.dataset.i18nPlaceholder));for(const e of document.querySelectorAll("[data-i18n-label]"))e.setAttribute("aria-label",i(e.dataset.i18nLabel))}function i(t,e={}){return(k[y]?.[t]??T[t]??t).replace(/\{(\w+)\}/g,(n,s)=>s in e?String(e[s]):`{${s}}`)}function g(t,e=2){return new Intl.NumberFormat(y,{maximumFractionDigits:e,minimumFractionDigits:e}).format(t)}function Z(t){const e=y==="fr"?["o","ko","Mo","Go"]:["B","kB","MB","GB"];let o=0,n=t;for(;n>=1e3&&o<e.length-1;)n/=1e3,o++;return`${new Intl.NumberFormat(y,{maximumFractionDigits:o?1:0}).format(n)} ${e[o]}`}function ee(t){return t<120?i("duration.moment"):t<7200?i("duration.minutes",{n:Math.round(t/60)}):t<2*86400?i("duration.hours",{n:Math.round(t/3600)}):i("duration.days",{n:Math.round(t/86400)})}const a=t=>document.getElementById(t),v=new URLSearchParams(location.search);let w,te=1;const E=new Map;function f(t,e={}){if(!w)throw new Error("not started");const o=te++;return new Promise((n,s)=>{E.set(o,{resolve:n,reject:s,...e}),w.postMessage({id:o,req:t})})}function oe(){w=new Worker(new URL(""+new URL("worker-BYAMVPsw.js",import.meta.url).href,import.meta.url),{type:"module"}),w.addEventListener("message",t=>{const e=t.data,o=E.get(e.id);o&&(e.kind==="progress"?o.onProgress?.(e.progress):e.kind==="token"?o.onToken?.(e.lane,e.token):(E.delete(e.id),e.ok?o.resolve(e.value):o.reject(new Error(e.error))))})}const R="poucet.runtime",j="poucet.device",O="poucet.started",$="poucet.exploratory.habit",z="poucet.model",ne={demo:"manifest.json",canonical:"manifest-canonical.json"};function x(){const t=v.get("runtime")??localStorage.getItem(R)??"webslm",e=v.get("device")??localStorage.getItem(j)??"auto",o=v.get("model")??localStorage.getItem(z)??"demo",n=v.get("mode");return{runtime:t==="engine"?"engine":"webslm",device:e==="cpu"||e==="webgpu"?e:"auto",model:o==="canonical"?"canonical":"demo",mode:n==="chat"||n==="chat-meaning"||n==="stream"?n:void 0}}function ie(){const t={};for(const e of["liveCap","reserveCap","tauOpen"]){const o=v.get(e);o!==null&&(t[e]=Number(o))}return Object.keys(t).length?t:void 0}let h,U,D=!1;function r(t,e,o){const n=document.createElement(t);return e&&(n.className=e),o!==void 0&&(n.textContent=o),n}function se(t){const e=[];for(const o of t){o.wrote&&e.push(i("receipt.wrote",{id:o.wrote}));for(const n of o.credited)n.relief>0?e.push(i("receipt.credited",{id:n.pebble,nats:g(n.relief,1)})):e.push(i("receipt.harmed",{id:n.pebble,nats:g(n.relief,1)}));o.reinstated&&e.push(i("receipt.reinstated",{id:o.reinstated}));for(const n of o.toReserve)e.push(i("receipt.toReserve",{id:n}));for(const n of o.erased)e.push(i("receipt.erased",{id:n}))}return e.length?e.join(" · "):i("receipt.nothing")}const L=()=>a("tip");function C(t,e){const o=L();o.replaceChildren();const n=r("dl"),s=(d,c)=>{n.append(r("dt",void 0,i(d)),r("dd",void 0,c))};s("tip.readout",i(`readout.${e.readout}`)),s("tip.pOpen",g(e.pOpen,3)),s("tip.pClosed",g(e.pClosed,3)),s("tip.mass",g(e.memoryMass,3)),o.append(n);const l=r("div",void 0,e.sources.length?i("tip.sources"):i("tip.noSources"));if(l.style.marginTop="0.35rem",o.append(l),e.sources.length){const d=r("ul");for(const c of e.sources)d.append(r("li",void 0,`#${c.pebble} (${g(c.mass,2)}): ${c.text.trim()}`));o.append(d)}o.hidden=!1;const u=t.getBoundingClientRect(),p=o.offsetWidth;o.style.left=`${Math.max(8,Math.min(window.innerWidth-p-8,u.left))}px`,o.style.top=`${u.bottom+6}px`}function B(t){const e=r("span",`tok ${t.readout}`,t.text);return e.tabIndex=0,e.dataset.readout=t.readout,e.addEventListener("mouseenter",()=>C(e,t)),e.addEventListener("focus",()=>C(e,t)),e.addEventListener("mouseleave",()=>L().hidden=!0),e.addEventListener("blur",()=>L().hidden=!0),e}function S(t,e){const o=r("div","answer");o.dataset.lane=e,o.append(r("span","label",i(t)));const n=r("span","body");return o.append(n),{box:o,body:n}}function M(t,e,o){if(e.replaceChildren(),o.unknown)e.append(r("span","dk",i("talk.unknown"))),t.dataset.unknown="true";else for(const s of o.tokens)e.append(B(s));t.dataset.text=o.text,t.dataset.ids=o.tokens.map(s=>s.id).join(",");const n=r("span","speed",i("talk.speed",{rate:g(o.tokensPerSecond,0)}));t.insertBefore(n,t.firstChild)}async function F(t){const e=t.split(``).map(o=>o.trim()).filter(Boolean);for(const o of e)o.endsWith("?")?await H(o):await N(o);await b()}async function N(t){const e=r("li","entry");e.dataset.kind="fed";const o=r("p","said");o.append(r("span","who",i("talk.you")),document.createTextNode(t));const n=r("p","receipt",i("talk.thinking"));e.append(o,n),q(e);const s=await f({type:"feed",text:`${t}`});return n.textContent=se(s),e.dataset.wrote=s.filter(l=>l.wrote).map(l=>l.wrote).join(","),s}async function H(t){const e=r("li","entry");e.dataset.kind="asked";const o=r("p","said");o.append(r("span","who",i("talk.you")),document.createTextNode(t));const n=r("div","answers"),s=S("talk.withMemory","open"),l=S("talk.memoryOff","closed");n.append(s.box,l.box),e.append(o,n),q(e);const u=await f({type:"ask",question:t},{onToken:(p,d)=>(p==="open"?s:l).body.append(B(d))});return M(s.box,s.body,u.open),M(l.box,l.body,u.closed),u.address&&(e.dataset.address=u.address.map(p=>p.pebble).join(",")),e.dataset.done="true",u}function ae(t){if(!t)return;const e=r("li","entry");e.dataset.kind="preamble";for(const o of t.split(``).filter(Boolean)){const n=r("p","said");n.append(r("span","who",i("talk.poucet")),document.createTextNode(o)),e.append(n)}e.append(r("p","receipt",i("talk.preamble"))),q(e)}function q(t){const e=a("transcript");e.append(t),a("transcript-empty").hidden=!0,e.scrollTop=e.scrollHeight}async function b(){const[t,e]=await Promise.all([f({type:"pebbles",reserve:D}),f({type:"store"})]);U=e,re(t),le(e)}function re(t){const e=a("pebble-table").querySelector("tbody");e.replaceChildren();for(const o of[...t].reverse()){const n=r("tr");n.dataset.id=o.id,n.dataset.status=o.status,o.pinned&&n.classList.add("pinned");const s=r("td",void 0,o.text.trim());s.title=`#${o.id}`;const l=r("td");l.append(r("span",`status ${o.status}`,i(`status.${o.status}`)));const u=r("td","actions"),p=r("button","ghost",o.pinned?i("pebbles.unpin"):i("pebbles.pin"));p.type="button",p.addEventListener("click",async()=>{await f({type:"pin",id:o.id,on:!o.pinned}),await b()});const d=r("button","ghost danger",i("pebbles.forget"));d.type="button",d.addEventListener("click",async()=>{confirm(i("pebbles.forget.confirm",{id:o.id}))&&(await f({type:"forget",id:o.id}),await b())}),u.append(p,d),n.append(s,r("td",void 0,i(`origin.${o.origin}`)),l,r("td","num",g(o.E,1)),r("td","num",String(o.r-o.h)),r("td","num",i("pebbles.age.days",{n:o.ageDays})),u),e.append(n)}a("pebbles-empty").hidden=t.length>0}function le(t){a("pebble-count").textContent=i("pebbles.count",{live:t.live,reserve:t.reserve}),a("life-day").textContent=i("life.day",{day:t.day}),a("life-store").textContent=i("life.store",{bytes:Z(t.bytes)}),document.body.dataset.stateHash=t.stateHash}function W(t){const e=t.visit,o=a("visits");o.replaceChildren(),o.classList.toggle("warn",!e.first&&!e.verified);const n=s=>o.append(r("div",void 0,s));if(e.first)n(i("visits.first"));else{const s=ee(e.secondsAway);n(e.folded?i("visits.back.folded",{days:s,pebbles:e.pebbles,folded:e.folded}):i("visits.back",{days:s,pebbles:e.pebbles})),e.recoveredFromBackup&&n(i("visits.recovered")),e.verified?n(i("visits.verified",{hash:e.foundHash.slice(0,12)})):e.expectedHash&&n(i("visits.mismatch",{expected:e.expectedHash.slice(0,12),found:e.foundHash.slice(0,12)}))}o.dataset.verified=String(e.verified),o.hidden=!1}async function de(){try{const t=await fetch(new URL("examples.json",document.baseURI).href);if(!t.ok)return;const e=await t.json(),o=(n,s)=>{const l=a(n);l.replaceChildren();for(const u of s){const p=r("button",void 0,u);p.type="button",p.lang="en",p.addEventListener("click",()=>{const c=a("line");c.value=u,c.focus()});const d=r("li");d.append(p),l.append(d)}};o("examples-facts",e.facts),o("examples-questions",e.questions),a("examples").hidden=!1}catch{}}function V(t){const e=t.exploratory;a("exploratory").hidden=!e.available||x().model!=="canonical";const o=a("exploratory-select");o.replaceChildren();const n=document.createElement("option");n.value="",n.textContent=i("life.nights.exploratory.none"),o.append(n);for(const l of e.habits){const u=document.createElement("option");u.value=l.id,u.textContent=i("life.nights.exploratory.option",{set:l.set.toUpperCase(),night:l.night}),o.append(u)}o.value=e.applied&&e.appliedId?e.appliedId:"";const s=a("exploratory-msg");s.textContent=e.error?i("life.nights.exploratory.failed",{error:e.error}):e.applied?i("life.nights.exploratory.applied",{night:e.night??"?"}):"",e.refused&&console.warn(`exploratory habit not offered: ${e.refused}`),document.body.dataset.exploratory=e.applied?"applied":e.available?"available":e.refused?"refused":"none"}function Y(t){const e=a("talk-mode");document.body.dataset.mode=t.mode,t.mode==="chat-meaning"&&t.address?e.textContent=i("talk.mode.chatMeaning",{repo:t.address.repo,license:t.address.license}):t.mode==="chat"?e.textContent=i("talk.mode.chat"):t.chatAvailable&&(e.textContent=i("talk.mode.stream")),e.hidden=!(t.mode!=="stream"||t.chatAvailable)}function G(t){const e=a("foot-model"),o=t.baseSha256.slice(0,12);e.textContent=`${i("footer.model")}: ${t.modelRepo} · ${t.modelFile} ${o}… · ${t.filesVerified?i("footer.verified"):""}`,a("foot-runtime").textContent=`${i("footer.runtime")}: ${t.backend}`;const n=t.address;a("foot-address").textContent=n?`${i("footer.address")}: ${n.repo} @ ${n.revision.slice(0,8)} (${n.license}), τ = ${g(n.tau,3)}`:"",a("foot-address").hidden=!n,document.body.dataset.runtime=t.runtime,document.body.dataset.backend=t.backend}const ue={base:"load.base",backbone:"load.backbone",engine:"load.engine",store:"load.store",habit:"load.habit",embedder:"load.embedder"};async function I(){const t=a("start");t.disabled=!0,a("progress").hidden=!1,a("load-error").hidden=!0,oe();const e=x(),o={manifestUrl:new URL(ne[e.model],document.baseURI).href,runtime:e.runtime,device:e.device,gates:ie(),clockOffset:Number(v.get("clockOffset")??0),exploratory:e.model==="canonical"?localStorage.getItem($)??void 0:void 0,lookForHabit:e.model==="canonical",mode:e.mode};try{h=await f({type:"init",options:o},{onProgress:n=>{a("progress-label").textContent=i(ue[n.phase]);const s=a("progress-bar");n.total?(s.value=(n.loaded??0)/n.total,a("progress-mb").textContent=i("load.mb",{done:g((n.loaded??0)/1e6,0),total:g(n.total/1e6,0)})):(s.removeAttribute("value"),a("progress-mb").textContent="")}})}catch(n){a("progress").hidden=!0;const s=a("load-error");s.textContent=i("load.failed",{error:n.message}),s.hidden=!1,t.disabled=!1;return}localStorage.setItem(O,"1"),a("progress").hidden=!0,t.hidden=!0,a("app").hidden=!1,a("intro").classList.add("compact"),W(h),G(h),Y(h),V(h),ae(h.preamble),de(),await b(),document.body.dataset.ready="true",a("line").focus()}function ce(){const t=a("lang");for(const d of Q)t.append(new Option(d.toUpperCase(),d));const e=X();t.value=e,P(e);const o=()=>{a("intro-size").textContent=i("intro.size",{mb:153}),a("intro-build").textContent=i(x().model==="demo"?"intro.build.demo":"intro.build.canonical")};o(),t.addEventListener("change",()=>{P(t.value),o(),h&&(W(h),G(h),Y(h),V(h),b())}),a("start").addEventListener("click",()=>{I()});const n=a("say"),s=a("line"),l=a("send");n.addEventListener("submit",async d=>{d.preventDefault();const c=s.value;if(!(!c.trim()||l.disabled)){s.value="",l.disabled=!0;try{await F(c)}catch(m){q(Object.assign(r("li","entry error"),{textContent:i("error.generic",{error:m.message})}))}finally{l.disabled=!1,s.focus()}}}),s.addEventListener("keydown",d=>{d.key==="Enter"&&!d.shiftKey&&(d.preventDefault(),n.requestSubmit())}),a("show-reserve").addEventListener("change",d=>{D=d.target.checked,b()}),a("export").addEventListener("click",async()=>{const d=await f({type:"exportDay"}),c=URL.createObjectURL(new Blob([d],{type:"application/octet-stream"})),m=r("a");m.href=c,m.download=`poucet-day-${new Date().toISOString().slice(0,10)}.pbs`,m.click(),setTimeout(()=>URL.revokeObjectURL(c),1e4)}),a("import").addEventListener("change",async d=>{const c=d.target.files?.[0];if(c){try{const m=await f({type:"importDay",bytes:new Uint8Array(await c.arrayBuffer())});a("life-msg").textContent=i("life.import.done",{pebbles:m.live+m.reserve})}catch(m){a("life-msg").textContent=i("life.import.failed",{error:m.message})}await b()}}),a("reset").addEventListener("click",async()=>{confirm(i("life.reset.confirm"))&&(await f({type:"resetStore"}),await b())}),a("exploratory-select").addEventListener("change",d=>{localStorage.setItem($,d.target.value),location.reload()});const u=a("settings");a("open-settings").addEventListener("click",()=>{const d=x();for(const c of u.querySelectorAll("input[name=runtime]"))c.checked=c.value===d.runtime;for(const c of u.querySelectorAll("input[name=device]"))c.checked=c.value===d.device;for(const c of u.querySelectorAll("input[name=model]"))c.checked=c.value===d.model;u.showModal()}),u.addEventListener("close",()=>{if(u.returnValue!=="apply")return;const d=u.querySelector("input[name=runtime]:checked")?.value,c=u.querySelector("input[name=device]:checked")?.value;d&&localStorage.setItem(R,d),c&&localStorage.setItem(j,c);const m=u.querySelector("input[name=model]:checked")?.value;m&&localStorage.setItem(z,m),location.reload()});const p=()=>{w&&h&&f({type:"save"}).catch(()=>{})};document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&p()}),window.addEventListener("pagehide",p),(v.get("autostart")==="1"||localStorage.getItem(O)==="1")&&I()}window.poucetDemo={request:f,say:F,feedLine:N,askLine:H,ready:()=>h,store:()=>U};ce();123version https://git-lfs.github.com/spec/v1oid sha256:6991f39369205ab8d44b0fa0a7921a476d52d45ca32a45085dba34d8983f6a61size 41445112345class F{static __wrap(e){const t=Object.create(F.prototype);return t.__wbg_ptr=e,_e.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,_e.unregister(this),e}free(){const e=this.__destroy_into_raw();i.__wbg_poucet_free(e,0)}appendTokens(e){const t=j(e,i.__wbindgen_malloc),n=u,s=i.poucet_appendTokens(this.__wbg_ptr,t,n);if(s[1])throw p(s[0])}applyHabitWeights(e){const t=D(e,i.__wbindgen_malloc),n=u,s=i.poucet_applyHabitWeights(this.__wbg_ptr,t,n);if(s[2])throw p(s[1]);return p(s[0])}applyHabit(e){const t=D(e,i.__wbindgen_malloc),n=u,s=i.poucet_applyHabit(this.__wbg_ptr,t,n);if(s[2])throw p(s[1]);return p(s[0])}clearSegments(){i.poucet_clearSegments(this.__wbg_ptr)}contextDrop(e){i.poucet_contextDrop(this.__wbg_ptr,e)}contextRestore(e){const t=i.poucet_contextRestore(this.__wbg_ptr,e);if(t[1])throw p(t[0])}contextSave(){return i.poucet_contextSave(this.__wbg_ptr)>>>0}contextTokens(){const e=i.poucet_contextTokens(this.__wbg_ptr);var t=ne(e[0],e[1]).slice();return i.__wbindgen_free(e[0],e[1]*4,4),t}detokenize(e){let t,n;try{const s=j(e,i.__wbindgen_malloc),o=u,a=i.poucet_detokenize(this.__wbg_ptr,s,o);return t=a[0],n=a[1],W(a[0],a[1])}finally{i.__wbindgen_free(t,n,1)}}exportDay(){const e=i.poucet_exportDay(this.__wbg_ptr);var t=re(e[0],e[1]).slice();return i.__wbindgen_free(e[0],e[1]*1,1),t}external(){return i.poucet_external(this.__wbg_ptr)!==0}feedEvent(e,t){const n=j(e,i.__wbindgen_malloc),s=u,o=i.poucet_feedEvent(this.__wbg_ptr,n,s,t);if(o[2])throw p(o[1]);return p(o[0])}feed(e,t){const n=m(e,i.__wbindgen_malloc,i.__wbindgen_realloc),s=u,o=i.poucet_feed(this.__wbg_ptr,n,s,t);if(o[2])throw p(o[1]);return p(o[0])}fillRandomPebbles(e,t,n){i.poucet_fillRandomPebbles(this.__wbg_ptr,e,t,n)}forget(e){const t=i.poucet_forget(this.__wbg_ptr,e);if(t[1])throw p(t[0])}genBegin(){i.poucet_genBegin(this.__wbg_ptr)}genNext(e){const t=i.poucet_genNext(this.__wbg_ptr,e);if(t[2])throw p(t[1]);return p(t[0])}genText(){let e,t;try{const n=i.poucet_genText(this.__wbg_ptr);return e=n[0],t=n[1],W(n[0],n[1])}finally{i.__wbindgen_free(e,t,1)}}generate(e,t,n){const s=m(e,i.__wbindgen_malloc,i.__wbindgen_realloc),o=u,a=i.poucet_generate(this.__wbg_ptr,s,o,t,n);if(a[2])throw p(a[1]);return p(a[0])}info(){return i.poucet_info(this.__wbg_ptr)}static loadPort(e){const t=D(e,i.__wbindgen_malloc),n=u,s=i.poucet_loadPort(t,n);if(s[2])throw p(s[1]);return F.__wrap(s[0])}static load(e,t){const n=D(e,i.__wbindgen_malloc),s=u;var o=S(t)?0:D(t,i.__wbindgen_malloc),a=u;const c=i.poucet_load(n,s,o,a);if(c[2])throw p(c[1]);return F.__wrap(c[0])}parityDump(e,t,n){var s=S(e)?0:m(e,i.__wbindgen_malloc,i.__wbindgen_realloc),o=u,a=S(t)?0:m(t,i.__wbindgen_malloc,i.__wbindgen_realloc),c=u,_=S(n)?0:m(n,i.__wbindgen_malloc,i.__wbindgen_realloc),f=u;const l=i.poucet_parityDump(this.__wbg_ptr,s,o,a,c,_,f);if(l[2])throw p(l[1]);return p(l[0])}pebbles(e){const t=i.poucet_pebbles(this.__wbg_ptr,e);if(t[2])throw p(t[1]);return p(t[0])}pin(e,t){const n=i.poucet_pin(this.__wbg_ptr,e,t);if(n[1])throw p(n[0])}planAppend(e){const t=j(e,i.__wbindgen_malloc),n=u;return i.poucet_planAppend(this.__wbg_ptr,t,n)}planFeed(e){const t=m(e,i.__wbindgen_malloc,i.__wbindgen_realloc),n=u;return i.poucet_planFeed(this.__wbg_ptr,t,n)}planParity(e,t){var n=S(e)?0:m(e,i.__wbindgen_malloc,i.__wbindgen_realloc),s=u,o=S(t)?0:m(t,i.__wbindgen_malloc,i.__wbindgen_realloc),a=u;const c=i.poucet_planParity(this.__wbg_ptr,n,s,o,a);if(c[2])throw p(c[1]);return p(c[0])}planReset(){return i.poucet_planReset(this.__wbg_ptr)}planRestore(e){const t=D(e,i.__wbindgen_malloc),n=u,s=i.poucet_planRestore(this.__wbg_ptr,t,n);if(s[2])throw p(s[1]);return p(s[0])}planTeach(e,t){const n=m(e,i.__wbindgen_malloc,i.__wbindgen_realloc),s=u,o=m(t,i.__wbindgen_malloc,i.__wbindgen_realloc),a=u;return i.poucet_planTeach(this.__wbg_ptr,n,s,o,a)}pushSegment(e,t,n){const s=j(e,i.__wbindgen_malloc),o=u,a=q(t,i.__wbindgen_malloc),c=u;var _=S(n)?0:q(n,i.__wbindgen_malloc),f=u;const l=i.poucet_pushSegment(this.__wbg_ptr,s,o,a,c,_,f);if(l[1])throw p(l[0])}resetContext(){const e=i.poucet_resetContext(this.__wbg_ptr);if(e[1])throw p(e[0])}restore(e){const t=D(e,i.__wbindgen_malloc),n=u,s=i.poucet_restore(this.__wbg_ptr,t,n);if(s[2])throw p(s[1]);return p(s[0])}seedRing(e){const t=q(e,i.__wbindgen_malloc),n=u;return i.poucet_seedRing(this.__wbg_ptr,t,n)!==0}setClock(e){i.poucet_setClock(this.__wbg_ptr,e)}setGates(e){i.poucet_setGates(this.__wbg_ptr,e)}snapshot(){const e=i.poucet_snapshot(this.__wbg_ptr);var t=re(e[0],e[1]).slice();return i.__wbindgen_free(e[0],e[1]*1,1),t}stateHash(){let e,t;try{const n=i.poucet_stateHash(this.__wbg_ptr);return e=n[0],t=n[1],W(n[0],n[1])}finally{i.__wbindgen_free(e,t,1)}}teach(e,t,n){const s=m(e,i.__wbindgen_malloc,i.__wbindgen_realloc),o=u,a=m(t,i.__wbindgen_malloc,i.__wbindgen_realloc),c=u,_=m(n,i.__wbindgen_malloc,i.__wbindgen_realloc),f=u,l=i.poucet_teach(this.__wbg_ptr,s,o,a,c,_,f);if(l[2])throw p(l[1]);return BigInt.asUintN(64,l[0])}tokenize(e){const t=m(e,i.__wbindgen_malloc,i.__wbindgen_realloc),n=u,s=i.poucet_tokenize(this.__wbg_ptr,t,n);var o=ne(s[0],s[1]).slice();return i.__wbindgen_free(s[0],s[1]*4,4),o}}Symbol.dispose&&(F.prototype[Symbol.dispose]=F.prototype.free);function xe(){return{__proto__:null,"./poucet_web_bg.js":{__proto__:null,__wbg_Error_67e7344beaa85059:function(e,t){return Error(W(e,t))},__wbg___wbindgen_boolean_get_7a12af2b3f899c5a:function(e){const t=e,n=typeof t=="boolean"?t:void 0;return S(n)?16777215:n?1:0},__wbg___wbindgen_debug_string_0e68cf47c9cbd9b0:function(e,t){const n=te(t),s=m(n,i.__wbindgen_malloc,i.__wbindgen_realloc),o=u;N().setInt32(e+4,o,!0),N().setInt32(e+0,s,!0)},__wbg___wbindgen_is_bigint_60fc0336cb14f5d7:function(e){return typeof e=="bigint"},__wbg___wbindgen_is_null_5160b3e381865372:function(e){return e===null},__wbg___wbindgen_is_undefined_8c687d0b90d5b524:function(e){return e===void 0},__wbg___wbindgen_number_get_1dc732b810cb937c:function(e,t){const n=t,s=typeof n=="number"?n:void 0;N().setFloat64(e+8,S(s)?0:s,!0),N().setInt32(e+0,!S(s),!0)},__wbg___wbindgen_string_get_92ab86bb19cbc12f:function(e,t){const n=t,s=typeof n=="string"?n:void 0;var o=S(s)?0:m(s,i.__wbindgen_malloc,i.__wbindgen_realloc),a=u;N().setInt32(e+4,a,!0),N().setInt32(e+0,o,!0)},__wbg___wbindgen_throw_5d9e815e6fdf150f:function(e,t){throw new Error(W(e,t))},__wbg_call_269c5566fbede3eb:function(){return H(function(e,t){return e.call(t)},arguments)},__wbg_call_6bcf8d3e20937e46:function(){return H(function(e,t,n){return e.call(t,n)},arguments)},__wbg_from_a39669ce566077da:function(e){return Array.from(e)},__wbg_get_989d0a1309644f2b:function(){return H(function(e,t){return Reflect.get(e,t)},arguments)},__wbg_get_unchecked_363572bdd397d473:function(e,t){return e[t>>>0]},__wbg_isArray_5674713bb7b79043:function(e){return Array.isArray(e)},__wbg_length_4e1adc0d42e23620:function(e){return e.length},__wbg_new_bebc3f4757acf305:function(){return new Object},__wbg_new_ffa92086ea89f79c:function(){return new Array},__wbg_new_from_slice_4ee02165f9de919e:function(e,t){return new Uint8Array(re(e,t))},__wbg_new_from_slice_a500ec81601be48f:function(e,t){return new Uint32Array(ne(e,t))},__wbg_normalize_508c6a234fd446b2:function(e,t,n){return e.normalize(W(t,n))},__wbg_push_bfdf956ba476f65b:function(e,t){return e.push(t)},__wbg_set_a377297433dfea63:function(){return H(function(e,t,n){return Reflect.set(e,t,n)},arguments)},__wbg_toString_093fb401d0dd2449:function(){return H(function(e,t){return e.toString(t)},arguments)},__wbindgen_generic_0000000000000001:function(e){return e},__wbindgen_generic_0000000000000002:function(e,t){return W(e,t)},__wbindgen_generic_0000000000000003:function(e){return BigInt.asUintN(64,e)},__wbindgen_init_externref_table:function(){const e=i.__wbindgen_externrefs,t=e.grow(4);e.set(0,void 0),e.set(t+0,void 0),e.set(t+1,null),e.set(t+2,!0),e.set(t+3,!1)}}}}const _e=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(r=>i.__wbg_poucet_free(r,1));function Ae(r){const e=i.__externref_table_alloc();return i.__wbindgen_externrefs.set(e,r),e}function te(r){const e=typeof r;if(e=="number"||e=="boolean"||r==null)return`${r}`;if(e=="string")return`"${r}"`;if(e=="symbol"){const s=r.description;return s==null?"Symbol":`Symbol(${s})`}if(e=="function"){const s=r.name;return typeof s=="string"&&s.length>0?`Function(${s})`:"Function"}if(Array.isArray(r)){const s=r.length;let o="[";s>0&&(o+=te(r[0]));for(let a=1;a<s;a++)o+=", "+te(r[a]);return o+="]",o}const t=/\[object ([^\]]+)\]/.exec(toString.call(r));let n;if(t&&t.length>1)n=t[1];else return toString.call(r);if(n=="Object")try{return"Object("+JSON.stringify(r)+")"}catch{return"Object"}return r instanceof Error?`${r.name}: ${r.message}${r.stack}`:n}function ne(r,e){return r=r>>>0,ge().subarray(r/4,r/4+e)}function re(r,e){return r=r>>>0,U().subarray(r/1,r/1+e)}let O=null;function N(){return(O===null||O.buffer.detached===!0||O.buffer.detached===void 0&&O.buffer!==i.memory.buffer)&&(O=new DataView(i.memory.buffer)),O}let C=null;function Se(){return(C===null||C.byteLength===0)&&(C=new Float32Array(i.memory.buffer)),C}function W(r,e){return Ee(r>>>0,e)}let P=null;function ge(){return(P===null||P.byteLength===0)&&(P=new Uint32Array(i.memory.buffer)),P}let B=null;function U(){return(B===null||B.byteLength===0)&&(B=new Uint8Array(i.memory.buffer)),B}function H(r,e){try{return r.apply(this,e)}catch(t){const n=Ae(t);i.__wbindgen_exn_store(n)}}function S(r){return r==null}function j(r,e){const t=e(r.length*4,4)>>>0;return ge().set(r,t/4),u=r.length,t}function D(r,e){const t=e(r.length*1,1)>>>0;return U().set(r,t/1),u=r.length,t}function q(r,e){const t=e(r.length*4,4)>>>0;return Se().set(r,t/4),u=r.length,t}function m(r,e,t){if(t===void 0){const c=I.encode(r),_=e(c.length,1)>>>0;return U().subarray(_,_+c.length).set(c),u=c.length,_}let n=r.length,s=e(n,1)>>>0;const o=U();let a=0;for(;a<n;a++){const c=r.charCodeAt(a);if(c>127)break;o[s+a]=c}if(a!==n){a!==0&&(r=r.slice(a)),s=t(s,n,n=a+r.length*3,1)>>>0;const c=U().subarray(s+a,s+n),_=I.encodeInto(r,c);a+=_.written,s=t(s,n,a,1)>>>0}return u=a,s}function p(r){const e=i.__wbindgen_externrefs.get(r);return i.__externref_table_dealloc(r),e}let G=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});G.decode();const Te=2146435072;let ee=0;function Ee(r,e){return ee+=e,ee>=Te&&(G=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),G.decode(),ee=e),G.decode(U().subarray(r,r+e))}const I=new TextEncoder;"encodeInto"in I||(I.encodeInto=function(r,e){const t=I.encode(r);return e.set(t),{read:r.length,written:t.length}});let u=0,i;function $e(r,e){return i=r.exports,O=null,C=null,P=null,B=null,i.__wbindgen_start(),i}async function Re(r,e){if(typeof Response=="function"&&r instanceof Response){if(!r.ok)throw new Error(`failed to fetch Wasm: ${r.status} ${r.statusText} fetching '${r.url}'`);if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(r,e)}catch(s){if(t(r.type)&&r.headers.get("Content-Type")!=="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",s);else throw s}const n=await r.arrayBuffer();return await WebAssembly.instantiate(n,e)}else{const n=await WebAssembly.instantiate(r,e);return n instanceof WebAssembly.Instance?{instance:n,module:r}:n}function t(n){switch(n){case"basic":case"cors":case"default":return!0}return!1}}async function Fe(r){if(i!==void 0)return i;r!==void 0&&(Object.getPrototypeOf(r)===Object.prototype?{module_or_path:r}=r:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),r===void 0&&(r=new URL(""+new URL("poucet_web_bg-EKZ7t1Wd.wasm",import.meta.url).href,import.meta.url));const e=xe();(typeof r=="string"||typeof Request=="function"&&r instanceof Request||typeof URL=="function"&&r instanceof URL)&&(r=fetch(r));const{instance:t,module:n}=await Re(await r,e);return $e(t)}var Me=""+new URL("poucet_web_bg-EKZ7t1Wd.wasm",import.meta.url).href;class De{constructor(e){this.backend=e}backend;external=!1;device="cpu";files=[];async run(){}async fork(){}takeTime(){return 0}async applyAdapter(){throw new Error("the reference engine applies habit files, not PEFT adapters")}}class ce{constructor(e,t,n,s,o){this.model=e,this.readerLayers=t,this.backend=n,this.device=s,this.files=o}model;readerLayers;backend;device;files;external=!0;#e=new Map;#t=0;static async load(e,t,n,s,o,a,c){const _=c?.webslm??await import("./index-Bw4MO8L9.js").then(function(h){return h.B}),f=await Oe(),l=await _.loadModel(c?{files:c.files}:{hub:e,revision:t},{worker:!1,device:s,quant:o.quant,...o.activations?{activations:o.activations}:{},contextLength:256,wasmFlavour:f?"relaxed":"simd",onProgress:h=>{h.overallTotalBytes&&a(h.overallLoadedBytes??0,h.overallTotalBytes)}}),d=l.info(),w=d.files.map(h=>({file:h.file,sha256:h.sha256}));return new ce(l,n,`webslm, ${d.backend}`,d.device,w)}async#n(e){let t=this.#e.get(e);return t||(t=await this.model.session(),this.#e.set(e,t)),t}async run(e,t,n){const s=performance.now(),o=await this.#n(n),a=this.readerLayers;for(const c of t){const _=c.kind==="rows";c.fresh&&await o.reset();const f=_&&c.tokens.length===1&&!c.fresh?await o.step(c.tokens[0],{logits:!0,hiddenStates:[a]}):await o.score(c.tokens,{logits:_?"all":"none",hiddenStates:[a]}),l=f.hidden[a];if(!l)throw new Error(`webslm returned no hidden state ${a}`);e.pushSegment(c.tokens,l,_?f.logits:void 0)}this.#t+=performance.now()-s}async fork(e,t){const n=await this.#n(e),s=this.#e.get(t);s&&await s.dispose(),this.#e.set(t,await n.fork())}takeTime(){const e=this.#t;return this.#t=0,e}async applyAdapter(e){await this.model.applyAdapter({files:e});for(const t of this.#e.values())await t.dispose();this.#e.clear()}}async function Oe(){const r=[253,12,...new Array(16).fill(0)],e=[0,...r,...r,...r,253,133,2,11],t=new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,e.length+2,1,e.length,...e]);try{return WebAssembly.validate(t)}catch{return!1}}const pe=/\p{White_Space}/u,ze=/\p{C}/u,We=/\p{Mn}/u,Ne=/[!-\/:-@\[-`{-~]|\p{P}/u;function Ue(r){return r>=19968&&r<=40959||r>=13312&&r<=19903||r>=131072&&r<=173791||r>=173824&&r<=177983||r>=177984&&r<=178207||r>=178464&&r<=183983||r>=63744&&r<=64255||r>=194560&&r<=195103}class le{#e;#t;#n;#r;#s;#o;#i;#a;dim;table;rows;normalize;constructor(e,t,n,s){if(this.table=t,this.rows=n,this.normalize=s,e.model.type!=="WordPiece")throw new Error(`static embedder: unsupported tokenizer model ${e.model.type}`);if(e.pre_tokenizer&&e.pre_tokenizer.type!=="BertPreTokenizer")throw new Error(`static embedder: unsupported pre-tokenizer ${e.pre_tokenizer.type}`);const o=e.normalizer;if(o&&o.type!=="BertNormalizer")throw new Error(`static embedder: unsupported normalizer ${o.type}`);this.#e=new Map(Object.entries(e.model.vocab)),this.#t=this.#e.get(e.model.unk_token),this.#n=e.model.continuing_subword_prefix??"##",this.#r=e.model.max_input_chars_per_word??100,this.#s=o?.lowercase??!1,this.#o=o?o.strip_accents??this.#s:!1,this.#i=o?.clean_text??!1,this.#a=o?.handle_chinese_chars??!1,this.dim=t.length/n}static fromFiles(e){const t=new TextDecoder,n=JSON.parse(t.decode(e["tokenizer.json"])),s=e["config.json"]?JSON.parse(t.decode(e["config.json"])):{},o=e["model.safetensors"],a=new DataView(o.buffer,o.byteOffset,o.byteLength),c=Number(a.getBigUint64(0,!0)),f=JSON.parse(t.decode(o.subarray(8,8+c))).embeddings;if(!f||f.dtype!=="F32"||f.shape.length!==2)throw new Error("static embedder: no F32 `embeddings` table");const[l,d]=f.data_offsets,w=o.byteOffset+8+c+l,h=(d-l)/4,g=w%4===0?new Float32Array(o.buffer,w,h):new Float32Array(o.slice(8+c+l,8+c+d).buffer);return new le(n,g,f.shape[0],s.normalize??!0)}normalise(e){let t="";for(const n of e){const s=n.codePointAt(0);if(this.#i){if(s===0||s===65533||n!==" "&&n!==``&&n!=="\r"&&ze.test(n))continue;if(pe.test(n)){t+=" ";continue}}t+=this.#a&&Ue(s)?` ${n} `:n}if(this.#o){let n="";for(const s of t.normalize("NFD"))We.test(s)||(n+=s);t=n}if(this.#s){let n="";for(const s of t)n+=s.toLowerCase();t=n}return t}words(e){const t=[];let n="";for(const s of e)pe.test(s)?(n&&t.push(n),n=""):Ne.test(s)?(n&&t.push(n),t.push(s),n=""):n+=s;return n&&t.push(n),t}wordpiece(e){const t=Array.from(e);if(t.length>this.#r)return this.#t===void 0?[]:[this.#t];const n=[];let s=0;for(;s<t.length;){let o=t.length,a;for(;s<o;){const c=(s>0?this.#n:"")+t.slice(s,o).join("");if(a=this.#e.get(c),a!==void 0)break;o--}if(a===void 0)return this.#t===void 0?[]:[this.#t];n.push(a),s=o}return n}ids(e){const t=[];for(const n of this.words(this.normalise(e)))for(const s of this.wordpiece(n))s!==this.#t&&t.push(s);return t}encode(e){const t=this.dim,n=new Float64Array(t),s=this.ids(e);if(!s.length)return n;for(const o of s){const a=o*t;for(let c=0;c<t;c++)n[c]=n[c]+this.table[a+c]}for(let o=0;o<t;o++)n[o]=n[o]/s.length;if(this.normalize){const o=Math.sqrt(be(n,n));if(o>0)for(let a=0;a<t;a++)n[a]=n[a]/o}return n}dot(e,t){return be(e,t)}choose(e,t,n){return He(e,t,n)}}function be(r,e){let t=0;for(let n=0;n<r.length;n++)t+=r[n]*e[n];return t}function He(r,e,t){return[...r].sort((n,s)=>s.cos-n.cos||Number(n.pebble)-Number(s.pebble)).slice(0,t).filter(n=>n.cos>=e)}const de=16,je=()=>({text:"",n:0,seenMemory:!1});function Ce(r,e,t=de){return e.eos?{keep:!1,stop:"eos"}:e.newline||e.text.includes(``)?{keep:!1,stop:"newline"}:r.seenMemory&&e.readout!=="memory"&&/^\s/.test(e.text)?{keep:!1,stop:"left_memory"}:(r.text+=e.text,r.n+=1,r.seenMemory||=e.readout==="memory",/[.!?]$/.test(r.text.trimEnd())?{keep:!0,stop:"sentence"}:r.n>=t?{keep:!0,stop:"max"}:{keep:!0})}const E=r=>typeof r=="bigint"?r.toString():String(r);function he(r){const e=r.credited.map(t=>({pebble:E(t.pebble),relief:t.relief,distinct:t.distinct,shadow:t.shadow}));return{tokens:r.tokens,surprise:r.surprise,need:r.need,threshold:r.threshold,wrote:r.wrote===void 0?void 0:E(r.wrote),credited:e,reinstated:r.reinstated===void 0?void 0:E(r.reinstated),erased:r.erased.map(E),toReserve:r.toReserve.map(E),superseded:r.superseded.map(E)}}class Pe{constructor(e,t,n=()=>{},s){this.poucet=e,this.bb=t,this.tick=n,this.mode=s;const o=e.tokenize(``);this.newlineId=o.length===1?o[0]:-1}poucet;bb;tick;mode;#e=new Map;#t=new Map;newlineId;async run(e,t){this.bb.external&&await this.bb.run(this.poucet,e,t)}async resetContext(e){await this.run(this.poucet.planReset(),e),this.poucet.resetContext()}async append(e,t){await this.run(this.poucet.planAppend(e),t),this.poucet.appendTokens(e)}seedRing(e){return e?.ringPrior?.length?this.poucet.seedRing(Float32Array.from(e.ringPrior)):!1}async startVisit(e){if(this.seedRing(e),await this.resetContext("main"),!e?.preamble)return[];this.tick();const t=this.poucet,n=[];for(const s of t.planFeed(e.preamble))await this.run(t.planAppend(s),"main"),n.push(he(t.feedEvent(s,{origin:"self",learn:!1})));return n}async feed(e,t){const n=this.poucet;this.tick();const s=[];for(const o of n.planFeed(e))await this.run(n.planAppend(o),"main"),s.push(he(n.feedEvent(o,{origin:t,learn:!0,write:!!this.mode?.writeAll})));return s}address(e){const t=this.mode?.address;if(!t)return;const n=t.embedder.encode(e),s=[];for(const o of this.poucet.pebbles({liveOnly:!0})){const a=E(o.id);let c=this.#t.get(a);c||(c=t.embedder.encode(String(o.text)),this.#t.set(a,c)),s.push({pebble:a,cos:t.embedder.dot(n,c)})}return t.embedder.choose(s,t.tau,t.topK)}#n(e){let t=this.#e.get(e);if(t===void 0){const n=this.poucet.pebbles({}).find(s=>E(s.id)===e);t=n?String(n.text):"",this.#e.set(e,t)}return t}#r(e){return{id:e.id,text:e.text,pOpen:e.pOpen,pClosed:e.pClosed,memoryMass:e.memoryMass,readout:e.readout,sources:e.sources.map(t=>({pebble:E(t.pebble),mass:t.mass,text:this.#n(E(t.pebble))}))}}async generate(e,t,n,s,o){const a=this.poucet;a.genBegin();const c=[],_=je(),f=performance.now();let l=0,d="max";for(let h=0;h<n;h++){const g=a.genNext(o&&t?{memory:t,temperature:0,readSet:o}:{memory:t,temperature:0});l++;const b=this.#r(g),y=Ce(_,{text:b.text,readout:b.readout,eos:!!g.eos,newline:g.id===this.newlineId},n);if(!y.keep){d=y.stop;break}if(c.push(b),s?.(t?"open":"closed",b),y.stop){d=y.stop;break}await this.append(Uint32Array.of(b.id),e)}const w=(performance.now()-f)/1e3;return{tokens:c,text:c.map(h=>h.text).join(""),unknown:c.length===0||c[0].readout==="unknown",stop:d,tokensPerSecond:l/Math.max(w,1e-9)}}async ask(e,t=de,n){const s=this.poucet;this.tick(),this.#e.clear();const o=this.address(e),a=s.contextSave();try{await this.resetContext("qa"),await this.append(s.tokenize(e),"qa");const c=s.contextSave();await this.bb.fork("qa","twin");const _=await this.generate("qa",!0,t,n,o?.map(l=>l.pebble));s.contextRestore(c),s.contextDrop(c);const f=await this.generate("twin",!1,t,n);return o?{open:_,closed:f,address:o}:{open:_,closed:f}}finally{s.contextRestore(a),s.contextDrop(a)}}}const Be="poucet";async function fe(){return(await navigator.storage.getDirectory()).getDirectoryHandle(Be,{create:!0})}async function Q(r){try{const t=await(await(await fe()).getFileHandle(r)).getFile();return new Uint8Array(await t.arrayBuffer())}catch{return null}}async function L(r,e){const t=await(await fe()).getFileHandle(r,{create:!0}),n=t;if(n.createSyncAccessHandle){const s=await n.createSyncAccessHandle();try{s.truncate(0),s.write(e,{at:0}),s.flush()}finally{s.close()}}else{const s=await t.createWritable();await s.write(e),await s.close()}}async function Le(r){try{await(await fe()).removeEntry(r)}catch{}}async function se(r){const e=await crypto.subtle.digest("SHA-256",r);return[...new Uint8Array(e)].map(t=>t.toString(16).padStart(2,"0")).join("")}async function me(r,e,t,n,s){const o=await Q(e);if(o&&o.length===n&&await se(o)===t)return s(n,n),o;const a=await fetch(r);if(!a.ok||!a.body)throw new Error(`${r}: HTTP ${a.status}`);const c=Number(a.headers.get("content-length"))||n,_=new Uint8Array(c),f=a.body.getReader();let l=0;for(;;){const{done:h,value:g}=await f.read();if(h)break;_.set(g,l),l+=g.length,s(l,c)}const d=_.subarray(0,l),w=await se(d);if(w!==t)throw new Error(`${e}: sha256 ${w}, expected ${t}`);return await L(e,d),d}let T,x,A,K=0,$,we=Promise.resolve(),V,oe,X;const R=r=>self.postMessage(r);function k(){if(!T)throw new Error("the engine is not started");return T}function Y(){k().setClock(Date.now()/1e3+K)}const Ie=r=>typeof r=="bigint"?r.toString():String(r);function M(){if(!V)throw new Error("the engine is not started");return V}async function Ve(r,e){const t=await M().feed(r,e);return ie(),t}async function Ke(r,e,t){return M().ask(r,e,(n,s)=>R({kind:"token",id:t,lane:n,token:s}))}function ue(r){return k().pebbles({liveOnly:!r}).map(e=>({id:Ie(e.id),text:e.text,cue:e.cue,origin:e.origin,status:e.status,pinned:e.pinned,lapsed:e.lapsed,folded:e.folded,superseded:e.superseded,E:e.E,r:e.r,h:e.h,hits:e.hits,ageDays:e.ageDays,day:e.day}))}function z(){const r=k(),e=r.info(),t=r.snapshot();return{live:e.livePebbles,reserve:e.reservePebbles,day:e.day,bytes:t.length,stateHash:r.stateHash()}}async function Z(){if(!T)return;const r=T.snapshot();await L("store.pbs.tmp",r);const e=await Q("store.pbs");e&&await L("store.pbs.bak",e),await L("store.pbs",r),await Le("store.pbs.tmp");const t=T.info(),n=ue(!0),o={firstVisit:(await ye())?.firstVisit??Date.now()/1e3,lastSaved:Date.now()/1e3+K,stateHash:await se(r),pebbles:n.length,habitNight:t.habitNight??0,folded:n.filter(a=>a.folded).length};await L("visits.json",new TextEncoder().encode(JSON.stringify(o)))}function ie(){$&&clearTimeout($),$=setTimeout(()=>{$=void 0,ke(Z)},2e3)}async function ye(){const r=await Q("visits.json");if(!r)return null;try{return JSON.parse(new TextDecoder().decode(r))}catch{return null}}async function ae(r){const e=k();await M().run(e.planRestore(r),"scratch"),e.restore(r),M().seedRing(X)}async function Je(){const r=await ye();let e=!1,t=!1;for(const a of["store.pbs","store.pbs.bak","store.pbs.tmp"]){const c=await Q(a);if(c)try{await ae(c),t=!0,e=a!=="store.pbs";break}catch{k().clearSegments()}}const n=k().stateHash(),s=ue(!0),o=Date.now()/1e3+K;return{first:!t,secondsAway:r?Math.max(0,o-r.lastSaved):0,pebbles:s.length,folded:Math.max(0,s.filter(a=>a.folded).length-(r?.folded??0)),verified:!!r&&t&&r.stateHash===n,expectedHash:r?.stateHash,foundHash:n,recoveredFromBackup:e}}const Ge=["m3b","m5a"];async function Xe(r,e){const t=A.model,n={available:!1,applied:!1,files:[],habits:[]};try{const s=await fetch(`https://huggingface.co/api/models/${t.repo}/revision/main`);if(!s.ok)return n;const o=(await s.json()).sha;n.revision=o;const a=String(k().info().baseSha256),c={},_=[];for(const d of Ge){const w=`exploratory/${d}`,h=await fetch(`https://huggingface.co/api/models/${t.repo}/tree/${o}/${w}`);if(!h.ok)continue;const g=(await h.json()).filter(v=>v.type==="file").map(v=>v.path.slice(w.length+1));n.files.push(...g.map(v=>`${d}/${v}`));let b;if(g.includes("manifest.json")){const v=await fetch(`https://huggingface.co/${t.repo}/resolve/${o}/${w}/manifest.json`);v.ok&&(b=(await v.json()).base?.sha256)}if(b!==a){_.push(b?`${d}: the habit was folded on base ${b.slice(0,12)}…, the loaded base is ${a.slice(0,12)}…`:`${d}: the habit's manifest does not name the base it was folded on`);continue}const y=g.includes("adapter_config.json")&&g.includes("adapter_model.safetensors");c[d]=y;const J=g.filter(v=>/^habit-\d+\.gguf$/.test(v)).sort(),ve=x.external?y?[{id:`${d}/peft`,set:d,file:J[0]??"",night:J.length?Number(J[0].slice(6,10)):1}]:[]:J.map(v=>({id:`${d}/${v}`,set:d,file:v,night:Number(v.slice(6,10))}));n.habits.push(...ve)}_.length&&!n.habits.length&&(n.refused=_.join("; ")),n.available=n.habits.length>0;const f=n.habits.find(d=>d.id===r);if(!f)return n;R({kind:"progress",id:e,progress:{phase:"habit"}});const l=async d=>{const w=await fetch(`https://huggingface.co/${t.repo}/resolve/${o}/exploratory/${f.set}/${d}`);if(!w.ok)throw new Error(`${d}: HTTP ${w.status}`);return new Uint8Array(await w.arrayBuffer())};if(x.external)f.file&&k().applyHabitWeights(await l(f.file)),await x.applyAdapter({"adapter_config.json":await l("adapter_config.json"),"adapter_model.safetensors":await l("adapter_model.safetensors")}),await M().resetContext("main"),n.night=f.night;else{const d=k().applyHabitWeights(await l(f.file));n.night=d.night}n.applied=!0,n.appliedId=f.id}catch(s){n.error=s instanceof Error?s.message:String(s)}return n}async function Ye(r,e){const t=`https://huggingface.co/${r.repo}/resolve/${r.revision}/`,n={};for(const[s,o]of Object.entries(r.files))n[s]=await me(t+s,`embed-${o.sha256}-${s}`,o.sha256,o.bytes,(a,c)=>R({kind:"progress",id:e,progress:{phase:"embedder",loaded:a,total:c}}));return le.fromFiles(n)}async function Ze(r,e){K=r.clockOffset??0,A=await(await fetch(r.manifestUrl)).json();const n=A.model,s=`https://huggingface.co/${n.repo}/resolve/${n.revision}/`,o=await me(s+n.base.file,`base-${n.base.sha256}.gguf`,n.base.sha256,n.base.bytes,(b,y)=>R({kind:"progress",id:e,progress:{phase:"base",loaded:b,total:y}}));R({kind:"progress",id:e,progress:{phase:"engine"}}),await Fe({module_or_path:Me}),r.runtime==="engine"?(T=F.load(o,void 0),x=new De("poucet-engine (WebAssembly SIMD128, 1 thread)")):(T=F.loadPort(o),x=await ce.load(n.repo,n.revision,n.backbone.readerLayers,r.device,n.backbone,(b,y)=>R({kind:"progress",id:e,progress:{phase:"backbone",loaded:b,total:y}})));const a={...A.gates,...r.gates??{}};delete a.source,T.setGates(a);const c={stream:void 0,chat:A.chat,"chat-meaning":A.chatMeaning},_=A.chat?.default?"chat":A.chatMeaning?.default?"chat-meaning":"stream",f=(r.mode&&(r.mode==="stream"||c[r.mode])?r.mode:void 0)??_,l=c[f];let d;if(l&&(d={writeAll:l.writeEveryStatement},l.address)){const b=await Ye(l.address,e);d.address={embedder:b,tau:l.address.tauEmb,topK:l.address.topK}}X=l?l.coldStart:A.coldStart,V=new Pe(T,x,Y,d),Y(),await V.resetContext("main"),oe=T.snapshot(),R({kind:"progress",id:e,progress:{phase:"store"}});const w=await Je(),h=r.lookForHabit===!1?{available:!1,applied:!1,files:[],habits:[]}:await Xe(r.exploratory,e);await V.startVisit(X),Y();const g=x.files.map(b=>{const y=n.backbone.files[b.file];return{file:b.file,sha256:b.sha256,expected:y,ok:y===void 0||y===b.sha256}});return g.unshift({file:n.base.file,sha256:n.base.sha256,expected:n.base.sha256,ok:!0}),{modelRepo:n.repo,modelFile:n.base.file,runtime:r.runtime,backend:x.backend,device:x.device,baseSha256:T.info().baseSha256,filesVerified:g.every(b=>b.ok&&b.sha256!==void 0),files:g,visit:w,store:z(),gates:a,exploratory:h,preamble:X?.preamble,mode:f,chatAvailable:!!(A.chat||A.chatMeaning),address:l?.address?{repo:l.address.repo,revision:l.address.revision,license:l.address.license,tau:l.address.tauEmb}:void 0}}async function Qe(r,e){const t=k(),n=t.contextSave();try{await M().resetContext("qa"),await M().append(t.tokenize(" Once upon a time, a little boy found a pebble by the river."),"qa"),x.takeTime(),t.genBegin();const s=performance.now();let o=0;for(let _=0;_<r;_++){const f=performance.now(),l=t.genNext({memory:e,temperature:0});o+=performance.now()-f;const d=Uint32Array.of(l.id);await M().run(t.planAppend(d),"qa");const w=performance.now();t.appendTokens(d),o+=performance.now()-w}const a=(performance.now()-s)/1e3,c=x.external?x.takeTime():0;return{tokens:r,seconds:a,tokensPerSecond:r/a,backboneSeconds:c/1e3,portSeconds:o/1e3,livePebbles:t.info().livePebbles,backend:x.backend}}finally{t.contextRestore(n),t.contextDrop(n)}}async function qe(r,e){switch(r.type){case"init":return Ze(r.options,e);case"feed":return Ve(r.text,r.origin??"user");case"ask":return Ke(r.question,r.maxTokens??de,e);case"pebbles":return ue(!!r.reserve);case"pin":return k().pin(BigInt(r.id),r.on),ie(),null;case"forget":return k().forget(BigInt(r.id)),ie(),null;case"store":return z();case"save":return $&&clearTimeout($),$=void 0,await Z(),z();case"exportDay":return k().exportDay();case"importDay":return await ae(r.bytes),await Z(),z();case"resetStore":return oe&&await ae(oe),await Z(),z();case"advanceClock":return K+=r.seconds,Y(),z();case"bench":return Qe(r.tokens,r.memory);case"tokenize":return Array.from(k().tokenize(r.text));case"fillRandom":return $&&clearTimeout($),k().fillRandomPebbles(r.live,0,1),z()}}function ke(r){const e=we.then(r,r);return we=e.catch(()=>{}),e}self.addEventListener("message",r=>{const{id:e,req:t}=r.data;ke(()=>qe(t,e)).then(n=>{const s=n instanceof Uint8Array?[n.buffer]:[];self.postMessage({kind:"result",id:e,ok:!0,value:n},s)},n=>R({kind:"result",id:e,ok:!1,error:n instanceof Error?n.message:String(n)}))});5 unmodified lines678910111257 unmodified lines70717273747566 unmodified lines1421431441451461475 unmodified lines<meta name="description" content="Poucet, a 30M-parameter language model with a pebble memory, running in this browser." /><title>Poucet</title><link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='9' r='5' fill='%236b7d8f'/%3E%3C/svg%3E" /><script type="module" crossorigin src="./assets/index-Cs--cBO7.js"></script><link rel="stylesheet" crossorigin href="./assets/index-BWBO5zds.css"></head><body>57 unmodified lines<button id="send" class="primary" type="submit" data-i18n="talk.send"></button></form><p class="hint muted" data-i18n="talk.hint"></p><details id="examples" class="examples" hidden><summary data-i18n="talk.examples.heading"></summary><p class="small muted" data-i18n="talk.examples.note"></p>66 unmodified lines<p data-i18n="footer.local"></p><p id="foot-model" class="muted small"></p><p id="foot-runtime" class="muted small"></p><p class="small"><a href="https://github.com/maxgfr/neoteny" data-i18n="footer.code"></a></p></footer>5 unmodified lines678910111257 unmodified lines7071727374757666 unmodified lines1431441451461471481495 unmodified lines<meta name="description" content="Poucet, a 30M-parameter language model with a pebble memory, running in this browser." /><title>Poucet</title><link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='9' r='5' fill='%236b7d8f'/%3E%3C/svg%3E" /><script type="module" crossorigin src="./assets/index-wrasL7ZU.js"></script><link rel="stylesheet" crossorigin href="./assets/index-BWBO5zds.css"></head><body>57 unmodified lines<button id="send" class="primary" type="submit" data-i18n="talk.send"></button></form><p class="hint muted" data-i18n="talk.hint"></p><p id="talk-mode" class="hint muted" hidden></p><details id="examples" class="examples" hidden><summary data-i18n="talk.examples.heading"></summary><p class="small muted" data-i18n="talk.examples.note"></p>66 unmodified lines<p data-i18n="footer.local"></p><p id="foot-model" class="muted small"></p><p id="foot-runtime" class="muted small"></p><p id="foot-address" class="muted small" hidden></p><p class="small"><a href="https://github.com/maxgfr/neoteny" data-i18n="footer.code"></a></p></footer>
106 unmodified lines107108109110111106 unmodified lines42.44846725463867],"preamble": "Hi! I'm Poucet, a small model with a memory of pebbles.\nTell me a few things about yourself, the people around you and your pets, and I will try to remember them.\n"}}106 unmodified lines107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145106 unmodified lines42.44846725463867],"preamble": "Hi! I'm Poucet, a small model with a memory of pebbles.\nTell me a few things about yourself, the people around you and your pets, and I will try to remember them.\n"},"chat": {"source": "issue #38 (docs/DEMO-BUILD.md section 9), at ?mode=chat: every statement is written as a pebble (the write gate bypassed; credit decides what stays); Poucet's own address and tau_open choose what a question reads; Poucet's preamble without the ring prior. Visitor test 55.3% against 42.0% for the stream path and probe 13.1% against 11.5%, but on questions about facts never stated it says \"does not know yet\" 2.5 points less often and reads memory out 2.9 points more often, outside the 2-point margins of the rule, so it is not the default","default": false,"writeEveryStatement": true,"coldStart": {"preamble": "Hi! I'm Poucet, a small model with a memory of pebbles.\nTell me a few things about yourself, the people around you and your pets, and I will try to remember them.\n"}},"chatMeaning": {"source": "issue #38 (docs/DEMO-BUILD.md section 9), at ?mode=chat-meaning: every statement is written as a pebble; the read set of a question is chosen by the static embedding model below, at most topK live pebbles at or above tauEmb (derived on dev by the two-sided rule); no ring prior, no preamble. The configuration chosen on dev (chat+emb-nopre); it was not admissible as the default (control EM and gate W3 on dev; visitor test 21.7% against 42.0%)","default": false,"writeEveryStatement": true,"address": {"repo": "minishlab/potion-base-8M","revision": "bf8b056651a2c21b8d2565580b8569da283cab23","license": "MIT","files": {"config.json": {"sha256": "2a6ac0e9aaa356a68a5688070db78fc3a464fefe85d2f06a1905ce3718687553","bytes": 202},"tokenizer.json": {"sha256": "e67e803f624fb4d67dea1c730d06e1067e1b14d830e2c2202569e3ef0f70bb50","bytes": 683666},"model.safetensors": {"sha256": "f65d0f325faadc1e121c319e2faa41170d3fa07d8c89abd48ca5358d9a223de2","bytes": 30236760}},"tauEmb": 0.4977132932001571,"topK": 4}}}
assets/index-wrasL7ZU.jsAdded+4
assets/poucet_web_bg-EKZ7t1Wd.wasmAdded+3
assets/worker-BYAMVPsw.jsAdded+5
index.html+3-1
manifest.json+34