- Categories:
String & binary functions (AI Functions)
COUNT_ TOKENS (SNOWFLAKE.CORTEX)¶
Note
is the latest version of this function. Use AI_COUNT_TOKENS for the latest functionality. You can continue to use COUNT_TOKENS (SNOWFLAKE.CORTEX).
返回实参中指定的大型语言模型或任务特定函数的提示符中的令牌数。此函数不支持微调模型。
语法
实参
必填:
model_name要作为令牌计数基础的模型的名称。指定以下值之一:
deepseek-r1e5-base-v2e5-large-v2llama3-70bllama3-8bllama3.1-405bllama3.1-70bllama3.1-8bllama3.3-70bllama4-maverickllama4-scoutmistral-7bmistral-largemistral-large2mixtral-8x7bnv-embed-qa-4snowflake-arctic-embed-l-v2.0snowflake-arctic-embed-m-v1.5snowflake-arctic-embed-msnowflake-arcticsnowflake-llama-3.1-405bsnowflake-llama-3.3-70bvoyage-multilingual-2
input_text输入文本,计算其中的令牌。
返回
Returns an INT , INTEGER , BIGINT , SMALLINT , TINYINT , BYTEINT type that is the number of tokens in the input text based on the model or function specified.
使用说明
- 如果指定了函数名称,令牌数将基于函数使用的模型。
- 在函数名称中使用小写字母。
Note
COUNT_TOKENS does not account for the managed system prompt that is automatically added to the beginning of the input text when using a Cortex Cortex AI functions. As a result, the value returned by COUNT_TOKENS is lower than the actual number of tokens processed by these functions.
示例
The following example returns the token count for the specified prompt using the llama3.1-70b model:
法律声明
Refer to Snowflake AI and ML.