AutoTokenizer.from_pretrained
时间: 2023-08-26 12:06:16 浏览: 114
AutoTokenizer.from_pretrained是一个函数,它可以根据预训练模型的路径或名称来实例化一个自适应的tokenizer。通过这个函数,我们可以加载预训练模型的tokenizer,以便用于处理文本数据。 例如,可以使用transformers库中的AutoTokenizer.from_pretrained函数来加载BertTokenizer,如下所示:tokenizer=AutoTokenizer.from_pretrained('bert-base-cased')[2 这将实例化一个基于BERT模型的tokenizer,用于处理文本数据。我们还可以指定其他参数,如padding、truncation和return_tensors,以根据需要对文本进行处理。 此外,我们还可以使用AutoTokenizer.from_pretrained函数来加载与特定模型相关的tokenizer和模型,如下所示:from transformers import AutoTokenizer, AutoModelForSequenceClassification Model_name = 'distillery-base-uncashed-finetuned-still-2-english' model = AutoModelForSequenceClassification.from_pretrained(model_name) tokenizer = AutoTokenizer.from_pretrained(model_name)[3 这将加载一个与指定模型名称相关联的tokenizer和模型。我们可以使用这些tokenizer和模型来进行文本分类任务等。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [huggingface使用(一):AutoTokenizer(通用)、BertTokenizer(基于Bert)](https://blog.csdn.net/u013250861/article/details/124535020)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
- *3* [transformers库的使用【二】tokenizer的使用,模型的保存自定义](https://blog.csdn.net/qq_28790663/article/details/115374855)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)