CodeGenTokenizer.EncodeToIds 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
重载
| 名称 | 说明 |
|---|---|
| EncodeToIds(String, Int32, Boolean, Boolean, Boolean, String, Int32, Boolean, Boolean) |
将输入文本编码为令牌 ID,最大令牌数。 |
| EncodeToIds(String, Boolean, Boolean, Boolean, Boolean, Boolean) |
将输入文本编码为令牌 ID。 |
| EncodeToIds(ReadOnlySpan<Char>, Int32, Boolean, Boolean, Boolean, String, Int32, Boolean, Boolean) |
将输入文本编码为令牌 ID,最大令牌数。 |
| EncodeToIds(String, ReadOnlySpan<Char>, EncodeSettings) |
将输入文本编码为令牌 ID。 |
| EncodeToIds(ReadOnlySpan<Char>, Boolean, Boolean, Boolean, Boolean, Boolean) |
将输入文本编码为令牌 ID。 |
EncodeToIds(String, Int32, Boolean, Boolean, Boolean, String, Int32, Boolean, Boolean)
- Source:
- CodeGenTokenizer.cs
- Source:
- CodeGenTokenizer.cs
- Source:
- CodeGenTokenizer.cs
将输入文本编码为令牌 ID,最大令牌数。
public System.Collections.Generic.IReadOnlyList<int> EncodeToIds(string text, int maxTokenCount, bool addPrefixSpace, bool addBeginningOfSentence, bool addEndOfSentence, out string? normalizedText, out int charsConsumed, bool considerPreTokenization = true, bool considerNormalization = true);
override this.EncodeToIds : string * int * bool * bool * bool * string * int * bool * bool -> System.Collections.Generic.IReadOnlyList<int>
Public Function EncodeToIds (text As String, maxTokenCount As Integer, addPrefixSpace As Boolean, addBeginningOfSentence As Boolean, addEndOfSentence As Boolean, ByRef normalizedText As String, ByRef charsConsumed As Integer, Optional considerPreTokenization As Boolean = true, Optional considerNormalization As Boolean = true) As IReadOnlyList(Of Integer)
参数
- text
- String
要编码的文本。
- maxTokenCount
- Int32
要编码的最大令牌数。
- addPrefixSpace
- Boolean
指示是否在对文本进行编码之前包含前导空格。
- addBeginningOfSentence
- Boolean
指示是否在编码中包含句子标记的开头。
- addEndOfSentence
- Boolean
指示是否在编码中包含句子标记的末尾。
- normalizedText
- String
如果启用了 tokenizer 规范化,则输入文本将以规范化形式表示;否则,它将为 null。
- charsConsumed
- Int32
包含最大编码令牌的文本长度。
- considerPreTokenization
- Boolean
指示是否在令牌化之前考虑预标记化。
- considerNormalization
- Boolean
指示是否在标记化之前考虑规范化。
返回
编码 ID 的列表。
适用于
EncodeToIds(String, Boolean, Boolean, Boolean, Boolean, Boolean)
- Source:
- CodeGenTokenizer.cs
- Source:
- CodeGenTokenizer.cs
- Source:
- CodeGenTokenizer.cs
将输入文本编码为令牌 ID。
public System.Collections.Generic.IReadOnlyList<int> EncodeToIds(string text, bool addPrefixSpace, bool addBeginningOfSentence, bool addEndOfSentence, bool considerPreTokenization = true, bool considerNormalization = true);
override this.EncodeToIds : string * bool * bool * bool * bool * bool -> System.Collections.Generic.IReadOnlyList<int>
Public Function EncodeToIds (text As String, addPrefixSpace As Boolean, addBeginningOfSentence As Boolean, addEndOfSentence As Boolean, Optional considerPreTokenization As Boolean = true, Optional considerNormalization As Boolean = true) As IReadOnlyList(Of Integer)
参数
- text
- String
要编码的文本。
- addPrefixSpace
- Boolean
指示是否在对文本进行编码之前包含前导空格。
- addBeginningOfSentence
- Boolean
指示是否在编码中包含句子标记的开头。
- addEndOfSentence
- Boolean
指示是否在编码中包含句子标记的末尾。
- considerPreTokenization
- Boolean
指示是否在令牌化之前考虑预标记化。
- considerNormalization
- Boolean
指示是否在标记化之前考虑规范化。
返回
编码 ID 的列表。
适用于
EncodeToIds(ReadOnlySpan<Char>, Int32, Boolean, Boolean, Boolean, String, Int32, Boolean, Boolean)
- Source:
- CodeGenTokenizer.cs
- Source:
- CodeGenTokenizer.cs
- Source:
- CodeGenTokenizer.cs
将输入文本编码为令牌 ID,最大令牌数。
public System.Collections.Generic.IReadOnlyList<int> EncodeToIds(ReadOnlySpan<char> text, int maxTokenCount, bool addPrefixSpace, bool addBeginningOfSentence, bool addEndOfSentence, out string? normalizedText, out int charsConsumed, bool considerPreTokenization = true, bool considerNormalization = true);
override this.EncodeToIds : ReadOnlySpan<char> * int * bool * bool * bool * string * int * bool * bool -> System.Collections.Generic.IReadOnlyList<int>
Public Function EncodeToIds (text As ReadOnlySpan(Of Char), maxTokenCount As Integer, addPrefixSpace As Boolean, addBeginningOfSentence As Boolean, addEndOfSentence As Boolean, ByRef normalizedText As String, ByRef charsConsumed As Integer, Optional considerPreTokenization As Boolean = true, Optional considerNormalization As Boolean = true) As IReadOnlyList(Of Integer)
参数
- text
- ReadOnlySpan<Char>
要编码的文本。
- maxTokenCount
- Int32
要编码的最大令牌数。
- addPrefixSpace
- Boolean
指示是否在对文本进行编码之前包含前导空格。
- addBeginningOfSentence
- Boolean
指示是否在编码中包含句子标记的开头。
- addEndOfSentence
- Boolean
指示是否在编码中包含句子标记的末尾。
- normalizedText
- String
如果启用了 tokenizer 规范化,则输入文本将以规范化形式表示;否则,它将为 null。
- charsConsumed
- Int32
包含最大编码令牌的文本长度。
- considerPreTokenization
- Boolean
指示是否在令牌化之前考虑预标记化。
- considerNormalization
- Boolean
指示是否在标记化之前考虑规范化。
返回
编码 ID 的列表。
适用于
EncodeToIds(String, ReadOnlySpan<Char>, EncodeSettings)
- Source:
- CodeGenTokenizer.cs
- Source:
- CodeGenTokenizer.cs
- Source:
- CodeGenTokenizer.cs
将输入文本编码为令牌 ID。
protected override Microsoft.ML.Tokenizers.EncodeResults<int> EncodeToIds(string? text, ReadOnlySpan<char> textSpan, Microsoft.ML.Tokenizers.EncodeSettings settings);
override this.EncodeToIds : string * ReadOnlySpan<char> * Microsoft.ML.Tokenizers.EncodeSettings -> Microsoft.ML.Tokenizers.EncodeResults<int>
Protected Overrides Function EncodeToIds (text As String, textSpan As ReadOnlySpan(Of Char), settings As EncodeSettings) As EncodeResults(Of Integer)
参数
- text
- String
要编码的文本。
- textSpan
- ReadOnlySpan<Char>
要编码的文本范围(如果 text 为 null)。
- settings
- EncodeSettings
用于对文本进行编码的设置。
返回
包含编码 ID 列表的编码结果。
适用于
EncodeToIds(ReadOnlySpan<Char>, Boolean, Boolean, Boolean, Boolean, Boolean)
- Source:
- CodeGenTokenizer.cs
- Source:
- CodeGenTokenizer.cs
- Source:
- CodeGenTokenizer.cs
将输入文本编码为令牌 ID。
public System.Collections.Generic.IReadOnlyList<int> EncodeToIds(ReadOnlySpan<char> text, bool addPrefixSpace, bool addBeginningOfSentence, bool addEndOfSentence, bool considerPreTokenization = true, bool considerNormalization = true);
override this.EncodeToIds : ReadOnlySpan<char> * bool * bool * bool * bool * bool -> System.Collections.Generic.IReadOnlyList<int>
Public Function EncodeToIds (text As ReadOnlySpan(Of Char), addPrefixSpace As Boolean, addBeginningOfSentence As Boolean, addEndOfSentence As Boolean, Optional considerPreTokenization As Boolean = true, Optional considerNormalization As Boolean = true) As IReadOnlyList(Of Integer)
参数
- text
- ReadOnlySpan<Char>
要编码的文本。
- addPrefixSpace
- Boolean
指示是否在对文本进行编码之前包含前导空格。
- addBeginningOfSentence
- Boolean
指示是否在编码中包含句子标记的开头。
- addEndOfSentence
- Boolean
指示是否在编码中包含句子标记的末尾。
- considerPreTokenization
- Boolean
指示是否在令牌化之前考虑预标记化。
- considerNormalization
- Boolean
指示是否在标记化之前考虑规范化。
返回
编码 ID 的列表。