First upload version 0.0.1

This commit is contained in:
Neyra
2026-02-05 15:27:49 +08:00
commit 8e9b7201ed
4182 changed files with 593136 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
import { LlamaVocabularyType } from "../bindings/types.js";
/**
* Resolve whether a token has to be prepended at the beginning of the input, and what should it be,
* based on the tokenizer implementation in `llama.cpp` under the `llama_tokenize_internal` function in `llama-vocab.cpp`
*/
export function resolveBeginningTokenToPrepend(vocabularyType, tokens) {
if (vocabularyType === LlamaVocabularyType.rwkv)
return null;
if (vocabularyType === LlamaVocabularyType.wpm)
return tokens.bos;
if (vocabularyType === LlamaVocabularyType.ugm)
return null;
if (tokens.shouldPrependBosToken)
return tokens.bos;
return null;
}
/**
* Resolve whether a token has to be appended at the end of the input, and what should it be,
* based on the tokenizer implementation in `llama.cpp` under the `llama_tokenize_internal` function in `llama-vocab.cpp`
*/
export function resolveEndTokenToAppend(vocabularyType, tokens) {
if (vocabularyType === LlamaVocabularyType.rwkv)
return null;
if (vocabularyType === LlamaVocabularyType.wpm)
return tokens.sep;
if (vocabularyType === LlamaVocabularyType.ugm)
return tokens.eos;
if (tokens.shouldAppendEosToken)
return tokens.eos;
return null;
}
//# sourceMappingURL=tokenizerUtils.js.map