lm-sys / lm-sys/FastChat

About the function of assign special token ids to the model.config object

Open
#2,243 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
39.5k
Forks
4.8k
PR merge metrics
No merged PRs in 30d

Description

Hi @bofenghuang, I just read through the Qwen-7B code and found the following code fragment,
```
class QwenChatAdapter(BaseModelAdapter):
tokenizer.eos_token_id = config.eos_token_id
tokenizer.bos_token_id = config.bos_token_id
tokenizer.pad_token_id = generation_config.pad_token_id
model.config.eos_token_id = tokenizer.eos_token_id
model.config.bos_token_id = tokenizer.bos_token_id
model.config.pad_token_id = tokenizer.pad_token_id
```
I don't understand the function of adding the `xxx_token_id` to the `model.config.xxx` attribute.
I found some language model like `llama-2` also have the above code.

Could you tell me the funciton of the above code?

Thanks

The link to the above code is:
https://github.com/lm-sys/FastChat/blob/8432833f3bcdcea0fe48b6c28fac8a0f456b3d05/fastchat/model/model_adapter.py#L1322C1-L1330C59

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with fastchat/model/model_adapter.py around the linked QwenChatAdapter lines 1322-1330, then compare the corresponding Llama-2 code mentioned in the issue. Explain the purpose of assigning the special token IDs to model.config and identify whether this behavior should be documented or clarified in the relevant project documentation.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
ai, documentation
Issue type
Documentation
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.