@huggingface/transformers 4.0.0-next.5 → 4.0.0-next.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -4
- package/dist/ort-wasm-simd-threaded.jsep.mjs +24 -24
- package/dist/transformers.js +2189 -1015
- package/dist/transformers.min.js +16 -16
- package/dist/transformers.node.cjs +2234 -1029
- package/dist/transformers.node.min.cjs +20 -20
- package/dist/transformers.node.min.mjs +20 -20
- package/dist/transformers.node.mjs +2194 -1017
- package/dist/transformers.web.js +2175 -1001
- package/dist/transformers.web.min.js +18 -18
- package/package.json +4 -4
- package/src/backends/onnx.js +77 -58
- package/src/backends/utils/cacheWasm.js +22 -43
- package/src/cache_utils.js +62 -0
- package/src/configs.js +32 -5
- package/src/env.js +36 -6
- package/src/image_processors_utils.js +3 -3
- package/src/models/auto/modeling_auto.js +14 -1
- package/src/models/chatterbox/modeling_chatterbox.js +1 -1
- package/src/models/detr/image_processing_detr.js +1 -1
- package/src/models/feature_extractors.js +2 -0
- package/src/models/gemma3n/modeling_gemma3n.js +2 -0
- package/src/models/granite_speech/feature_extraction_granite_speech.js +58 -0
- package/src/models/granite_speech/modeling_granite_speech.js +5 -0
- package/src/models/granite_speech/processing_granite_speech.js +62 -0
- package/src/models/grounding_dino/image_processing_grounding_dino.js +1 -1
- package/src/models/idefics3/modeling_idefics3.js +5 -32
- package/src/models/image_processors.js +1 -0
- package/src/models/lfm2_vl/image_processing_lfm2_vl.js +305 -0
- package/src/models/lfm2_vl/modeling_lfm2_vl.js +13 -0
- package/src/models/lfm2_vl/processing_lfm2_vl.js +77 -0
- package/src/models/llava/modeling_llava.js +1 -1
- package/src/models/mistral3/modeling_mistral3.js +2 -2
- package/src/models/modeling_utils.js +234 -292
- package/src/models/models.js +9 -0
- package/src/models/olmo_hybrid/modeling_olmo_hybrid.js +5 -0
- package/src/models/paligemma/modeling_paligemma.js +2 -25
- package/src/models/processors.js +3 -0
- package/src/models/qwen2_5_vl/modeling_qwen2_5_vl.js +5 -1
- package/src/models/qwen2_moe/modeling_qwen2_moe.js +5 -0
- package/src/models/qwen2_vl/image_processing_qwen2_vl.js +1 -41
- package/src/models/qwen2_vl/modeling_qwen2_vl.js +36 -3
- package/src/models/qwen3_5/modeling_qwen3_5.js +1 -0
- package/src/models/qwen3_5_moe/modeling_qwen3_5_moe.js +2 -1
- package/src/models/qwen3_moe/modeling_qwen3_moe.js +5 -0
- package/src/models/qwen3_next/modeling_qwen3_next.js +5 -0
- package/src/models/qwen3_vl/modeling_qwen3_vl.js +2 -1
- package/src/models/qwen3_vl_moe/modeling_qwen3_vl_moe.js +4 -0
- package/src/models/registry.js +39 -4
- package/src/models/sam/image_processing_sam.js +1 -1
- package/src/models/session.js +17 -6
- package/src/models/smolvlm/modeling_smolvlm.js +7 -0
- package/src/models/ultravox/modeling_ultravox.js +1 -3
- package/src/models/voxtral/modeling_voxtral.js +3 -0
- package/src/models/voxtral_realtime/feature_extraction_voxtral_realtime.js +71 -0
- package/src/models/voxtral_realtime/modeling_voxtral_realtime.js +239 -0
- package/src/models/voxtral_realtime/processing_voxtral_realtime.js +113 -0
- package/src/models/whisper/feature_extraction_whisper.js +2 -12
- package/src/pipelines/index.js +2 -84
- package/src/pipelines.js +40 -77
- package/src/transformers.js +2 -0
- package/src/utils/audio.js +18 -2
- package/src/utils/cache/CrossOriginStorageCache.js +251 -0
- package/src/utils/cache/FileCache.js +128 -0
- package/src/utils/cache/cross-origin-storage.d.ts +38 -0
- package/src/utils/cache.js +8 -3
- package/src/utils/hub/{files.js → FileResponse.js} +0 -105
- package/src/utils/hub/utils.js +35 -1
- package/src/utils/hub.js +6 -5
- package/src/utils/image.js +12 -13
- package/src/utils/lru_cache.js +67 -0
- package/src/utils/memoize_promise.js +45 -0
- package/src/utils/model_registry/ModelRegistry.js +70 -23
- package/src/utils/model_registry/get_file_metadata.js +14 -2
- package/src/utils/model_registry/get_model_files.js +63 -78
- package/src/utils/model_registry/get_pipeline_files.js +15 -24
- package/src/utils/model_registry/is_cached.js +81 -4
- package/src/utils/tensor.js +18 -2
- package/types/backends/onnx.d.ts.map +1 -1
- package/types/backends/utils/cacheWasm.d.ts +3 -17
- package/types/backends/utils/cacheWasm.d.ts.map +1 -1
- package/types/cache_utils.d.ts +29 -0
- package/types/cache_utils.d.ts.map +1 -0
- package/types/configs.d.ts.map +1 -1
- package/types/env.d.ts +18 -3
- package/types/env.d.ts.map +1 -1
- package/types/image_processors_utils.d.ts +17 -1
- package/types/image_processors_utils.d.ts.map +1 -1
- package/types/models/auto/modeling_auto.d.ts +6 -0
- package/types/models/auto/modeling_auto.d.ts.map +1 -1
- package/types/models/detr/image_processing_detr.d.ts +1 -1
- package/types/models/feature_extractors.d.ts +2 -0
- package/types/models/gemma3n/modeling_gemma3n.d.ts +2 -0
- package/types/models/gemma3n/modeling_gemma3n.d.ts.map +1 -1
- package/types/models/granite_speech/feature_extraction_granite_speech.d.ts +16 -0
- package/types/models/granite_speech/feature_extraction_granite_speech.d.ts.map +1 -0
- package/types/models/granite_speech/modeling_granite_speech.d.ts +4 -0
- package/types/models/granite_speech/modeling_granite_speech.d.ts.map +1 -0
- package/types/models/granite_speech/processing_granite_speech.d.ts +19 -0
- package/types/models/granite_speech/processing_granite_speech.d.ts.map +1 -0
- package/types/models/grounding_dino/image_processing_grounding_dino.d.ts +1 -1
- package/types/models/idefics3/modeling_idefics3.d.ts +2 -18
- package/types/models/idefics3/modeling_idefics3.d.ts.map +1 -1
- package/types/models/image_processors.d.ts +1 -0
- package/types/models/lfm2_vl/image_processing_lfm2_vl.d.ts +41 -0
- package/types/models/lfm2_vl/image_processing_lfm2_vl.d.ts.map +1 -0
- package/types/models/lfm2_vl/modeling_lfm2_vl.d.ts +4 -0
- package/types/models/lfm2_vl/modeling_lfm2_vl.d.ts.map +1 -0
- package/types/models/lfm2_vl/processing_lfm2_vl.d.ts +18 -0
- package/types/models/lfm2_vl/processing_lfm2_vl.d.ts.map +1 -0
- package/types/models/mistral3/modeling_mistral3.d.ts +2 -2
- package/types/models/mistral3/modeling_mistral3.d.ts.map +1 -1
- package/types/models/modeling_utils.d.ts +44 -24
- package/types/models/modeling_utils.d.ts.map +1 -1
- package/types/models/models.d.ts +9 -0
- package/types/models/olmo_hybrid/modeling_olmo_hybrid.d.ts +8 -0
- package/types/models/olmo_hybrid/modeling_olmo_hybrid.d.ts.map +1 -0
- package/types/models/paligemma/modeling_paligemma.d.ts +2 -8
- package/types/models/paligemma/modeling_paligemma.d.ts.map +1 -1
- package/types/models/processors.d.ts +3 -0
- package/types/models/qwen2_5_vl/modeling_qwen2_5_vl.d.ts +3 -0
- package/types/models/qwen2_5_vl/modeling_qwen2_5_vl.d.ts.map +1 -1
- package/types/models/qwen2_moe/modeling_qwen2_moe.d.ts +8 -0
- package/types/models/qwen2_moe/modeling_qwen2_moe.d.ts.map +1 -0
- package/types/models/qwen2_vl/image_processing_qwen2_vl.d.ts.map +1 -1
- package/types/models/qwen2_vl/modeling_qwen2_vl.d.ts +2 -0
- package/types/models/qwen2_vl/modeling_qwen2_vl.d.ts.map +1 -1
- package/types/models/qwen3_5/modeling_qwen3_5.d.ts +2 -0
- package/types/models/qwen3_5/modeling_qwen3_5.d.ts.map +1 -1
- package/types/models/qwen3_5_moe/modeling_qwen3_5_moe.d.ts +3 -0
- package/types/models/qwen3_5_moe/modeling_qwen3_5_moe.d.ts.map +1 -1
- package/types/models/qwen3_moe/modeling_qwen3_moe.d.ts +8 -0
- package/types/models/qwen3_moe/modeling_qwen3_moe.d.ts.map +1 -0
- package/types/models/qwen3_next/modeling_qwen3_next.d.ts +8 -0
- package/types/models/qwen3_next/modeling_qwen3_next.d.ts.map +1 -0
- package/types/models/qwen3_vl/modeling_qwen3_vl.d.ts +3 -0
- package/types/models/qwen3_vl/modeling_qwen3_vl.d.ts.map +1 -1
- package/types/models/qwen3_vl_moe/modeling_qwen3_vl_moe.d.ts +7 -0
- package/types/models/qwen3_vl_moe/modeling_qwen3_vl_moe.d.ts.map +1 -0
- package/types/models/registry.d.ts +2 -1
- package/types/models/registry.d.ts.map +1 -1
- package/types/models/sam/image_processing_sam.d.ts +1 -1
- package/types/models/session.d.ts +3 -2
- package/types/models/session.d.ts.map +1 -1
- package/types/models/smolvlm/modeling_smolvlm.d.ts +8 -0
- package/types/models/smolvlm/modeling_smolvlm.d.ts.map +1 -0
- package/types/models/ultravox/modeling_ultravox.d.ts +0 -2
- package/types/models/ultravox/modeling_ultravox.d.ts.map +1 -1
- package/types/models/voxtral/modeling_voxtral.d.ts +4 -0
- package/types/models/voxtral/modeling_voxtral.d.ts.map +1 -0
- package/types/models/voxtral_realtime/feature_extraction_voxtral_realtime.d.ts +28 -0
- package/types/models/voxtral_realtime/feature_extraction_voxtral_realtime.d.ts.map +1 -0
- package/types/models/voxtral_realtime/modeling_voxtral_realtime.d.ts +17 -0
- package/types/models/voxtral_realtime/modeling_voxtral_realtime.d.ts.map +1 -0
- package/types/models/voxtral_realtime/processing_voxtral_realtime.d.ts +44 -0
- package/types/models/voxtral_realtime/processing_voxtral_realtime.d.ts.map +1 -0
- package/types/models/whisper/feature_extraction_whisper.d.ts.map +1 -1
- package/types/pipelines/index.d.ts +0 -34
- package/types/pipelines/index.d.ts.map +1 -1
- package/types/pipelines.d.ts.map +1 -1
- package/types/transformers.d.ts +1 -0
- package/types/transformers.d.ts.map +1 -1
- package/types/utils/audio.d.ts +5 -2
- package/types/utils/audio.d.ts.map +1 -1
- package/types/utils/cache/CrossOriginStorageCache.d.ts +120 -0
- package/types/utils/cache/CrossOriginStorageCache.d.ts.map +1 -0
- package/types/utils/cache/FileCache.d.ts +39 -0
- package/types/utils/cache/FileCache.d.ts.map +1 -0
- package/types/utils/cache.d.ts +4 -4
- package/types/utils/cache.d.ts.map +1 -1
- package/types/utils/dtypes.d.ts +1 -1
- package/types/utils/hub/{files.d.ts → FileResponse.d.ts} +1 -38
- package/types/utils/hub/FileResponse.d.ts.map +1 -0
- package/types/utils/hub/utils.d.ts +17 -2
- package/types/utils/hub/utils.d.ts.map +1 -1
- package/types/utils/hub.d.ts +7 -7
- package/types/utils/hub.d.ts.map +1 -1
- package/types/utils/image.d.ts +1 -1
- package/types/utils/image.d.ts.map +1 -1
- package/types/utils/lru_cache.d.ts +38 -0
- package/types/utils/lru_cache.d.ts.map +1 -0
- package/types/utils/memoize_promise.d.ts +14 -0
- package/types/utils/memoize_promise.d.ts.map +1 -0
- package/types/utils/model_registry/ModelRegistry.d.ts +66 -6
- package/types/utils/model_registry/ModelRegistry.d.ts.map +1 -1
- package/types/utils/model_registry/get_file_metadata.d.ts.map +1 -1
- package/types/utils/model_registry/get_model_files.d.ts +1 -0
- package/types/utils/model_registry/get_model_files.d.ts.map +1 -1
- package/types/utils/model_registry/get_pipeline_files.d.ts +2 -1
- package/types/utils/model_registry/get_pipeline_files.d.ts.map +1 -1
- package/types/utils/model_registry/is_cached.d.ts +47 -4
- package/types/utils/model_registry/is_cached.d.ts.map +1 -1
- package/types/utils/tensor.d.ts.map +1 -1
- package/src/utils/data-structures.js +0 -572
- package/types/utils/data-structures.d.ts +0 -294
- package/types/utils/data-structures.d.ts.map +0 -1
- package/types/utils/hub/files.d.ts.map +0 -1
|
@@ -1,294 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file Custom data structures.
|
|
3
|
-
*
|
|
4
|
-
* These are only used internally, meaning an end-user shouldn't
|
|
5
|
-
* need to access anything here.
|
|
6
|
-
*
|
|
7
|
-
* @module utils/data-structures
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* Efficient Heap-based Implementation of a Priority Queue.
|
|
11
|
-
* It uses an array-based binary heap, where the root is at index `0`, and the
|
|
12
|
-
* children of node `i` are located at indices `2i + 1` and `2i + 2`, respectively.
|
|
13
|
-
*
|
|
14
|
-
* Adapted from the following sources:
|
|
15
|
-
* - https://stackoverflow.com/a/42919752/13989043 (original)
|
|
16
|
-
* - https://github.com/belladoreai/llama-tokenizer-js (minor improvements)
|
|
17
|
-
*/
|
|
18
|
-
export class PriorityQueue {
|
|
19
|
-
/**
|
|
20
|
-
* Create a new PriorityQueue.
|
|
21
|
-
* @param {function(any, any): boolean} comparator Comparator function to determine priority. Defaults to a MaxHeap.
|
|
22
|
-
*/
|
|
23
|
-
constructor(comparator?: (arg0: any, arg1: any) => boolean, maxSize?: number);
|
|
24
|
-
_heap: any[];
|
|
25
|
-
_comparator: (arg0: any, arg1: any) => boolean;
|
|
26
|
-
_maxSize: number;
|
|
27
|
-
/**
|
|
28
|
-
* The size of the queue
|
|
29
|
-
*/
|
|
30
|
-
get size(): number;
|
|
31
|
-
/**
|
|
32
|
-
* Check if the queue is empty.
|
|
33
|
-
* @returns {boolean} `true` if the queue is empty, `false` otherwise.
|
|
34
|
-
*/
|
|
35
|
-
isEmpty(): boolean;
|
|
36
|
-
/**
|
|
37
|
-
* Return the element with the highest priority in the queue.
|
|
38
|
-
* @returns {any} The highest priority element in the queue.
|
|
39
|
-
*/
|
|
40
|
-
peek(): any;
|
|
41
|
-
/**
|
|
42
|
-
* Add one or more elements to the queue.
|
|
43
|
-
* @param {...any} values The values to push into the queue.
|
|
44
|
-
* @returns {number} The new size of the queue.
|
|
45
|
-
*/
|
|
46
|
-
push(...values: any[]): number;
|
|
47
|
-
/**
|
|
48
|
-
* Add multiple elements to the queue.
|
|
49
|
-
* @param {any[]} values The values to push into the queue.
|
|
50
|
-
* @returns {number} The new size of the queue.
|
|
51
|
-
*/
|
|
52
|
-
extend(values: any[]): number;
|
|
53
|
-
/**
|
|
54
|
-
* Remove and return the element with the highest priority in the queue.
|
|
55
|
-
* @returns {any} The element with the highest priority in the queue.
|
|
56
|
-
*/
|
|
57
|
-
pop(): any;
|
|
58
|
-
/**
|
|
59
|
-
* Replace the element with the highest priority in the queue with a new value.
|
|
60
|
-
* @param {*} value The new value.
|
|
61
|
-
* @returns {*} The replaced value.
|
|
62
|
-
*/
|
|
63
|
-
replace(value: any): any;
|
|
64
|
-
/**
|
|
65
|
-
* Compute the index for the parent of the node at index `i`.
|
|
66
|
-
* @param {number} i The index of the node to get the parent of.
|
|
67
|
-
* @returns {number} The index of the parent node.
|
|
68
|
-
* @private
|
|
69
|
-
*/
|
|
70
|
-
private _parent;
|
|
71
|
-
/**
|
|
72
|
-
* Compute the index for the left child of the node at index `i`.
|
|
73
|
-
* @param {number} i The index of the node to get the left child of.
|
|
74
|
-
* @returns {number} The index of the left child.
|
|
75
|
-
* @private
|
|
76
|
-
*/
|
|
77
|
-
private _left;
|
|
78
|
-
/**
|
|
79
|
-
* Compute the index for the right child of the node at index `i`.
|
|
80
|
-
* @param {number} i The index of the node to get the right child of.
|
|
81
|
-
* @returns {number} The index of the right child.
|
|
82
|
-
* @private
|
|
83
|
-
*/
|
|
84
|
-
private _right;
|
|
85
|
-
/**
|
|
86
|
-
* Check if the element at index `i` is greater than the element at index `j`.
|
|
87
|
-
* @param {number} i The index of the first element to compare.
|
|
88
|
-
* @param {number} j The index of the second element to compare.
|
|
89
|
-
* @returns {boolean} `true` if the element at index `i` is greater than the element at index `j`, `false` otherwise.
|
|
90
|
-
* @private
|
|
91
|
-
*/
|
|
92
|
-
private _greater;
|
|
93
|
-
/**
|
|
94
|
-
* Swap the elements at indices `i` and `j`.
|
|
95
|
-
* @param {number} i The index of the first element to swap.
|
|
96
|
-
* @param {number} j The index of the second element to swap.
|
|
97
|
-
* @private
|
|
98
|
-
*/
|
|
99
|
-
private _swap;
|
|
100
|
-
/**
|
|
101
|
-
* Maintain the heap property by updating positions in the heap,
|
|
102
|
-
* starting at the last element and moving up the heap.
|
|
103
|
-
* @private
|
|
104
|
-
*/
|
|
105
|
-
private _siftUp;
|
|
106
|
-
/**
|
|
107
|
-
* Helper function to sift up from a given node.
|
|
108
|
-
* @param {number} node The index of the node to start sifting up from.
|
|
109
|
-
*/
|
|
110
|
-
_siftUpFrom(node: number): void;
|
|
111
|
-
/**
|
|
112
|
-
* Maintain the heap property by updating positions in the heap,
|
|
113
|
-
* starting at the first element and moving down the heap.
|
|
114
|
-
* @private
|
|
115
|
-
*/
|
|
116
|
-
private _siftDown;
|
|
117
|
-
/**
|
|
118
|
-
* Get the index of the smallest element in the heap. Since we use an array-based heap,
|
|
119
|
-
* the index can be computed without needing to traverse the heap.
|
|
120
|
-
* @private
|
|
121
|
-
*/
|
|
122
|
-
private _smallest;
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* A trie structure to efficiently store and search for strings.
|
|
126
|
-
*/
|
|
127
|
-
export class CharTrie {
|
|
128
|
-
root: CharTrieNode;
|
|
129
|
-
/**
|
|
130
|
-
* Adds one or more `texts` to the trie.
|
|
131
|
-
* @param {string[]} texts The strings to add to the trie.
|
|
132
|
-
*/
|
|
133
|
-
extend(texts: string[]): void;
|
|
134
|
-
/**
|
|
135
|
-
* Adds text to the trie.
|
|
136
|
-
* @param {string} text The string to add to the trie.
|
|
137
|
-
*/
|
|
138
|
-
push(text: string): void;
|
|
139
|
-
/**
|
|
140
|
-
* Searches the trie for all strings with a common prefix of `text`.
|
|
141
|
-
* @param {string} text The common prefix to search for.
|
|
142
|
-
* @yields {string} Each string in the trie that has `text` as a prefix.
|
|
143
|
-
*/
|
|
144
|
-
commonPrefixSearch(text: string): Generator<string, void, unknown>;
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* A lattice data structure to be used for tokenization.
|
|
148
|
-
*/
|
|
149
|
-
export class TokenLattice {
|
|
150
|
-
/**
|
|
151
|
-
* Creates a new TokenLattice instance.
|
|
152
|
-
*
|
|
153
|
-
* @param {string} sentence The input sentence to be tokenized.
|
|
154
|
-
* @param {number} bosTokenId The beginning-of-sequence token ID.
|
|
155
|
-
* @param {number} eosTokenId The end-of-sequence token ID.
|
|
156
|
-
*/
|
|
157
|
-
constructor(sentence: string, bosTokenId: number, eosTokenId: number);
|
|
158
|
-
chars: string[];
|
|
159
|
-
len: number;
|
|
160
|
-
bosTokenId: number;
|
|
161
|
-
eosTokenId: number;
|
|
162
|
-
nodes: TokenLatticeNode[];
|
|
163
|
-
beginNodes: any[][];
|
|
164
|
-
endNodes: any[][];
|
|
165
|
-
/**
|
|
166
|
-
* Inserts a new token node into the token lattice.
|
|
167
|
-
*
|
|
168
|
-
* @param {number} pos The starting position of the token.
|
|
169
|
-
* @param {number} length The length of the token.
|
|
170
|
-
* @param {number} score The score of the token.
|
|
171
|
-
* @param {number} tokenId The token ID of the token.
|
|
172
|
-
*/
|
|
173
|
-
insert(pos: number, length: number, score: number, tokenId: number): void;
|
|
174
|
-
/**
|
|
175
|
-
* Implements the Viterbi algorithm to compute the most likely sequence of tokens.
|
|
176
|
-
*
|
|
177
|
-
* @returns {TokenLatticeNode[]} The most likely sequence of tokens.
|
|
178
|
-
*/
|
|
179
|
-
viterbi(): TokenLatticeNode[];
|
|
180
|
-
/**
|
|
181
|
-
* @param {TokenLatticeNode} node
|
|
182
|
-
* @returns {string} The array of nodes representing the most likely sequence of tokens.
|
|
183
|
-
*/
|
|
184
|
-
piece(node: TokenLatticeNode): string;
|
|
185
|
-
/**
|
|
186
|
-
* @returns {string[]} The most likely sequence of tokens.
|
|
187
|
-
*/
|
|
188
|
-
tokens(): string[];
|
|
189
|
-
/**
|
|
190
|
-
* @returns {number[]} The most likely sequence of token ids.
|
|
191
|
-
*/
|
|
192
|
-
tokenIds(): number[];
|
|
193
|
-
}
|
|
194
|
-
/**
|
|
195
|
-
* A data structure which uses a trie to split a string into tokens based on a dictionary.
|
|
196
|
-
* It can also use a regular expression to preprocess the input text before splitting.
|
|
197
|
-
*
|
|
198
|
-
* NOTE: To ensure multi-byte characters are handled correctly, we operate at byte-level instead of character-level.
|
|
199
|
-
*/
|
|
200
|
-
export class DictionarySplitter {
|
|
201
|
-
/**
|
|
202
|
-
* @param {string[]} dictionary The dictionary of words to use for splitting.
|
|
203
|
-
*/
|
|
204
|
-
constructor(dictionary: string[]);
|
|
205
|
-
trie: any;
|
|
206
|
-
/**
|
|
207
|
-
* Builds a trie from the given dictionary.
|
|
208
|
-
* @param {string[]} dictionary The dictionary of words to build the trie from.
|
|
209
|
-
* @returns {Object} The root node of the trie.
|
|
210
|
-
* @private
|
|
211
|
-
*/
|
|
212
|
-
private _buildTrie;
|
|
213
|
-
/**
|
|
214
|
-
* Splits the input text into tokens based on the dictionary.
|
|
215
|
-
* @param {string} text The input text to split.
|
|
216
|
-
* @returns {string[]} An array of tokens.
|
|
217
|
-
*/
|
|
218
|
-
split(text: string): string[];
|
|
219
|
-
}
|
|
220
|
-
/**
|
|
221
|
-
* A simple Least Recently Used (LRU) cache implementation in JavaScript.
|
|
222
|
-
* This cache stores key-value pairs and evicts the least recently used item
|
|
223
|
-
* when the capacity is exceeded.
|
|
224
|
-
*/
|
|
225
|
-
export class LRUCache {
|
|
226
|
-
/**
|
|
227
|
-
* Creates an LRUCache instance.
|
|
228
|
-
* @param {number} capacity The maximum number of items the cache can hold.
|
|
229
|
-
*/
|
|
230
|
-
constructor(capacity: number);
|
|
231
|
-
capacity: number;
|
|
232
|
-
cache: Map<any, any>;
|
|
233
|
-
/**
|
|
234
|
-
* Retrieves the value associated with the given key and marks the key as recently used.
|
|
235
|
-
* @param {any} key The key to retrieve.
|
|
236
|
-
* @returns {any} The value associated with the key, or undefined if the key does not exist.
|
|
237
|
-
*/
|
|
238
|
-
get(key: any): any;
|
|
239
|
-
/**
|
|
240
|
-
* Inserts or updates the key-value pair in the cache.
|
|
241
|
-
* If the key already exists, it is updated and marked as recently used.
|
|
242
|
-
* If the cache exceeds its capacity, the least recently used item is evicted.
|
|
243
|
-
* @param {any} key The key to add or update.
|
|
244
|
-
* @param {any} value The value to associate with the key.
|
|
245
|
-
*/
|
|
246
|
-
put(key: any, value: any): void;
|
|
247
|
-
/**
|
|
248
|
-
* Clears the cache.
|
|
249
|
-
*/
|
|
250
|
-
clear(): void;
|
|
251
|
-
}
|
|
252
|
-
/**
|
|
253
|
-
* Represents a node in a character trie.
|
|
254
|
-
*/
|
|
255
|
-
declare class CharTrieNode {
|
|
256
|
-
/**
|
|
257
|
-
* Returns a new `CharTrieNode` instance with default values.
|
|
258
|
-
* @returns {CharTrieNode} A new `CharTrieNode` instance with `isLeaf` set to `false` and an empty `children` map.
|
|
259
|
-
*/
|
|
260
|
-
static default(): CharTrieNode;
|
|
261
|
-
/**
|
|
262
|
-
* Create a new CharTrieNode.
|
|
263
|
-
* @param {boolean} isLeaf Whether the node is a leaf node or not.
|
|
264
|
-
* @param {Map<string, CharTrieNode>} children A map containing the node's children, where the key is a character and the value is a `CharTrieNode`.
|
|
265
|
-
*/
|
|
266
|
-
constructor(isLeaf: boolean, children: Map<string, CharTrieNode>);
|
|
267
|
-
isLeaf: boolean;
|
|
268
|
-
children: Map<string, CharTrieNode>;
|
|
269
|
-
}
|
|
270
|
-
declare class TokenLatticeNode {
|
|
271
|
-
/**
|
|
272
|
-
* Represents a node in a token lattice for a given sentence.
|
|
273
|
-
* @param {number} tokenId The ID of the token associated with this node.
|
|
274
|
-
* @param {number} nodeId The ID of this node.
|
|
275
|
-
* @param {number} pos The starting position of the token in the sentence.
|
|
276
|
-
* @param {number} length The length of the token.
|
|
277
|
-
* @param {number} score The score associated with the token.
|
|
278
|
-
*/
|
|
279
|
-
constructor(tokenId: number, nodeId: number, pos: number, length: number, score: number);
|
|
280
|
-
tokenId: number;
|
|
281
|
-
nodeId: number;
|
|
282
|
-
pos: number;
|
|
283
|
-
length: number;
|
|
284
|
-
score: number;
|
|
285
|
-
prev: any;
|
|
286
|
-
backtraceScore: number;
|
|
287
|
-
/**
|
|
288
|
-
* Returns a clone of this node.
|
|
289
|
-
* @returns {TokenLatticeNode} A clone of this node.
|
|
290
|
-
*/
|
|
291
|
-
clone(): TokenLatticeNode;
|
|
292
|
-
}
|
|
293
|
-
export {};
|
|
294
|
-
//# sourceMappingURL=data-structures.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"data-structures.d.ts","sourceRoot":"","sources":["../../src/utils/data-structures.js"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;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,YAHW,gBAAgB,GACd,MAAM,CAIlB;IAED;;OAEG;IACH,UAFa,MAAM,EAAE,CAKpB;IAED;;OAEG;IACH,YAFa,MAAM,EAAE,CAKpB;CACJ;AAgCD;;;;;GAKG;AACH;IACI;;OAEG;IACH,wBAFW,MAAM,EAAE,EAIlB;IADG,UAAuC;IAG3C;;;;;OAKG;IACH,mBAUC;IAED;;;;OAIG;IACH,YAHW,MAAM,GACJ,MAAM,EAAE,CAoCpB;CACJ;AAED;;;;GAIG;AACH;IACI;;;OAGG;IACH,sBAFW,MAAM,EAKhB;IAFG,iBAAwB;IACxB,qBAAsB;IAG1B;;;;OAIG;IACH,SAHW,GAAG,GACD,GAAG,CAQf;IAED;;;;;;OAMG;IACH,SAHW,GAAG,SACH,GAAG,QAUb;IAED;;OAEG;IACH,cAEC;CACJ;AA3SD;;GAEG;AACH;IAWI;;;OAGG;IACH,kBAFa,YAAY,CAIxB;IAhBD;;;;OAIG;IACH,oBAHW,OAAO,YACP,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,EAKnC;IAFG,gBAAoB;IACpB,oCAAwB;CAU/B;AA0HD;IACI;;;;;;;OAOG;IACH,qBANW,MAAM,UACN,MAAM,OACN,MAAM,UACN,MAAM,SACN,MAAM,EAUhB;IAPG,gBAAsB;IACtB,eAAoB;IACpB,YAAc;IACd,eAAoB;IACpB,cAAkB;IAClB,UAAgB;IAChB,uBAAyB;IAG7B;;;OAGG;IACH,SAFa,gBAAgB,CAO5B;CACJ"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../../src/utils/hub/files.js"],"names":[],"mappings":"AAkBA;IACI;;;OAGG;IACH,sBAFW,MAAM,EAgChB;IA7BG,iBAAwB;IACxB,iBAA4B;IAE5B,gBAAqC;IAEjC,eAAiB;IACjB,mBAAsB;IAQtB,0BASE;IAQV;;;;OAIG;IACH,qBAFa,IAAI,CAMhB;IAED;;;OAGG;IACH,SAFa,YA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