JJoeven

Exercises / llm

Count message tokens (approx)

approx_tokens(messages) is words*1.3 plus 4 per message (role overhead). Print the estimate for a 2-message chat.

Live Pythonpython
Output
Run to execute this in your browser. Nothing is sent to a server.