知识卡片
生成函数只返回新增部分
生成器在入口记录 input_length,累积完整上下文,返回时切出输入长度之后的 token。这样返回结果表示生成动作产生的业务结果,调用者无需从文本猜测提示词边界。空输出也可能合法,例如第一步就遇到 EOS。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- · 查看原书依据
#F Return only the generated tokens (excluding the original input) In essence, the generate_text_basic function listing 2.2 applies the argmax-based token ID extraction via a for-loop for a user-specified number of iterations (max_new_tokens). It returns the generated token IDs, similar to what's shown in figure 2.14, which we can then convert back into text. Let's use the function to generate a 100-token response to a
参考来源
- 位置:《Build a Reasoning Model (From Scratch)》第02章《使用预训练模型生成文本》(来源项目:a19c7933-4eda-4176-aebd-30fe7e1ad292;源文件:extracted/Build a Reasoning Model (From Scratch)/_epub-src/OEBPS/Text/chapter-2.html)
- 结论依据:摘录中关于生成函数只返回新增部分的定义、比较或条件支撑卡片;原书表述不严谨的范围已在覆盖记录逐项限定,不把案例结果外推为普遍结论。
- 原始内容:#F Return only the generated tokens (excluding the original input) In essence, the generate_text_basic function listing 2.2 applies the argmax-based token ID extraction via a for-loop for a user-specified number of iterations (max_new_tokens). It returns the generated token IDs, similar to what's shown in figure 2.14, which we can then convert back into text. Let's use the function to generate a 100-token response to a