Code Monkey home page Code Monkey logo

Comments (4)

godly-devotion avatar godly-devotion commented on May 19, 2024 1

A helpful rule of thumb is that one token generally corresponds to ~4 characters of text for common English text. This translates to roughly ¾ of a word (so 100 tokens ~= 75 words).
Source: https://beta.openai.com/tokenizer

from mochidiffusion.

godly-devotion avatar godly-devotion commented on May 19, 2024 1

The gpt-3-encoder package provides a python implementation as well as a javascript one.

Both of which give me a more accurate token count than what Mochi provides me with currently. Unfortunately I have never wrote a single line of Swift so I have no idea how I would implement this but I thought I'd leave the info out there.

Token counts differ based on the model's vocab list. Also after I made the initial commit for the naive token counter, @CarterLombardi improved it by actually calculating the real token count (commit: 034bbe7)

from mochidiffusion.

godly-devotion avatar godly-devotion commented on May 19, 2024

So the token≈word isn't correct. I can see the text being truncated in Xcode output but parts of words are getting truncated if it goes over the "token" length. I've tried looking at webui's implementation of their token counter but the code is messy and isn't very straight forward. I'll be open to a PR but I can't figure out exactly what a token is.

from mochidiffusion.

takoyaro avatar takoyaro commented on May 19, 2024

From the same source,

If you need a programmatic interface for tokenizing text, check out the transformers package for python or the gpt-3-encoder package for node.js.

The gpt-3-encoder package provides a python implementation as well as a javascript one.

Both of which give me a more accurate token count than what Mochi provides me with currently. Unfortunately I have never wrote a single line of Swift so I have no idea how I would implement this but I thought I'd leave the info out there.

from mochidiffusion.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.