continue-custom/core/llm/llamaTokenizerWorkerPool.mjs
Rob Leidle 8a278ff8b4
Enable async encoding for the GPTEncoder (#1946)
This will improve the performance of indexing when using a GPT model.
Also, improved the Async interface to also have an async decode method.

Note: I was only able to test this method with the test I added as I do
not have access to a GPT model.

Co-authored-by: Rob Leidle <rleidle@tesla.com>
2024-08-06 16:18:49 -07:00

15 lines
No EOL
280 B
JavaScript

import workerpool from "workerpool";
import llamaTokenizer from "./llamaTokenizer.mjs";
function encode(segment) {
return llamaTokenizer.encode(segment);
}
function decode(tokens) {
return llamaTokenizer.decode(tokens);
}
workerpool.worker({
decode,
encode,
});