语言

CodeGenTokenizer.GetIndexByTokenCountFromEnd 方法

定义

重载

名称 说明
GetIndexByTokenCountFromEnd(ReadOnlySpan<Char>, Int32, Boolean, Boolean, Boolean, String, Int32, Boolean, Boolean)

查找文本中末尾最大编码容量的索引,而不会超过令牌限制。

GetIndexByTokenCountFromEnd(String, Int32, Boolean, Boolean, Boolean, String, Int32, Boolean, Boolean)

查找文本中末尾最大编码容量的索引,而不会超过令牌限制。

GetIndexByTokenCountFromEnd(ReadOnlySpan<Char>, Int32, Boolean, Boolean, Boolean, String, Int32, Boolean, Boolean)

Source:
CodeGenTokenizer.cs
Source:
CodeGenTokenizer.cs
Source:
CodeGenTokenizer.cs

查找文本中末尾最大编码容量的索引,而不会超过令牌限制。

public int GetIndexByTokenCountFromEnd(ReadOnlySpan<char> text, int maxTokenCount, bool addPrefixSpace, bool addBeginningOfSentence, bool addEndOfSentence, out string? normalizedText, out int tokenCount, bool considerPreTokenization = true, bool considerNormalization = true);
override this.GetIndexByTokenCountFromEnd : ReadOnlySpan<char> * int * bool * bool * bool * string * int * bool * bool -> int
Public Function GetIndexByTokenCountFromEnd (text As ReadOnlySpan(Of Char), maxTokenCount As Integer, addPrefixSpace As Boolean, addBeginningOfSentence As Boolean, addEndOfSentence As Boolean, ByRef normalizedText As String, ByRef tokenCount As Integer, Optional considerPreTokenization As Boolean = true, Optional considerNormalization As Boolean = true) As Integer

参数

text
ReadOnlySpan<Char>

要编码的文本。

maxTokenCount
Int32

限制编码容量的最大令牌计数。

addPrefixSpace
Boolean

指示是否在对文本进行编码之前包含前导空格。

addBeginningOfSentence
Boolean

指示是否在编码中包含句子标记的开头。

addEndOfSentence
Boolean

指示是否在编码中包含句子标记的末尾。

normalizedText
String

如果启用了 tokenizer 规范化,则输入文本将以规范化形式表示;否则,它将为 null。

tokenCount
Int32

可以生成令牌计数,该计数应小于最大令牌计数。

considerPreTokenization
Boolean

指示是否在令牌化之前考虑预标记化。

considerNormalization
Boolean

指示是否在标记化之前考虑规范化。

返回

已处理文本中最大编码容量的起始索引,而不会超过令牌限制。 它表示要包含的第一个字符处的索引。 如果不存在标记,则结果将为长度 normalizedText;相反,如果所有标记都合适,则结果将为 0。

注解

如果整个文本可以在令牌限制内进行编码,则返回的索引将为 0。

适用于

GetIndexByTokenCountFromEnd(String, Int32, Boolean, Boolean, Boolean, String, Int32, Boolean, Boolean)

Source:
CodeGenTokenizer.cs
Source:
CodeGenTokenizer.cs
Source:
CodeGenTokenizer.cs

查找文本中末尾最大编码容量的索引,而不会超过令牌限制。

public int GetIndexByTokenCountFromEnd(string text, int maxTokenCount, bool addPrefixSpace, bool addBeginningOfSentence, bool addEndOfSentence, out string? normalizedText, out int tokenCount, bool considerPreTokenization = true, bool considerNormalization = true);
override this.GetIndexByTokenCountFromEnd : string * int * bool * bool * bool * string * int * bool * bool -> int
Public Function GetIndexByTokenCountFromEnd (text As String, maxTokenCount As Integer, addPrefixSpace As Boolean, addBeginningOfSentence As Boolean, addEndOfSentence As Boolean, ByRef normalizedText As String, ByRef tokenCount As Integer, Optional considerPreTokenization As Boolean = true, Optional considerNormalization As Boolean = true) As Integer

参数

text
String

要编码的文本。

maxTokenCount
Int32

限制编码容量的最大令牌计数。

addPrefixSpace
Boolean

指示是否在对文本进行编码之前包含前导空格。

addBeginningOfSentence
Boolean

指示是否在编码中包含句子标记的开头。

addEndOfSentence
Boolean

指示是否在编码中包含句子标记的末尾。

normalizedText
String

如果启用了 tokenizer 规范化,则输入文本将以规范化形式表示;否则,它将为 null。

tokenCount
Int32

可以生成令牌计数,该计数应小于最大令牌计数。

considerPreTokenization
Boolean

指示是否在令牌化之前考虑预标记化。

considerNormalization
Boolean

指示是否在标记化之前考虑规范化。

返回

已处理文本中最大编码容量的起始索引,而不会超过令牌限制。 它表示要包含的第一个字符处的索引。 如果不存在标记,则结果将为文本的长度或 normalizedText 启用规范化;相反,如果所有标记都适合,则结果将为 0。

注解

如果整个文本可以在令牌限制内进行编码,则返回的索引将为 0。

适用于