mindspore/docs/api/api_python/dataset_text/mindspore.dataset.text.Sent...

62 lines
3.5 KiB
ReStructuredText
Raw Normal View History

2022-02-24 15:57:18 +08:00
mindspore.dataset.text.SentencePieceVocab
==========================================
2022-02-28 14:19:59 +08:00
.. py:class:: mindspore.dataset.text.SentencePieceVocab
2022-02-24 15:57:18 +08:00
用于执行分词的SentencePiece对象。
.. py:method:: from_dataset(dataset, col_names, vocab_size, character_coverage, model_type, params)
从数据集构建SentencePiece。
**参数:**
2022-02-26 11:08:21 +08:00
2022-02-24 15:57:18 +08:00
- **dataset** (Dataset) - 表示用于构建SentencePiece对象的数据集。
- **col_names** (list) - 表示列名称的列表。
- **vocab_size** (int) - 表示词汇大小。
2022-03-31 11:10:18 +08:00
- **character_coverage** (float) - 表示模型涵盖的字符数量。推荐的默认值为0.9995适用于具有丰富字符集的语言如日文或中文1.0适用于具有小字符集的其他语言。
2022-02-24 15:57:18 +08:00
- **model_type** (SentencePieceModel) - 其值可以是SentencePieceModel.UNIGRAM、SentencePieceModel.BPE、SentencePieceModel.CHAR或SentencePieceModel.WORD默认值SentencePieceModel.UNIgram。使用SentencePieceModel.WORD类型时必须预先标记输入句子。
- SentencePieceModel.UNIGRAMUnigram语言模型意味着句子中的下一个单词被假定为独立于模型生成的前一个单词。
- SentencePieceModel.BPE指字节对编码算法它取代了最频繁的对句子中的字节数其中包含一个未使用的字节。
- SentencePieceModel.CHAR引用基于字符的SentencePiece模型类型。
2022-03-31 11:10:18 +08:00
- SentencePieceModel.WORD引用基于单词的SentencePiece模型类型。
2022-02-24 15:57:18 +08:00
- **params** (dict):表示没有传入参数的字典。
**返回:**
2022-02-26 11:08:21 +08:00
2022-03-31 11:10:18 +08:00
SentencePieceVocab从数据集构建的Vocab对象。
2022-02-24 15:57:18 +08:00
.. py:method:: from_file(file_path, vocab_size, character_coverage, model_type, params)
从文件中构建一个SentencePiece对象。
2022-02-24 15:57:18 +08:00
**参数:**
2022-02-26 11:08:21 +08:00
2022-03-31 11:10:18 +08:00
- **file_path** (list) - 表示包含SentencePiece文件路径的一个列表。
2022-02-24 15:57:18 +08:00
- **vocab_size** (int) - 表示词汇大小。
2022-04-07 15:54:44 +08:00
- **character_coverage** (float) - 表示模型涵盖的字符数量。推荐的默认值为0.9995适用于具有丰富字符集的语言如日文或中文1.0适用于具有小字符集的其他语言。
2022-02-24 15:57:18 +08:00
- **model_type** (SentencePieceModel) - 其值可以是SentencePieceModel.UNIGRAM、SentencePieceModel.BPE、SentencePieceModel.CHAR或SentencePieceModel.WORD默认值为SentencePieceModel.UNIgram。使用SentencePieceModel.WORD类型时必须预先标记输入句子。
- SentencePieceModel.UNIGRAMUnigram语言模型意味着句子中的下一个单词被假定为独立于模型生成的前一个单词。
- SentencePieceModel.BPE指字节对编码算法它取代了最频繁的对句子中的字节数其中包含一个未使用的字节。
- SentencePieceModel.CHAR引用基于字符的SentencePiece模型类型。
2022-03-31 11:10:18 +08:00
- SentencePieceModel.WORD引用基于单词的SentencePiece模型类型。
2022-02-24 15:57:18 +08:00
- **params** (dict)表示没有传入参数的字典参数派生自SentencePiece库
**返回:**
2022-02-26 11:08:21 +08:00
2022-03-31 11:10:18 +08:00
SentencePieceVocab表示从文件中构建的Vocab对象。
2022-02-24 15:57:18 +08:00
.. py:method:: save_model(vocab, path, filename)
将模型保存到给定的文件路径。
**参数:**
2022-02-24 15:57:18 +08:00
- **vocab** (SentencePieceVocab) - 表示一个SentencePiece对象。
- **path** (str) - 表示存储模型的路径。
- **filename** (str) - 表示文件名称。