We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
import GPT3Tokenizer from 'gpt3-tokenizer'; const tokenizer = new GPT3Tokenizer({ type: 'gpt3' }); export function estimateTokens(str: string): number { const encoded: { bpe: number[]; text: string[] } = tokenizer.encode(str); return encoded.bpe.length; }
参考demo
需要同时计算输入的字符+角色描述的字符 如果开启了记忆模式,还需要增加记忆所消耗的字符 总上传token必须少于4096,建议留200的余量,因为计算可能和实际有误差
需要将计算token的方法抽离,之后会用到计算返回答案的token计算
The text was updated successfully, but these errors were encountered:
feat: add GPT3Tokenizer #90
666a45e
74039ae
feat: add GPT3Tokenizer #90 (#94)
49b7ff1
orangelckc
No branches or pull requests
参考demo
需要同时计算输入的字符+角色描述的字符
如果开启了记忆模式,还需要增加记忆所消耗的字符
总上传token必须少于4096,建议留200的余量,因为计算可能和实际有误差
需要将计算token的方法抽离,之后会用到计算返回答案的token计算
The text was updated successfully, but these errors were encountered: