File size: 5,291 Bytes
76a55fd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>0xBitNet Demo</title>
  <style>
    * { margin: 0; padding: 0; box-sizing: border-box; }

    body {
      font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
      background: #0a0a0a;
      color: #e0e0e0;
      height: 100vh;
      display: flex;
      flex-direction: column;
    }

    header {
      padding: 1rem 1.5rem;
      border-bottom: 1px solid #222;
      display: flex;
      align-items: center;
      gap: 0.75rem;
    }

    header h1 { font-size: 1.25rem; font-weight: 600; color: #fff; }

    header .badge {
      font-size: 0.7rem;
      padding: 0.15rem 0.5rem;
      border-radius: 9999px;
      background: #1a3a2a;
      color: #4ade80;
      font-weight: 500;
    }

    #status {
      padding: 0.75rem 1.5rem;
      background: #111;
      border-bottom: 1px solid #222;
      font-size: 0.85rem;
      color: #888;
      display: none;
    }

    .progress-bar {
      margin-top: 0.5rem;
      height: 4px;
      background: #222;
      border-radius: 2px;
      overflow: hidden;
    }

    .progress-fill {
      height: 100%;
      background: #4ade80;
      width: 0%;
      transition: width 0.3s;
    }

    #hero {
      flex: 1;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 1.5rem;
      padding: 2rem;
      text-align: center;
    }

    #hero h2 {
      font-size: 1.5rem;
      color: #fff;
    }

    #hero p {
      max-width: 480px;
      color: #888;
      line-height: 1.6;
      font-size: 0.95rem;
    }

    #hero pre {
      background: #111;
      border: 1px solid #333;
      border-radius: 8px;
      padding: 1.25rem 1.5rem;
      max-width: 560px;
      width: 100%;
      text-align: left;
      font-size: 0.85rem;
      line-height: 1.7;
      color: #c9d1d9;
      overflow-x: auto;
    }

    #hero pre .kw { color: #ff7b72; }
    #hero pre .str { color: #a5d6ff; }
    #hero pre .fn { color: #d2a8ff; }
    #hero pre .cmt { color: #555; }

    #load-btn {
      padding: 0.85rem 2.5rem;
      border-radius: 8px;
      border: none;
      background: #166534;
      color: #fff;
      font-weight: 600;
      cursor: pointer;
      font-size: 1rem;
    }

    #load-btn:hover { background: #15803d; }
    #load-btn:disabled { opacity: 0.5; cursor: not-allowed; }

    #messages {
      flex: 1;
      overflow-y: auto;
      padding: 1.5rem;
      display: none;
      flex-direction: column;
      gap: 1rem;
    }

    .msg {
      max-width: 70%;
      padding: 0.75rem 1rem;
      border-radius: 12px;
      line-height: 1.5;
      white-space: pre-wrap;
      word-break: break-word;
    }

    .msg.user {
      align-self: flex-end;
      background: #1a365d;
      color: #bee3f8;
    }

    .msg.assistant {
      align-self: flex-start;
      background: #1a1a1a;
      border: 1px solid #333;
    }

    #input-area {
      padding: 1rem 1.5rem;
      border-top: 1px solid #222;
      display: none;
      gap: 0.75rem;
    }

    #input-area input {
      flex: 1;
      padding: 0.75rem 1rem;
      border-radius: 8px;
      border: 1px solid #333;
      background: #111;
      color: #e0e0e0;
      font-size: 0.95rem;
      outline: none;
    }

    #input-area input:focus { border-color: #4ade80; }

    #input-area button {
      padding: 0.75rem 1.5rem;
      border-radius: 8px;
      border: none;
      background: #166534;
      color: #fff;
      font-weight: 600;
      cursor: pointer;
    }

    #input-area button:hover { background: #15803d; }
    #input-area button:disabled { opacity: 0.5; cursor: not-allowed; }

    .npm-link {
      font-size: 0.8rem;
      color: #555;
    }

    .npm-link a { color: #4ade80; }
  </style>
  <script type="module" crossorigin src="./assets/index-gTdi7eoP.js"></script>
</head>
<body>
  <header>
    <h1>0xBitNet</h1>
    <span class="badge">WebGPU</span>
  </header>

  <div id="status">
    <span id="status-text">Loading model...</span>
    <div class="progress-bar">
      <div class="progress-fill" id="progress-fill"></div>
    </div>
  </div>

  <div id="hero">
    <h2>BitNet in the Browser. That's it.</h2>
    <pre><code><span class="kw">import</span> { BitNet } <span class="kw">from</span> <span class="str">"0xbitnet"</span>;

<span class="kw">const</span> model = <span class="kw">await</span> BitNet.<span class="fn">load</span>(url);

<span class="kw">for await</span> (<span class="kw">const</span> token <span class="kw">of</span> model.<span class="fn">generate</span>(messages)) {
  process.stdout.<span class="fn">write</span>(token);
}</code></pre>
    <button id="load-btn">Try It — Load BitNet 2B-4T (~700 MB)</button>
    <p class="npm-link"><code>npm install 0xbitnet</code> &mdash; <a href="https://github.com/m96-chan/0xBitNet" target="_blank">GitHub</a> &middot; <a href="https://www.npmjs.com/package/0xbitnet" target="_blank">npm</a></p>
  </div>

  <div id="messages"></div>

  <div id="input-area">
    <input type="text" id="user-input" placeholder="Type a message..." autocomplete="off" />
    <button id="send-btn" disabled>Send</button>
  </div>

</body>
</html>