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
|
Optional[Union[str, Path]]
|
The directory where the tokenizer will be cached. |
None
|
token
|
Optional[Union[bool, str]]
|
The Hugging Face token to use to download the tokenizer. |
None
|
revision
|
Optional[str]
|
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
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 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 |
|
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
|
Optional[str]
|
The revision of the model to use. If |
required |