Skip to content

Count the Number of Tokens in a Piece of Text #139

@TariqAHassan

Description

@TariqAHassan

🚀 Feature

I would like to be able to compute the number of tokens in a piece of text prior to embedding it.

Motivation

This tool would make it possible to know if the text will be truncated prior to being sent for embedding. If it was too long, one could summarize it first, chunk it, etc.

Basic example

count = token_count(text)
print(count)
# 57

Details

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions