Spaces:
Running
Running
Upload 12 files
Browse files- T5ModelEncoderWorker.js +8 -1
- index.html +14 -16
- utils.js +1 -1
T5ModelEncoderWorker.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
//load Candle Bert Module wasm module
|
| 2 |
-
|
| 3 |
|
| 4 |
async function fetchArrayBuffer(url) {
|
| 5 |
const cacheName = "t5-candle-cache";
|
|
@@ -17,6 +17,13 @@ class Encoder {
|
|
| 17 |
static instance = {};
|
| 18 |
|
| 19 |
static async getInstance(weightsURL, tokenizerURL, configURL, modelID) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
if (!this.instance[modelID]) {
|
| 21 |
await init();
|
| 22 |
|
|
|
|
| 1 |
//load Candle Bert Module wasm module
|
| 2 |
+
let init, ModelEncoder;
|
| 3 |
|
| 4 |
async function fetchArrayBuffer(url) {
|
| 5 |
const cacheName = "t5-candle-cache";
|
|
|
|
| 17 |
static instance = {};
|
| 18 |
|
| 19 |
static async getInstance(weightsURL, tokenizerURL, configURL, modelID) {
|
| 20 |
+
if (modelID.includes("quantized")) {
|
| 21 |
+
({ default: init, ModelEncoder } = await import(
|
| 22 |
+
"./build/m-quantized.js"
|
| 23 |
+
));
|
| 24 |
+
} else {
|
| 25 |
+
({ default: init, ModelEncoder } = await import("./build/m.js"));
|
| 26 |
+
}
|
| 27 |
if (!this.instance[modelID]) {
|
| 28 |
await init();
|
| 29 |
|
index.html
CHANGED
|
@@ -138,44 +138,42 @@
|
|
| 138 |
<h1 class="text-5xl font-bold">Candle T5 Transformer</h1>
|
| 139 |
<h2 class="text-2xl font-bold">Rust/WASM Demo</h2>
|
| 140 |
<p class="max-w-lg">
|
| 141 |
-
This demo
|
| 142 |
-
<a
|
| 143 |
href="https://blog.research.google/2020/02/exploring-transfer-learning-with-t5.html"
|
| 144 |
target="_blank"
|
| 145 |
-
class="link"
|
| 146 |
-
T5
|
| 147 |
-
|
| 148 |
-
with
|
| 149 |
<a
|
| 150 |
href="https://github.com/huggingface/candle/"
|
| 151 |
target="_blank"
|
| 152 |
class="link">
|
| 153 |
Candle
|
| 154 |
</a>
|
| 155 |
-
|
|
|
|
| 156 |
<a
|
| 157 |
href="https://huggingface.co/t5-small"
|
| 158 |
target="_blank"
|
| 159 |
class="link">
|
| 160 |
-
t5-small
|
| 161 |
>,
|
| 162 |
-
<a href="https://huggingface.co/t5-base" target="_blank" class="link"
|
| 163 |
-
t5-base
|
| 164 |
>,
|
| 165 |
<a
|
| 166 |
href="https://huggingface.co/google/flan-t5-small"
|
| 167 |
target="_blank"
|
| 168 |
class="link"
|
| 169 |
-
>flan-t5-small
|
| 170 |
-
|
| 171 |
-
and
|
| 172 |
<a
|
| 173 |
href="https://huggingface.co/lmz/candle-quantized-t5/tree/main"
|
| 174 |
target="_blank"
|
| 175 |
class="link">
|
| 176 |
-
t5 quantized gguf
|
| 177 |
-
|
| 178 |
-
are available.
|
| 179 |
</p>
|
| 180 |
</div>
|
| 181 |
|
|
|
|
| 138 |
<h1 class="text-5xl font-bold">Candle T5 Transformer</h1>
|
| 139 |
<h2 class="text-2xl font-bold">Rust/WASM Demo</h2>
|
| 140 |
<p class="max-w-lg">
|
| 141 |
+
This demo showcase Text-To-Text Transfer Transformer (<a
|
|
|
|
| 142 |
href="https://blog.research.google/2020/02/exploring-transfer-learning-with-t5.html"
|
| 143 |
target="_blank"
|
| 144 |
+
class="link"
|
| 145 |
+
>T5</a
|
| 146 |
+
>) models right in your browser, thanks to
|
|
|
|
| 147 |
<a
|
| 148 |
href="https://github.com/huggingface/candle/"
|
| 149 |
target="_blank"
|
| 150 |
class="link">
|
| 151 |
Candle
|
| 152 |
</a>
|
| 153 |
+
ML framework and rust/wasm. You can choose from a range of available
|
| 154 |
+
models, including
|
| 155 |
<a
|
| 156 |
href="https://huggingface.co/t5-small"
|
| 157 |
target="_blank"
|
| 158 |
class="link">
|
| 159 |
+
t5-small</a
|
| 160 |
>,
|
| 161 |
+
<a href="https://huggingface.co/t5-base" target="_blank" class="link"
|
| 162 |
+
>t5-base</a
|
| 163 |
>,
|
| 164 |
<a
|
| 165 |
href="https://huggingface.co/google/flan-t5-small"
|
| 166 |
target="_blank"
|
| 167 |
class="link"
|
| 168 |
+
>flan-t5-small</a
|
| 169 |
+
>
|
| 170 |
+
and several t5
|
| 171 |
<a
|
| 172 |
href="https://huggingface.co/lmz/candle-quantized-t5/tree/main"
|
| 173 |
target="_blank"
|
| 174 |
class="link">
|
| 175 |
+
t5 quantized gguf</a
|
| 176 |
+
>.
|
|
|
|
| 177 |
</p>
|
| 178 |
</div>
|
| 179 |
|
utils.js
CHANGED
|
@@ -6,7 +6,7 @@ export async function extractEmbeddings(
|
|
| 6 |
modelID,
|
| 7 |
sentences,
|
| 8 |
updateStatus,
|
| 9 |
-
normalize_embeddings
|
| 10 |
) {
|
| 11 |
return new Promise((resolve, reject) => {
|
| 12 |
worker.postMessage({
|
|
|
|
| 6 |
modelID,
|
| 7 |
sentences,
|
| 8 |
updateStatus,
|
| 9 |
+
normalize_embeddings = true
|
| 10 |
) {
|
| 11 |
return new Promise((resolve, reject) => {
|
| 12 |
worker.postMessage({
|