mistral_common.tokens.tokenizers.utils
chunks(lst, chunk_size)
Chunk a list into smaller lists of a given size.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lst
|
list[str]
|
The list to chunk. |
required |
chunk_size
|
int
|
The size of each chunk. |
required |
Returns:
| Type | Description |
|---|---|
Iterator[list[str]]
|
An iterator over the chunks. |
Examples:
Source code in src/mistral_common/tokens/tokenizers/utils.py
download_tokenizer_from_hf_hub(repo_id, cache_dir=None, token=None, revision=None, force_download=False, local_files_only=False)
Download the tokenizer file of a Mistral model from the Hugging Face Hub.
See here for a list of our OSS models.
Note
You need to install the huggingface_hub package to use this method.
Please run pip install mistral-common[hf-hub] to install it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
repo_id
|
str
|
The Hugging Face repo ID. |
required |
cache_dir
|
str | Path | None
|
The directory where the tokenizer will be cached. |
None
|
token
|
bool | str | None
|
The Hugging Face token to use to download the tokenizer. |
None
|
revision
|
str | None
|
The revision of the model to use. If |
None
|
force_download
|
bool
|
Whether to force the download of the tokenizer. If |
False
|
local_files_only
|
bool
|
Whether to only use local files. If |
False
|
Returns:
| Type | Description |
|---|---|
str
|
The downloaded tokenizer local path for the given model ID. |
Source code in src/mistral_common/tokens/tokenizers/utils.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 | |
get_one_valid_tokenizer_file(files)
Get one valid tokenizer file from a list of files.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
files
|
list[str]
|
The list of files to filter. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The path to the tokenizer file. |
Source code in src/mistral_common/tokens/tokenizers/utils.py
list_local_hf_repo_files(repo_id, revision)
list the files of a local Hugging Face repo.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
repo_id
|
str
|
The Hugging Face repo ID. |
required |
revision
|
str | None
|
The revision of the model to use. If |
required |