Update README.md
Browse files
README.md
CHANGED
@@ -83,6 +83,12 @@ function collectAttentions(out: Record<string, Tensor>): XtTensor[] {
|
|
83 |
return keys.map((k) => out[k] as unknown as XtTensor);
|
84 |
}
|
85 |
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
/**
|
87 |
* Tokenization:
|
88 |
* Prefer the public callable form `tokenizer(text, {...})` which returns tensors.
|
@@ -112,7 +118,7 @@ const input_ids = Array.from(
|
|
112 |
*/
|
113 |
const out = (await model.forward({
|
114 |
input_ids,
|
115 |
-
attention_mask:
|
116 |
output_attentions: true,
|
117 |
})) as unknown as Record<string, Tensor>;
|
118 |
|
|
|
83 |
return keys.map((k) => out[k] as unknown as XtTensor);
|
84 |
}
|
85 |
|
86 |
+
function onesMask(n: number): Tensor {
|
87 |
+
const data = BigInt64Array.from({ length: n }, () => 1n);
|
88 |
+
return new Tensor('int64', data, [1, n]);
|
89 |
+
}
|
90 |
+
|
91 |
+
|
92 |
/**
|
93 |
* Tokenization:
|
94 |
* Prefer the public callable form `tokenizer(text, {...})` which returns tensors.
|
|
|
118 |
*/
|
119 |
const out = (await model.forward({
|
120 |
input_ids,
|
121 |
+
attention_mask: onesMask(input_ids.length),
|
122 |
output_attentions: true,
|
123 |
})) as unknown as Record<string, Tensor>;
|
124 |
|