Gemma 2: Gemma template won't end with eos token
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 39.5k
- Forks
- 4.8k
- PR merge metrics
- No merged PRs in 30d
Description
For the current gemma template, the template is such that the marks the end of each turn and the last token in the sequence. However, for [Gemma 2 (Table 4)](https://arxiv.org/pdf/2408.00118), the last token should be the eos token. For a workaround, I modified [conversation.py](https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/conversation.py) like so
```
if self.sep_style == SeparatorStyle.GEMMA:
ret = ""
for role, message in self.messages:
if message:
ret += "" + role + "\n" + message + self.sep
else:
ret += "" + role + "\n"
if self.stop_str == "":
ret += ""
```
and registering it like so:
```
register_conv_template(
Conversation(
name="gemma-2",
roles=("user", "model"),
sep_style=SeparatorStyle.GEMMA,
sep="\n",
stop_str="",
),
)
```
I hope this helps other people that run into this!
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in fastchat/conversation.py and inspect the current SeparatorStyle.GEMMA rendering and template registration. Compare the rendered Gemma 2 sequence with Table 4 of the linked paper, then verify that the final token is the eos token rather than only the end-of-turn marker.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- ai
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 52/100