tokencount

package
v0.0.38 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 12, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package tokencount provides token estimation for LLM text.

Index

Constants

View Source
const CharsPerToken = 4

CharsPerToken is the approximate number of characters per token for GPT-style tokenizers.

Variables

This section is empty.

Functions

func EstimateTokens

func EstimateTokens(text string) int

EstimateTokens estimates the number of LLM tokens in the given text. Uses a simple heuristic of approximately 4 characters per token, which is a common approximation for English text with GPT-style tokenizers.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL