Spaces:
Running
Running
Deploy free static in-browser ONNX Web demo for Mima 1 & Mima 1.5 Preview
Browse files- .gitattributes +1 -0
- README.md +11 -5
- bpe.js +148 -0
- index.html +553 -18
- mima-1.5-pico.png +3 -0
- mima_1.onnx +3 -0
- mima_1_5_preview.onnx +3 -0
- tokenizer.json +0 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
mima-1.5-pico.png filter=lfs diff=lfs merge=lfs -text
|
README.md
CHANGED
|
@@ -1,10 +1,16 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: MİMA Pico 15M Sohbet
|
| 3 |
+
emoji: ✨
|
| 4 |
+
colorFrom: pink
|
| 5 |
+
colorTo: purple
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
| 8 |
+
license: apache-2.0
|
| 9 |
+
models:
|
| 10 |
+
- root-sys-n/Mima-1.5-Pico-15m-Preview
|
| 11 |
+
- root-sys-n/Mima-1-Pico-15m
|
| 12 |
---
|
| 13 |
|
| 14 |
+
# MİMA Pico 15M — Tarayıcı İçi Sohbet Demosu
|
| 15 |
+
|
| 16 |
+
[`root-sys-n/Mima-1.5-Pico-15m-Preview`](https://huggingface.co/root-sys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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* Pure-JS Byte-Level BPE tokenizer compatible with HuggingFace tokenizers.json.
|
| 3 |
+
* Supports GPT-2 byte mapping, <bos>/<user>/<asst>/<end>/<pad> special tokens,
|
| 4 |
+
* and UTF-8 Turkish text round-trip parity.
|
| 5 |
+
*/
|
| 6 |
+
(function (root) {
|
| 7 |
+
function buildByteTables() {
|
| 8 |
+
const bs = [];
|
| 9 |
+
for (let i = 33; i <= 126; i++) bs.push(i);
|
| 10 |
+
for (let i = 161; i <= 172; i++) bs.push(i);
|
| 11 |
+
for (let i = 174; i <= 255; i++) bs.push(i);
|
| 12 |
+
const cs = bs.slice();
|
| 13 |
+
let n = 0;
|
| 14 |
+
for (let b = 0; b < 256; b++) {
|
| 15 |
+
if (!bs.includes(b)) {
|
| 16 |
+
bs.push(b);
|
| 17 |
+
cs.push(256 + n);
|
| 18 |
+
n += 1;
|
| 19 |
+
}
|
| 20 |
+
}
|
| 21 |
+
const b2u = new Array(256);
|
| 22 |
+
const u2b = new Map();
|
| 23 |
+
for (let i = 0; i < bs.length; i++) {
|
| 24 |
+
const ch = String.fromCodePoint(cs[i]);
|
| 25 |
+
b2u[bs[i]] = ch;
|
| 26 |
+
u2b.set(ch, bs[i]);
|
| 27 |
+
}
|
| 28 |
+
return { b2u, u2b };
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
class MimaTokenizer {
|
| 32 |
+
constructor(tokJson) {
|
| 33 |
+
const { b2u, u2b } = buildByteTables();
|
| 34 |
+
this.b2u = b2u;
|
| 35 |
+
this.u2b = u2b;
|
| 36 |
+
this.utf8Enc = new TextEncoder();
|
| 37 |
+
this.utf8Dec = new TextDecoder("utf-8", { fatal: false });
|
| 38 |
+
|
| 39 |
+
this.vocab = tokJson.model.vocab;
|
| 40 |
+
this.idToTok = [];
|
| 41 |
+
for (const [tok, id] of Object.entries(this.vocab)) {
|
| 42 |
+
this.idToTok[id] = tok;
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
this.specialToId = new Map();
|
| 46 |
+
this.specialIds = new Set();
|
| 47 |
+
for (const at of tokJson.added_tokens || []) {
|
| 48 |
+
this.specialToId.set(at.content, at.id);
|
| 49 |
+
this.specialIds.add(at.id);
|
| 50 |
+
this.idToTok[at.id] = at.content;
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
this.ranks = new Map();
|
| 54 |
+
const merges = tokJson.model.merges || [];
|
| 55 |
+
for (let i = 0; i < merges.length; i++) {
|
| 56 |
+
const pair = Array.isArray(merges[i]) ? merges[i] : merges[i].split(" ");
|
| 57 |
+
this.ranks.set(pair[0] + "\u0000" + pair[1], i);
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
this.bpeCache = new Map();
|
| 61 |
+
this.pat = /'s|'t|'re|'ve|'m|'ll|'d| ?\p{L}+| ?\p{N}+| ?[^\s\p{L}\p{N}]+|\s+(?!\S)|\s+/gu;
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
_bpe(token) {
|
| 65 |
+
const cached = this.bpeCache.get(token);
|
| 66 |
+
if (cached) return cached;
|
| 67 |
+
|
| 68 |
+
let word = Array.from(token);
|
| 69 |
+
if (word.length <= 1) {
|
| 70 |
+
this.bpeCache.set(token, word);
|
| 71 |
+
return word;
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
while (true) {
|
| 75 |
+
let bestRank = Infinity;
|
| 76 |
+
let bestPairA = null;
|
| 77 |
+
let bestPairB = null;
|
| 78 |
+
for (let i = 0; i < word.length - 1; i++) {
|
| 79 |
+
const rank = this.ranks.get(word[i] + "\u0000" + word[i + 1]);
|
| 80 |
+
if (rank !== undefined && rank < bestRank) {
|
| 81 |
+
bestRank = rank;
|
| 82 |
+
bestPairA = word[i];
|
| 83 |
+
bestPairB = word[i + 1];
|
| 84 |
+
}
|
| 85 |
+
}
|
| 86 |
+
if (bestPairA === null) break;
|
| 87 |
+
|
| 88 |
+
const next = [];
|
| 89 |
+
let i = 0;
|
| 90 |
+
while (i < word.length) {
|
| 91 |
+
if (i < word.length - 1 && word[i] === bestPairA && word[i + 1] === bestPairB) {
|
| 92 |
+
next.push(bestPairA + bestPairB);
|
| 93 |
+
i += 2;
|
| 94 |
+
} else {
|
| 95 |
+
next.push(word[i]);
|
| 96 |
+
i += 1;
|
| 97 |
+
}
|
| 98 |
+
}
|
| 99 |
+
word = next;
|
| 100 |
+
if (word.length === 1) break;
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
this.bpeCache.set(token, word);
|
| 104 |
+
return word;
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
encodeText(text) {
|
| 108 |
+
if (!text) return [];
|
| 109 |
+
const ids = [];
|
| 110 |
+
const matches = text.match(this.pat) || [];
|
| 111 |
+
for (const piece of matches) {
|
| 112 |
+
const bytes = this.utf8Enc.encode(piece);
|
| 113 |
+
let mapped = "";
|
| 114 |
+
for (let i = 0; i < bytes.length; i++) {
|
| 115 |
+
mapped += this.b2u[bytes[i]];
|
| 116 |
+
}
|
| 117 |
+
for (const sub of this._bpe(mapped)) {
|
| 118 |
+
const id = this.vocab[sub];
|
| 119 |
+
if (id !== undefined) ids.push(id);
|
| 120 |
+
}
|
| 121 |
+
}
|
| 122 |
+
return ids;
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
decode(ids, skipSpecial = true) {
|
| 126 |
+
const bytes = [];
|
| 127 |
+
for (const id of ids) {
|
| 128 |
+
if (skipSpecial && this.specialIds.has(id)) continue;
|
| 129 |
+
const tok = this.idToTok[id];
|
| 130 |
+
if (tok === undefined) continue;
|
| 131 |
+
if (!skipSpecial && this.specialToId.has(tok)) {
|
| 132 |
+
for (const b of this.utf8Enc.encode(tok)) bytes.push(b);
|
| 133 |
+
continue;
|
| 134 |
+
}
|
| 135 |
+
for (const ch of Array.from(tok)) {
|
| 136 |
+
const b = this.u2b.get(ch);
|
| 137 |
+
if (b !== undefined) bytes.push(b);
|
| 138 |
+
}
|
| 139 |
+
}
|
| 140 |
+
return this.utf8Dec.decode(new Uint8Array(bytes));
|
| 141 |
+
}
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
+
root.MimaTokenizer = MimaTokenizer;
|
| 145 |
+
if (typeof module !== "undefined" && module.exports) {
|
| 146 |
+
module.exports = { MimaTokenizer };
|
| 147 |
+
}
|
| 148 |
+
})(typeof window !== "undefined" ? window : globalThis);
|
index.html
CHANGED
|
@@ -1,19 +1,554 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
</html>
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="tr">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8" />
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
| 6 |
+
<title>MİMA Pico 15M — Tarayıcı Sohbeti</title>
|
| 7 |
+
<style>
|
| 8 |
+
:root {
|
| 9 |
+
--bg: #f6f3fa;
|
| 10 |
+
--card: #ffffff;
|
| 11 |
+
--ink: #1e1b29;
|
| 12 |
+
--muted: #665f7a;
|
| 13 |
+
--border: #e3dcf0;
|
| 14 |
+
--accent: #6d4aff;
|
| 15 |
+
--accent-soft: #efeafd;
|
| 16 |
+
--user-bg: #231f33;
|
| 17 |
+
--user-ink: #ffffff;
|
| 18 |
+
--bot-bg: #f9f7fc;
|
| 19 |
+
}
|
| 20 |
+
* { box-sizing: border-box; }
|
| 21 |
+
body {
|
| 22 |
+
margin: 0;
|
| 23 |
+
min-height: 100vh;
|
| 24 |
+
background: var(--bg);
|
| 25 |
+
color: var(--ink);
|
| 26 |
+
font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
|
| 27 |
+
display: flex;
|
| 28 |
+
justify-content: center;
|
| 29 |
+
padding: 18px 14px;
|
| 30 |
+
}
|
| 31 |
+
.shell {
|
| 32 |
+
width: 100%;
|
| 33 |
+
max-width: 860px;
|
| 34 |
+
background: var(--card);
|
| 35 |
+
border: 1.5px solid var(--border);
|
| 36 |
+
border-radius: 18px;
|
| 37 |
+
overflow: hidden;
|
| 38 |
+
display: flex;
|
| 39 |
+
flex-direction: column;
|
| 40 |
+
height: calc(100vh - 36px);
|
| 41 |
+
min-height: 540px;
|
| 42 |
+
box-shadow: 0 8px 30px rgba(30, 27, 41, 0.06);
|
| 43 |
+
}
|
| 44 |
+
.topbar {
|
| 45 |
+
padding: 12px 18px;
|
| 46 |
+
border-bottom: 1.5px solid var(--border);
|
| 47 |
+
display: flex;
|
| 48 |
+
flex-wrap: wrap;
|
| 49 |
+
gap: 12px;
|
| 50 |
+
align-items: center;
|
| 51 |
+
justify-content: space-between;
|
| 52 |
+
background: #fcfbfe;
|
| 53 |
+
}
|
| 54 |
+
.brand {
|
| 55 |
+
display: flex;
|
| 56 |
+
align-items: center;
|
| 57 |
+
gap: 12px;
|
| 58 |
+
}
|
| 59 |
+
.brand img {
|
| 60 |
+
height: 44px;
|
| 61 |
+
width: auto;
|
| 62 |
+
border-radius: 8px;
|
| 63 |
+
border: 1px solid var(--border);
|
| 64 |
+
}
|
| 65 |
+
.brand h1 {
|
| 66 |
+
margin: 0;
|
| 67 |
+
font-size: 16px;
|
| 68 |
+
font-weight: 700;
|
| 69 |
+
letter-spacing: -0.01em;
|
| 70 |
+
}
|
| 71 |
+
.brand p {
|
| 72 |
+
margin: 2px 0 0;
|
| 73 |
+
font-size: 12px;
|
| 74 |
+
color: var(--muted);
|
| 75 |
+
}
|
| 76 |
+
.controls {
|
| 77 |
+
display: flex;
|
| 78 |
+
flex-wrap: wrap;
|
| 79 |
+
gap: 8px;
|
| 80 |
+
align-items: center;
|
| 81 |
+
}
|
| 82 |
+
select, button.ghost {
|
| 83 |
+
border: 1.5px solid var(--border);
|
| 84 |
+
background: #fff;
|
| 85 |
+
color: var(--ink);
|
| 86 |
+
border-radius: 9px;
|
| 87 |
+
padding: 7px 11px;
|
| 88 |
+
font-size: 13px;
|
| 89 |
+
font-weight: 600;
|
| 90 |
+
cursor: pointer;
|
| 91 |
+
}
|
| 92 |
+
button.ghost:hover { background: var(--accent-soft); border-color: #cfc1fb; }
|
| 93 |
+
.settings-bar {
|
| 94 |
+
padding: 8px 18px;
|
| 95 |
+
border-bottom: 1px solid var(--border);
|
| 96 |
+
background: #faf8fd;
|
| 97 |
+
display: flex;
|
| 98 |
+
flex-wrap: wrap;
|
| 99 |
+
gap: 16px;
|
| 100 |
+
align-items: center;
|
| 101 |
+
font-size: 12px;
|
| 102 |
+
color: var(--muted);
|
| 103 |
+
}
|
| 104 |
+
.settings-bar label {
|
| 105 |
+
display: flex;
|
| 106 |
+
align-items: center;
|
| 107 |
+
gap: 6px;
|
| 108 |
+
}
|
| 109 |
+
.settings-bar input[type="range"] { width: 88px; accent-color: var(--accent); }
|
| 110 |
+
.chat-area {
|
| 111 |
+
flex: 1;
|
| 112 |
+
overflow-y: auto;
|
| 113 |
+
padding: 18px;
|
| 114 |
+
display: flex;
|
| 115 |
+
flex-direction: column;
|
| 116 |
+
gap: 12px;
|
| 117 |
+
}
|
| 118 |
+
.empty-state {
|
| 119 |
+
margin: auto;
|
| 120 |
+
text-align: center;
|
| 121 |
+
max-width: 560px;
|
| 122 |
+
color: var(--muted);
|
| 123 |
+
}
|
| 124 |
+
.empty-state h2 {
|
| 125 |
+
margin: 0 0 8px;
|
| 126 |
+
font-size: 18px;
|
| 127 |
+
color: var(--ink);
|
| 128 |
+
}
|
| 129 |
+
.empty-state p { margin: 0 0 14px; font-size: 13.5px; line-height: 1.5; }
|
| 130 |
+
.examples {
|
| 131 |
+
display: flex;
|
| 132 |
+
flex-wrap: wrap;
|
| 133 |
+
gap: 8px;
|
| 134 |
+
justify-content: center;
|
| 135 |
+
}
|
| 136 |
+
.chip {
|
| 137 |
+
background: var(--accent-soft);
|
| 138 |
+
color: #3f28a8;
|
| 139 |
+
border: 1px solid #dcd1fb;
|
| 140 |
+
border-radius: 999px;
|
| 141 |
+
padding: 7px 13px;
|
| 142 |
+
font-size: 12.5px;
|
| 143 |
+
font-weight: 500;
|
| 144 |
+
cursor: pointer;
|
| 145 |
+
}
|
| 146 |
+
.chip:hover { background: #e2d8fc; }
|
| 147 |
+
.msg-row {
|
| 148 |
+
display: flex;
|
| 149 |
+
flex-direction: column;
|
| 150 |
+
max-width: 82%;
|
| 151 |
+
}
|
| 152 |
+
.msg-row.user { align-self: flex-end; align-items: flex-end; }
|
| 153 |
+
.msg-row.bot { align-self: flex-start; align-items: flex-start; }
|
| 154 |
+
.bubble {
|
| 155 |
+
padding: 10px 14px;
|
| 156 |
+
border-radius: 14px;
|
| 157 |
+
font-size: 14px;
|
| 158 |
+
line-height: 1.55;
|
| 159 |
+
white-space: pre-wrap;
|
| 160 |
+
word-break: break-word;
|
| 161 |
+
}
|
| 162 |
+
.msg-row.user .bubble {
|
| 163 |
+
background: var(--user-bg);
|
| 164 |
+
color: var(--user-ink);
|
| 165 |
+
border-bottom-right-radius: 4px;
|
| 166 |
+
}
|
| 167 |
+
.msg-row.bot .bubble {
|
| 168 |
+
background: var(--bot-bg);
|
| 169 |
+
border: 1.5px solid var(--border);
|
| 170 |
+
border-bottom-left-radius: 4px;
|
| 171 |
+
}
|
| 172 |
+
.msg-meta {
|
| 173 |
+
font-size: 11px;
|
| 174 |
+
color: var(--muted);
|
| 175 |
+
margin: 3px 4px 0;
|
| 176 |
+
}
|
| 177 |
+
.composer {
|
| 178 |
+
border-top: 1.5px solid var(--border);
|
| 179 |
+
padding: 12px 16px;
|
| 180 |
+
background: #fcfbfe;
|
| 181 |
+
}
|
| 182 |
+
.composer-box {
|
| 183 |
+
display: flex;
|
| 184 |
+
gap: 10px;
|
| 185 |
+
align-items: flex-end;
|
| 186 |
+
}
|
| 187 |
+
textarea {
|
| 188 |
+
flex: 1;
|
| 189 |
+
border: 1.5px solid var(--border);
|
| 190 |
+
border-radius: 11px;
|
| 191 |
+
padding: 10px 12px;
|
| 192 |
+
font-family: inherit;
|
| 193 |
+
font-size: 14px;
|
| 194 |
+
resize: none;
|
| 195 |
+
min-height: 42px;
|
| 196 |
+
max-height: 120px;
|
| 197 |
+
outline: none;
|
| 198 |
+
background: #fff;
|
| 199 |
+
color: var(--ink);
|
| 200 |
+
}
|
| 201 |
+
textarea:focus { border-color: var(--accent); }
|
| 202 |
+
button.primary {
|
| 203 |
+
background: var(--accent);
|
| 204 |
+
color: #fff;
|
| 205 |
+
border: none;
|
| 206 |
+
border-radius: 11px;
|
| 207 |
+
padding: 10px 18px;
|
| 208 |
+
font-size: 14px;
|
| 209 |
+
font-weight: 600;
|
| 210 |
+
cursor: pointer;
|
| 211 |
+
height: 42px;
|
| 212 |
+
}
|
| 213 |
+
button.primary:disabled { opacity: 0.55; cursor: not-allowed; }
|
| 214 |
+
.statusbar {
|
| 215 |
+
margin-top: 7px;
|
| 216 |
+
display: flex;
|
| 217 |
+
justify-content: space-between;
|
| 218 |
+
font-size: 11.5px;
|
| 219 |
+
color: var(--muted);
|
| 220 |
+
gap: 10px;
|
| 221 |
+
flex-wrap: wrap;
|
| 222 |
+
}
|
| 223 |
+
.statusbar a { color: var(--accent); text-decoration: none; }
|
| 224 |
+
.statusbar a:hover { text-decoration: underline; }
|
| 225 |
+
</style>
|
| 226 |
+
</head>
|
| 227 |
+
<body>
|
| 228 |
+
<div class="shell">
|
| 229 |
+
<div class="topbar">
|
| 230 |
+
<div class="brand">
|
| 231 |
+
<img src="./mima-1.5-pico.png" alt="MİMA 1.5 Pico" />
|
| 232 |
+
<div>
|
| 233 |
+
<h1>MİMA Pico 15M</h1>
|
| 234 |
+
<p>Tarayıcıda çalışan Türkçe küçük dil modeli (15.54M · ONNX WASM)</p>
|
| 235 |
+
</div>
|
| 236 |
+
</div>
|
| 237 |
+
<div class="controls">
|
| 238 |
+
<select id="modelSelect" title="Model Seçimi">
|
| 239 |
+
<option value="mima15" selected>MİMA 1.5 Pico Preview</option>
|
| 240 |
+
<option value="mima1">MİMA 1 Pico</option>
|
| 241 |
+
</select>
|
| 242 |
+
<button class="ghost" id="clearBtn" type="button">Temizle</button>
|
| 243 |
+
</div>
|
| 244 |
+
</div>
|
| 245 |
+
|
| 246 |
+
<div class="settings-bar">
|
| 247 |
+
<label>Sıcaklık: <strong id="tempVal">0.00</strong>
|
| 248 |
+
<input id="tempRange" type="range" min="0" max="1" step="0.05" value="0" />
|
| 249 |
+
</label>
|
| 250 |
+
<label>Top-K: <strong id="topkVal">40</strong>
|
| 251 |
+
<input id="topkRange" type="range" min="1" max="80" step="1" value="40" />
|
| 252 |
+
</label>
|
| 253 |
+
<label>Maks. Token: <strong id="maxTokVal">96</strong>
|
| 254 |
+
<input id="maxTokRange" type="range" min="24" max="200" step="8" value="96" />
|
| 255 |
+
</label>
|
| 256 |
+
<label>Tekrar Cezası: <strong id="repVal">1.08</strong>
|
| 257 |
+
<input id="repRange" type="range" min="1.00" max="1.25" step="0.02" value="1.08" />
|
| 258 |
+
</label>
|
| 259 |
+
</div>
|
| 260 |
+
|
| 261 |
+
<div class="chat-area" id="chatArea">
|
| 262 |
+
<div class="empty-state" id="emptyState">
|
| 263 |
+
<h2>Tarayıcıdan Doğrudan Test Edin</h2>
|
| 264 |
+
<p>
|
| 265 |
+
Seçtiğiniz MİMA Pico modeli (~72 MB ONNX) sunucuya ihtiyaç duymadan doğrudan tarayıcınızda çalıştırılır.
|
| 266 |
+
İlk mesajda model ağırlıkları önbelleğe indirilir.
|
| 267 |
+
</p>
|
| 268 |
+
<div class="examples">
|
| 269 |
+
<button class="chip" type="button" data-q="Türkiye'nin başkenti neresidir?">Türkiye'nin başkenti neresidir?</button>
|
| 270 |
+
<button class="chip" type="button" data-q="Su kaç derecede kaynar?">Su kaç derecede kaynar?</button>
|
| 271 |
+
<button class="chip" type="button" data-q="Defter ne işe yarar?">Defter ne işe yarar?</button>
|
| 272 |
+
<button class="chip" type="button" data-q="2099 yılında Mars'ta kurulan ilk Türk futbol takımının kalecisi kimdir?">2099 Mars futbol kalecisi?</button>
|
| 273 |
+
</div>
|
| 274 |
+
</div>
|
| 275 |
+
</div>
|
| 276 |
+
|
| 277 |
+
<div class="composer">
|
| 278 |
+
<div class="composer-box">
|
| 279 |
+
<textarea id="promptInput" rows="1" placeholder="Türkçe bir soru yazın (Enter ile gönder)..."></textarea>
|
| 280 |
+
<button class="primary" id="sendBtn" type="button">Gönder</button>
|
| 281 |
+
</div>
|
| 282 |
+
<div class="statusbar">
|
| 283 |
+
<span id="statusText">Hazır — ilk mesajda seçili model indirilir.</span>
|
| 284 |
+
<span>
|
| 285 |
+
Modeller:
|
| 286 |
+
<a href="https://huggingface.co/root-sys-n/Mima-1.5-Pico-15m-Preview" target="_blank" rel="noopener">MİMA 1.5 Preview</a> ·
|
| 287 |
+
<a href="https://huggingface.co/root-sys-n/Mima-1-Pico-15m" target="_blank" rel="noopener">MİMA 1</a> ·
|
| 288 |
+
İkonlar: withicons
|
| 289 |
+
</span>
|
| 290 |
+
</div>
|
| 291 |
+
</div>
|
| 292 |
+
</div>
|
| 293 |
+
|
| 294 |
+
<script src="https://cdn.jsdelivr.net/npm/onnxruntime-web@1.20.1/dist/ort.min.js"></script>
|
| 295 |
+
<script src="./bpe.js"></script>
|
| 296 |
+
<script>
|
| 297 |
+
ort.env.wasm.wasmPaths = "https://cdn.jsdelivr.net/npm/onnxruntime-web@1.20.1/dist/";
|
| 298 |
+
ort.env.wasm.numThreads = 1;
|
| 299 |
+
ort.env.wasm.proxy = false;
|
| 300 |
+
|
| 301 |
+
const BOS = 0, USER = 1, ASST = 2, END = 3;
|
| 302 |
+
const N_LAYER = 7, N_HEAD = 6, HEAD_DIM = 64, BLOCK_SIZE = 512;
|
| 303 |
+
|
| 304 |
+
const MODELS = {
|
| 305 |
+
mima15: { label: "MİMA 1.5 Pico Preview", url: "./mima_1_5_preview.onnx" },
|
| 306 |
+
mima1: { label: "MİMA 1 Pico", url: "./mima_1.onnx" },
|
| 307 |
+
};
|
| 308 |
+
|
| 309 |
+
let tokenizer = null;
|
| 310 |
+
const sessions = {};
|
| 311 |
+
let history = [];
|
| 312 |
+
let busy = false;
|
| 313 |
+
|
| 314 |
+
const chatArea = document.getElementById("chatArea");
|
| 315 |
+
const emptyState = document.getElementById("emptyState");
|
| 316 |
+
const modelSelect = document.getElementById("modelSelect");
|
| 317 |
+
const promptInput = document.getElementById("promptInput");
|
| 318 |
+
const sendBtn = document.getElementById("sendBtn");
|
| 319 |
+
const clearBtn = document.getElementById("clearBtn");
|
| 320 |
+
const statusText = document.getElementById("statusText");
|
| 321 |
+
|
| 322 |
+
const tempRange = document.getElementById("tempRange");
|
| 323 |
+
const topkRange = document.getElementById("topkRange");
|
| 324 |
+
const maxTokRange = document.getElementById("maxTokRange");
|
| 325 |
+
const repRange = document.getElementById("repRange");
|
| 326 |
+
tempRange.oninput = () => document.getElementById("tempVal").textContent = Number(tempRange.value).toFixed(2);
|
| 327 |
+
topkRange.oninput = () => document.getElementById("topkVal").textContent = topkRange.value;
|
| 328 |
+
maxTokRange.oninput = () => document.getElementById("maxTokVal").textContent = maxTokRange.value;
|
| 329 |
+
repRange.oninput = () => document.getElementById("repVal").textContent = Number(repRange.value).toFixed(2);
|
| 330 |
+
|
| 331 |
+
async function ensureTokenizer() {
|
| 332 |
+
if (tokenizer) return tokenizer;
|
| 333 |
+
statusText.textContent = "Tokenizer yükleniyor...";
|
| 334 |
+
const res = await fetch("./tokenizer.json");
|
| 335 |
+
if (!res.ok) throw new Error("tokenizer.json yüklenemedi: " + res.status);
|
| 336 |
+
tokenizer = new MimaTokenizer(await res.json());
|
| 337 |
+
return tokenizer;
|
| 338 |
+
}
|
| 339 |
+
|
| 340 |
+
async function ensureSession(key) {
|
| 341 |
+
if (sessions[key]) return sessions[key];
|
| 342 |
+
const meta = MODELS[key];
|
| 343 |
+
statusText.textContent = `${meta.label} indiriliyor (~72 MB) ve hazırlanıyor...`;
|
| 344 |
+
const sess = await ort.InferenceSession.create(meta.url, {
|
| 345 |
+
executionProviders: ["wasm"],
|
| 346 |
+
});
|
| 347 |
+
sessions[key] = sess;
|
| 348 |
+
return sess;
|
| 349 |
+
}
|
| 350 |
+
|
| 351 |
+
function appendMessage(role, text, metaLabel) {
|
| 352 |
+
if (emptyState) emptyState.style.display = "none";
|
| 353 |
+
const row = document.createElement("div");
|
| 354 |
+
row.className = "msg-row " + role;
|
| 355 |
+
const bubble = document.createElement("div");
|
| 356 |
+
bubble.className = "bubble";
|
| 357 |
+
bubble.textContent = text;
|
| 358 |
+
row.appendChild(bubble);
|
| 359 |
+
if (metaLabel) {
|
| 360 |
+
const meta = document.createElement("div");
|
| 361 |
+
meta.className = "msg-meta";
|
| 362 |
+
meta.textContent = metaLabel;
|
| 363 |
+
row.appendChild(meta);
|
| 364 |
+
}
|
| 365 |
+
chatArea.appendChild(row);
|
| 366 |
+
chatArea.scrollTop = chatArea.scrollHeight;
|
| 367 |
+
return { row, bubble };
|
| 368 |
+
}
|
| 369 |
+
|
| 370 |
+
function buildPromptIds(tok, hist, userMsg, maxNew) {
|
| 371 |
+
const budget = BLOCK_SIZE - maxNew - 8;
|
| 372 |
+
const tail = tok.encodeText(userMsg);
|
| 373 |
+
let trimmedHist = hist.slice();
|
| 374 |
+
|
| 375 |
+
function assemble(h) {
|
| 376 |
+
const ids = [BOS];
|
| 377 |
+
for (const turn of h) {
|
| 378 |
+
ids.push(USER, ...tok.encodeText(turn.u), ASST, ...tok.encodeText(turn.a), END);
|
| 379 |
+
}
|
| 380 |
+
ids.push(USER, ...tail, ASST);
|
| 381 |
+
return ids;
|
| 382 |
+
}
|
| 383 |
+
|
| 384 |
+
let ids = assemble(trimmedHist);
|
| 385 |
+
while (ids.length > budget && trimmedHist.length > 0) {
|
| 386 |
+
trimmedHist.shift();
|
| 387 |
+
ids = assemble(trimmedHist);
|
| 388 |
+
}
|
| 389 |
+
if (ids.length > BLOCK_SIZE - 4) {
|
| 390 |
+
ids = [BOS, ...ids.slice(-(BLOCK_SIZE - 5))];
|
| 391 |
+
}
|
| 392 |
+
return ids;
|
| 393 |
+
}
|
| 394 |
+
|
| 395 |
+
function pickNextToken(logits, seenSet, temp, topK, repPenalty) {
|
| 396 |
+
const vocab = logits.length;
|
| 397 |
+
const adjusted = new Float32Array(logits);
|
| 398 |
+
if (repPenalty !== 1.0) {
|
| 399 |
+
for (const id of seenSet) {
|
| 400 |
+
if (id >= 0 && id < vocab) {
|
| 401 |
+
adjusted[id] = adjusted[id] > 0 ? adjusted[id] / repPenalty : adjusted[id] * repPenalty;
|
| 402 |
+
}
|
| 403 |
+
}
|
| 404 |
+
}
|
| 405 |
+
|
| 406 |
+
if (temp <= 0.0) {
|
| 407 |
+
let bestId = 0;
|
| 408 |
+
let bestVal = -Infinity;
|
| 409 |
+
for (let i = 0; i < vocab; i++) {
|
| 410 |
+
if (adjusted[i] > bestVal) {
|
| 411 |
+
bestVal = adjusted[i];
|
| 412 |
+
bestId = i;
|
| 413 |
+
}
|
| 414 |
+
}
|
| 415 |
+
return bestId;
|
| 416 |
+
}
|
| 417 |
+
|
| 418 |
+
// Top-K + temperature softmax sampling
|
| 419 |
+
const indexed = new Array(vocab);
|
| 420 |
+
for (let i = 0; i < vocab; i++) indexed[i] = i;
|
| 421 |
+
indexed.sort((a, b) => adjusted[b] - adjusted[a]);
|
| 422 |
+
const k = Math.min(Math.max(1, topK), vocab);
|
| 423 |
+
const topIdx = indexed.slice(0, k);
|
| 424 |
+
const maxLogit = adjusted[topIdx[0]] / temp;
|
| 425 |
+
const probs = new Float64Array(k);
|
| 426 |
+
let sum = 0;
|
| 427 |
+
for (let i = 0; i < k; i++) {
|
| 428 |
+
const p = Math.exp(adjusted[topIdx[i]] / temp - maxLogit);
|
| 429 |
+
probs[i] = p;
|
| 430 |
+
sum += p;
|
| 431 |
+
}
|
| 432 |
+
let r = Math.random() * sum;
|
| 433 |
+
for (let i = 0; i < k; i++) {
|
| 434 |
+
r -= probs[i];
|
| 435 |
+
if (r <= 0) return topIdx[i];
|
| 436 |
+
}
|
| 437 |
+
return topIdx[0];
|
| 438 |
+
}
|
| 439 |
+
|
| 440 |
+
async function sendMessage(overrideText) {
|
| 441 |
+
if (busy) return;
|
| 442 |
+
const msg = (overrideText !== undefined ? overrideText : promptInput.value).trim();
|
| 443 |
+
if (!msg) return;
|
| 444 |
+
|
| 445 |
+
busy = true;
|
| 446 |
+
sendBtn.disabled = true;
|
| 447 |
+
promptInput.value = "";
|
| 448 |
+
promptInput.style.height = "auto";
|
| 449 |
+
|
| 450 |
+
const modelKey = modelSelect.value;
|
| 451 |
+
const modelLabel = MODELS[modelKey].label;
|
| 452 |
+
appendMessage("user", msg, "Sen");
|
| 453 |
+
const botUi = appendMessage("bot", "...", modelLabel);
|
| 454 |
+
|
| 455 |
+
try {
|
| 456 |
+
const tok = await ensureTokenizer();
|
| 457 |
+
const sess = await ensureSession(modelKey);
|
| 458 |
+
|
| 459 |
+
const temp = Number(tempRange.value);
|
| 460 |
+
const topK = Number(topkRange.value);
|
| 461 |
+
const maxNew = Number(maxTokRange.value);
|
| 462 |
+
const repPen = Number(repRange.value);
|
| 463 |
+
|
| 464 |
+
const promptIds = buildPromptIds(tok, history, msg, maxNew);
|
| 465 |
+
const allTokens = promptIds.slice();
|
| 466 |
+
const generated = [];
|
| 467 |
+
|
| 468 |
+
let caches = [];
|
| 469 |
+
for (let i = 0; i < N_LAYER; i++) {
|
| 470 |
+
caches.push(new ort.Tensor("float32", new Float32Array(0), [1, N_HEAD, 0, HEAD_DIM]));
|
| 471 |
+
caches.push(new ort.Tensor("float32", new Float32Array(0), [1, N_HEAD, 0, HEAD_DIM]));
|
| 472 |
+
}
|
| 473 |
+
|
| 474 |
+
let pos = 0;
|
| 475 |
+
let nextChunk = promptIds;
|
| 476 |
+
const t0 = performance.now();
|
| 477 |
+
statusText.textContent = `${modelLabel} yanıt üretiyor...`;
|
| 478 |
+
|
| 479 |
+
for (let step = 0; step < maxNew; step++) {
|
| 480 |
+
if (pos + nextChunk.length >= BLOCK_SIZE) break;
|
| 481 |
+
const posArr = new BigInt64Array(nextChunk.length);
|
| 482 |
+
for (let i = 0; i < nextChunk.length; i++) posArr[i] = BigInt(pos + i);
|
| 483 |
+
|
| 484 |
+
const feeds = {
|
| 485 |
+
input_ids: new ort.Tensor("int64", BigInt64Array.from(nextChunk.map(BigInt)), [1, nextChunk.length]),
|
| 486 |
+
position_ids: new ort.Tensor("int64", posArr, [nextChunk.length]),
|
| 487 |
+
};
|
| 488 |
+
for (let i = 0; i < N_LAYER; i++) {
|
| 489 |
+
feeds[`past_key_${i}`] = caches[2 * i];
|
| 490 |
+
feeds[`past_value_${i}`] = caches[2 * i + 1];
|
| 491 |
+
}
|
| 492 |
+
|
| 493 |
+
const out = await sess.run(feeds);
|
| 494 |
+
pos += nextChunk.length;
|
| 495 |
+
for (let i = 0; i < N_LAYER; i++) {
|
| 496 |
+
caches[2 * i] = out[`present_key_${i}`];
|
| 497 |
+
caches[2 * i + 1] = out[`present_value_${i}`];
|
| 498 |
+
}
|
| 499 |
+
|
| 500 |
+
const seenSet = new Set(allTokens.slice(-BLOCK_SIZE));
|
| 501 |
+
const nxt = pickNextToken(out.logits.data, seenSet, temp, topK, repPen);
|
| 502 |
+
if (nxt === END || nxt === BOS || nxt === USER) break;
|
| 503 |
+
|
| 504 |
+
generated.push(nxt);
|
| 505 |
+
allTokens.push(nxt);
|
| 506 |
+
nextChunk = [nxt];
|
| 507 |
+
|
| 508 |
+
const decoded = tok.decode(generated).trim();
|
| 509 |
+
botUi.bubble.textContent = decoded || "...";
|
| 510 |
+
chatArea.scrollTop = chatArea.scrollHeight;
|
| 511 |
+
await new Promise((r) => setTimeout(r, 0));
|
| 512 |
+
}
|
| 513 |
+
|
| 514 |
+
const finalText = tok.decode(generated).trim() || "(boş yanıt)";
|
| 515 |
+
botUi.bubble.textContent = finalText;
|
| 516 |
+
history.push({ u: msg, a: finalText });
|
| 517 |
+
const sec = Math.max(0.01, (performance.now() - t0) / 1000);
|
| 518 |
+
const tps = (generated.length / sec).toFixed(1);
|
| 519 |
+
statusText.textContent = `Tamamlandı · ${generated.length} token · ${tps} tok/s`;
|
| 520 |
+
} catch (err) {
|
| 521 |
+
botUi.bubble.textContent = "Hata: " + (err && err.message ? err.message : String(err));
|
| 522 |
+
statusText.textContent = "Çalıştırma hatası";
|
| 523 |
+
console.error(err);
|
| 524 |
+
} finally {
|
| 525 |
+
busy = false;
|
| 526 |
+
sendBtn.disabled = false;
|
| 527 |
+
promptInput.focus();
|
| 528 |
+
}
|
| 529 |
+
}
|
| 530 |
+
|
| 531 |
+
sendBtn.onclick = () => sendMessage();
|
| 532 |
+
clearBtn.onclick = () => {
|
| 533 |
+
history = [];
|
| 534 |
+
chatArea.innerHTML = "";
|
| 535 |
+
chatArea.appendChild(emptyState);
|
| 536 |
+
emptyState.style.display = "block";
|
| 537 |
+
statusText.textContent = "Sohbet temizlendi.";
|
| 538 |
+
};
|
| 539 |
+
promptInput.addEventListener("keydown", (e) => {
|
| 540 |
+
if (e.key === "Enter" && !e.shiftKey) {
|
| 541 |
+
e.preventDefault();
|
| 542 |
+
sendMessage();
|
| 543 |
+
}
|
| 544 |
+
});
|
| 545 |
+
promptInput.addEventListener("input", () => {
|
| 546 |
+
promptInput.style.height = "auto";
|
| 547 |
+
promptInput.style.height = Math.min(promptInput.scrollHeight, 120) + "px";
|
| 548 |
+
});
|
| 549 |
+
document.querySelectorAll(".chip").forEach((btn) => {
|
| 550 |
+
btn.addEventListener("click", () => sendMessage(btn.getAttribute("data-q")));
|
| 551 |
+
});
|
| 552 |
+
</script>
|
| 553 |
+
</body>
|
| 554 |
</html>
|
mima-1.5-pico.png
ADDED
|
Git LFS Details
|
mima_1.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8e7623d7502e162fbb48215e3f7eb9499302f3206a6ab7549b811c4fae1845f5
|
| 3 |
+
size 75055556
|
mima_1_5_preview.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:953c9a05f0f610b8a5abfa0931ded747e5256a6f41474a053d5cf17e2cbd559b
|
| 3 |
+
size 75055556
|
tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|