AI English Shift · Lessons / F03

Tokens and the cost of text

词元与文本成本

Open the interactive lesson · 打开互动课程

A person reads a sentence as words and meaning, while a language-model system first needs a numerical representation of the input.

人阅读句子时理解的是词语和含义,而语言模型系统首先需要把输入表示为数值。

人は文を単語や意味として読みますが、言語モデルのシステムはまず入力を数値で表す必要があります。

A tokenizer divides text into units from a vocabulary and maps those units to token identifiers.

分词器将文本拆分为词表中的单元,并把这些单元映射为词元标识符。

トークナイザーはテキストを語彙にある単位に分け、それぞれをトークンIDに対応付けます。

Depending on the tokenizer, a unit may correspond to a word, a word fragment, punctuation, a space pattern, or bytes.

根据分词器的不同,一个单元可能对应一个词、词的一部分、标点、空格模式或字节。

トークナイザーによって、単位は単語、語の一部、句読点、空白のパターン、バイトなどに対応します。

The identifier is a label for that unit; it is not a human-readable definition of its meaning.

标识符是这个单元的标签,并不是供人阅读的词义定义。

IDはその単位を識別するラベルであり、意味を人が読める形で説明するものではありません。

An embedding step maps token identifiers to vectors that the neural network can process, which is different from splitting text into tokens.

嵌入步骤把词元标识符映射为神经网络可以处理的向量;这与把文本拆分成词元是不同的步骤。

埋め込みの処理はトークンIDをニューラルネットワークが扱えるベクトルに変換するもので、テキストをトークンに分ける処理とは異なります。

The familiar estimate that a token is roughly part of an English word is useful only as an estimate for certain text and tokenizers.

常见的“一个词元大致相当于一个英文词的一部分”只适合作为特定文本和分词器下的粗略估计。

トークンは英単語の一部程度という一般的な目安は、特定の文章とトークナイザーでの概算としてのみ有用です。

Japanese text, source code, unusual names, and tables can have very different token-to-character relationships.

日语文本、源代码、少见的名称和表格,其词元数与字符数之间的关系可能有很大不同。

日本語、ソースコード、珍しい名前、表では、文字数とトークン数の関係が大きく異なることがあります。

A bilingual learning product should therefore measure representative English and Japanese inputs rather than assume identical processing costs.

因此,双语学习产品应测量有代表性的英语和日语输入,而不应假定两者的处理成本相同。

そのため二言語の学習サービスでは、処理費用が同じだと仮定せず、代表的な英語と日本語の入力を測定する必要があります。

Input accounting can include instructions, conversation history, retrieved passages, and tool definitions, not just the latest visible question.

输入用量的计算可能包括指令、对话历史、检索到的段落和工具定义,而不只是界面上可见的最新问题。

入力の計算対象には、最新の質問だけでなく、指示、会話履歴、取得した文章、ツールの定義が含まれる場合があります。

Output accounting depends on the service and model, including how it handles internal reasoning and other generated content.

输出用量如何计算取决于服务和模型,也包括其对内部推理和其他生成内容的计量方式。

出力の計算方法は、内部の推論や他の生成内容をどう扱うかなど、サービスとモデルによって異なります。

For a fictional request, suppose uncached input costs two dollars per million tokens and output costs eight dollars per million tokens.

以一个虚构请求为例,假设未缓存输入的价格为每百万词元两美元,输出的价格为每百万词元八美元。

架空のリクエストで、キャッシュされていない入力100万トークンが2ドル、出力100万トークンが8ドルだとします。

Six thousand input tokens and one thousand output tokens would cost 0.012 dollars plus 0.008 dollars, or 0.02 dollars in total.

六千个输入词元加上一千个输出词元的费用为 0.012 美元加 0.008 美元,总计 0.02 美元。

入力6,000トークンと出力1,000トークンなら、0.012ドルと0.008ドルを足して合計0.02ドルです。

These invented rates illustrate the calculation and are not a quotation of any provider's current prices.

这些虚构费率只用于演示计算,并不是任何服务商当前价格的报价。

この架空の料金は計算方法を示すもので、特定の事業者の現在の料金を引用したものではありません。

If an agent makes several requests to complete one task, total task cost includes all those requests and any separately charged tools.

如果智能体为完成一项任务发出了多个请求,任务总成本就包括这些请求,以及任何单独收费的工具费用。

エージェントが1つの作業に複数回のリクエストを行う場合、総費用には全リクエストと、別料金が発生するツールの利用も含まれます。

Prefix caching can reuse computation for a shared input prefix, provided that the provider's cache conditions are met.

只要满足服务商的缓存条件,前缀缓存就可以复用共同输入前缀的计算结果。

プレフィックスキャッシュは、事業者のキャッシュ条件を満たす場合に、共通する入力の先頭部分の計算を再利用できます。

Caching is not the same as remembering a fact, and a discounted cached input can still occupy context capacity.

缓存不等于记住一条事实,而且享受折扣的缓存输入仍可能占用上下文容量。

キャッシュは事実を記憶することとは異なり、割引対象の入力でもコンテキストの容量を使うことがあります。

The useful optimization target is cost per successful task, because shortening an input can increase errors and expensive retries.

更有用的优化目标是每次成功完成任务的成本,因为缩短输入可能增加错误和代价高昂的重试。

入力を短くすると誤りや高額な再試行が増えることもあるため、有用な最適化の対象は、成功した作業1件あたりの費用です。

Key terms