Code Monkey home page Code Monkey logo

Comments (4)

belladoreai avatar belladoreai commented on June 10, 2024 1

For instance, counting the special token "<|end_of_text|>" is wrong.

Are you inserting the string <|end_of_text|> into normal input text and expecting it to be parsed as a special token? I have implemented the special tokens in a different manner. I wrote into the README an example of how to work with special tokens. Here is the example from README adapted into this particular token:

const tokens = []
tokens.push(llama3Tokenizer.getSpecialTokenId('<|end_of_text|>'))
console.log(tokens.length) // Count is one

I implemented it this way because I am not sure what to do with all these special tokens, and the official LLaMA 3 repo has similar Python implementation: https://github.com/meta-llama/llama3/blob/main/llama/tokenizer.py#L202-L229

Thinking more about this, maybe I should also parse the special tokens from normal input text?

It might be better to also visualize the token id in the website.

Thank you for the suggestion. I can see how there would be a need for this, though the website is just a quick demo for the library.

from llama3-tokenizer-js.

BeibinLi avatar BeibinLi commented on June 10, 2024

Got it! Makes much more sense now~!

from llama3-tokenizer-js.

belladoreai avatar belladoreai commented on June 10, 2024

I have now added the features you requested:

  1. Visualize token ids on the demo website
  2. Allow passing special tokens inside normal input text, no longer requiring any special function calls

from llama3-tokenizer-js.

BeibinLi avatar BeibinLi commented on June 10, 2024

@belladoreai Awesome! Thanks so much, I appreciate it!

from llama3-tokenizer-js.

Related Issues (5)

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.