small_conversational_test

作者 Narsil · 下载 0 · 点赞 0 · 更新 2023-10-31

import tempfile                                                                   
                                                                                  
from tokenizers import Tokenizer, models, processors                              
from transformers.tokenization_utils_fast import PreTrainedTokenizerFast          
                                                                                  
vocab = [(chr(i), i) for i in range(256)]                                         
tokenizer = Tokenizer(models.Unigram(vocab))                                      
tokenizer.add_special_tokens(["<bos>", "<eos>"])                                  
tokenizer.post_processor = processors.TemplateProcessing(                         
    single="<bos> $0 <eos>", special_tokens=[("<bos>", 256), ("<eos>", 257)]      
)                                                                                 
with tempfile.NamedTemporaryFile() as f:                                          
    tokenizer.save(f.name)                                                        
    real_tokenizer = PreTrainedTokenizerFast(tokenizer_file=f.name, eos_token="<eos>", bos_token="<bos>")   
                                                                                  
real_tokenizer._tokenizer.save("dummy.json")     

Small change.

模型信息

该模型卡暂无预览图和文字说明。以下信息来自 Hugging Face。

作者 Narsil
类型—
基础模型—
标签—
下载0
点赞0
更新时间2023-10-31
Hugging Face https://huggingface.co/Narsil/small_conversational_test