Class: LlamaModel
Properties
tokenizer
readonly tokenizer: Tokenizer;
Defined in
evaluator/LlamaModel/LlamaModel.ts:160
onDispose
readonly onDispose: EventRelay<void>;
Defined in
evaluator/LlamaModel/LlamaModel.ts:161
Accessors
disposed
get disposed(): boolean
Returns
boolean
Defined in
evaluator/LlamaModel/LlamaModel.ts:266
tokens
get tokens(): LlamaModelTokens
Returns
Defined in
evaluator/LlamaModel/LlamaModel.ts:270
filename
get filename(): undefined | string
Returns
undefined
| string
Defined in
evaluator/LlamaModel/LlamaModel.ts:274
fileInfo
get fileInfo(): GgufFileInfo
Returns
Defined in
evaluator/LlamaModel/LlamaModel.ts:278
fileInsights
get fileInsights(): GgufInsights
Returns
Defined in
evaluator/LlamaModel/LlamaModel.ts:282
gpuLayers
get gpuLayers(): number
Number of layers offloaded to the GPU. If GPU support is disabled, this will always be 0
.
Returns
number
Defined in
evaluator/LlamaModel/LlamaModel.ts:290
size
get size(): number
Total model size in memory in bytes
Returns
number
Defined in
evaluator/LlamaModel/LlamaModel.ts:297
flashAttentionSupported
get flashAttentionSupported(): boolean
Returns
boolean
Defined in
evaluator/LlamaModel/LlamaModel.ts:303
defaultContextFlashAttention
get defaultContextFlashAttention(): boolean
Returns
boolean
Defined in
evaluator/LlamaModel/LlamaModel.ts:307
trainContextSize
get trainContextSize(): number
The context size the model was trained on
Returns
number
Defined in
evaluator/LlamaModel/LlamaModel.ts:589
embeddingVectorSize
get embeddingVectorSize(): number
The size of an embedding vector the model can produce
Returns
number
Defined in
evaluator/LlamaModel/LlamaModel.ts:599
vocabularyType
get vocabularyType(): LlamaVocabularyType
Returns
Defined in
evaluator/LlamaModel/LlamaModel.ts:608
Methods
dispose()
dispose(): Promise<void>
Returns
Promise
<void
>
Defined in
evaluator/LlamaModel/LlamaModel.ts:252
tokenize()
tokenize(text, specialTokens, options)
tokenize(
text: string,
specialTokens?: boolean,
options?: "trimLeadingSpace"): Token[]
Transform text into tokens that can be fed to the model
Parameters
Parameter | Type | Description |
---|---|---|
text | string | the text to tokenize |
specialTokens ? | boolean | if set to true, text that correspond to special tokens will be tokenized to those tokens. For example, <s> will be tokenized to the BOS token if specialTokens is set to true , otherwise it will be tokenized to tokens that corresponds to the plaintext <s> string. |
options ? | "trimLeadingSpace" | additional options for tokenization. If set to "trimLeadingSpace" , a leading space will be trimmed from the tokenized output if the output has an additional space at the beginning. |
Returns
Token
[]
Defined in
evaluator/LlamaModel/LlamaModel.ts:321
tokenize(text, specialTokens)
tokenize(text: BuiltinSpecialTokenValue, specialTokens: "builtin"): Token[]
Parameters
Parameter | Type |
---|---|
text | BuiltinSpecialTokenValue |
specialTokens | "builtin" |
Returns
Token
[]
Defined in
evaluator/LlamaModel/LlamaModel.ts:322
detokenize()
detokenize(
tokens: readonly Token[],
specialTokens?: boolean,
lastTokens?: readonly Token[]): string
Transform tokens into text
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
tokens | readonly Token [] | undefined | the tokens to detokenize. |
specialTokens ? | boolean | false | if set to true , special tokens will be detokenized to their corresponding token text representation. Recommended for debugging purposes only. > Note: there may be additional spaces around special tokens that were not present in the original text - this is not a bug, this is how the tokenizer is supposed to work. Defaults to false . |
lastTokens ? | readonly Token [] | undefined | the last few tokens that preceded the tokens to detokenize. If provided, the last few tokens will be used to determine whether a space has to be added before the current tokens or not, and apply other detokenizer-specific heuristics to provide the correct text continuation to the existing tokens. Using it may have no effect with some models, but it is still recommended. |
Returns
string
Defined in
evaluator/LlamaModel/LlamaModel.ts:435
getTokenAttributes()
getTokenAttributes(token: Token): TokenAttributes
Parameters
Parameter | Type |
---|---|
token | Token |
Returns
Defined in
evaluator/LlamaModel/LlamaModel.ts:456
isSpecialToken()
isSpecialToken(token: undefined | Token): boolean
Check whether the given token is a special token (a control-type token or a token with no normal text representation)
Parameters
Parameter | Type |
---|---|
token | undefined | Token |
Returns
boolean
Defined in
evaluator/LlamaModel/LlamaModel.ts:467
iterateAllTokens()
iterateAllTokens(): Generator<Token, void, unknown>
Returns
Generator
<Token
, void
, unknown
>
Defined in
evaluator/LlamaModel/LlamaModel.ts:482
isEogToken()
isEogToken(token: undefined | Token): boolean
Check whether the given token is an EOG (End Of Generation) token, like EOS or EOT.
Parameters
Parameter | Type |
---|---|
token | undefined | Token |
Returns
boolean
Defined in
evaluator/LlamaModel/LlamaModel.ts:495
createContext()
createContext(options: LlamaContextOptions): Promise<LlamaContext>
Parameters
Parameter | Type |
---|---|
options | LlamaContextOptions |
Returns
Defined in
evaluator/LlamaModel/LlamaModel.ts:502
createEmbeddingContext()
createEmbeddingContext(options: LlamaEmbeddingContextOptions): Promise<LlamaEmbeddingContext>
Parameters
Parameter | Type |
---|---|
options | LlamaEmbeddingContextOptions |
Returns
Promise
<LlamaEmbeddingContext
>
Defined in
evaluator/LlamaModel/LlamaModel.ts:516
getWarnings()
getWarnings(): string[]
Get warnings about the model file that would affect its usage.
These warnings include all the warnings generated by GgufInsights
, but are more comprehensive.
Returns
string
[]