Update server.js
Browse files
server.js
CHANGED
|
@@ -56,13 +56,19 @@ app.post('/chat', async (req, res) => {
|
|
| 56 |
break;
|
| 57 |
}
|
| 58 |
|
| 59 |
-
|
| 60 |
-
const inputData = BigInt64Array.from(ctx.map(x => BigInt(x)));
|
| 61 |
-
const tensor = new ort.Tensor('int64', inputData, [1, ctx.length]);
|
| 62 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
const results = await session.run({ input: tensor });
|
| 64 |
-
const outputName = session.outputNames[0];
|
| 65 |
|
|
|
|
| 66 |
const logits = Array.from(results[outputName].data.slice(-VOCAB_SIZE));
|
| 67 |
|
| 68 |
if (penalty !== 1.0) {
|
|
|
|
| 56 |
break;
|
| 57 |
}
|
| 58 |
|
| 59 |
+
cconst ctx = tokens.slice(-1024);
|
|
|
|
|
|
|
| 60 |
|
| 61 |
+
const paddedInput = new BigInt64Array(1024).fill(0n);
|
| 62 |
+
|
| 63 |
+
for (let i = 0; i < ctx.length; i++) {
|
| 64 |
+
paddedInput[1024 - ctx.length + i] = BigInt(ctx[i]);
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
const tensor = new ort.Tensor('int64', paddedInput, [1, 1024]);
|
| 68 |
+
|
| 69 |
const results = await session.run({ input: tensor });
|
|
|
|
| 70 |
|
| 71 |
+
const outputName = session.outputNames[0];
|
| 72 |
const logits = Array.from(results[outputName].data.slice(-VOCAB_SIZE));
|
| 73 |
|
| 74 |
if (penalty !== 1.0) {
|