Code Monkey home page Code Monkey logo

Comments (2)

li-plus avatar li-plus commented on June 17, 2024 1

There are actually two kinds of tokenization strategies. For base models (pretrained without SFT) like Baichuan2-7B, it's fine to directly encode the text into token ids without adding any special prefix or suffix tokens, just as your tokenizer('你好吗', return_tensors='pt'). However, for chat models (after SFT) like Baichuan2-7B-Chat, they are usually trained on a specific prompt template during SFT. When they're deployed for inference, their prompt patterns should be respected. In this case, Baichuan2-7B-Chat uses a prompt template like: (see https://huggingface.co/baichuan-inc/Baichuan2-7B-Chat/blob/main/generation_utils.py#L30-L43)

<user_token_id>prompt1<assistant_token_id>response1<user_token_id>prompt2<assistant_token_id>response2 ...

where <user_token_id> is 195 and <assistant_token_id> is 196 according to their generation config (see https://huggingface.co/baichuan-inc/Baichuan2-7B-Chat/blob/main/generation_config.json#L5-L6). We should add these special tokens to make it chat normally.

from chatglm.cpp.

Zhenzhong1 avatar Zhenzhong1 commented on June 17, 2024

Thanks for your reply. I closed this issue.

from chatglm.cpp.

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.