模型分词器¶ class torchtune.modules.tokenizers.ModelTokenizer(*args, **kwargs)[source]¶ 抽象分词器,在tokenize_messages方法中实现了模型特定的特殊标记逻辑。请参阅Llama3Tokenizer以了解此协议的示例实现。 tokenize_messages(messages: List[消息], **kwargs: Dict[str, Any]) → Tuple[List[int], List[bool]][source]¶ 给定一个消息列表,返回连接和格式化后的消息的令牌列表和掩码列表。 Parameters: messages (List[消息]) – 要标记化的消息列表。 **kwargs (Dict[str, Any]) – kwargs. Returns: 令牌ID列表和掩码列表。 Return type: 元组[列表[int], 列表[bool]]