---
base_model: unsloth/Qwen3-0.6B-Base
tags:
- text-generation-inference
- transformers
- unsloth
- qwen2
- trl
- sft
license: apache-2.0
language:
- en
---

# Formatter 0.6B

- **Developed by:** qingy2024
- **License:** apache-2.0
- **Finetuned from model :** Qwen3 0.6B (base)

This is mainly my experiment to play around with adding special tokens and changing the chat template while fine-tuning.

```jinja
{%- set last_message = messages[-1] -%}
{%- if last_message.role == "user" -%}
{{- '<|problem_start|>\n' + last_message.content + '<|problem_end|>\n' -}}
{%- elif last_message.role == "assistant" -%}
{%- for message in messages -%}
{%- if message.role == "user" -%}
{{- '<|problem_start|>\n' + message.content + '<|problem_end|>\n' -}}
{%- elif message.role == "assistant" -%}
{{- '<|formatted_problem_start|>\n' + message.content + '<|formatted_problem_end|>\n' -}}
{%- else -%}
{{- raise('Unknown role: ' + message.role) -}}
{%- endif -%}
{%- endfor -%}
{%- else -%}
{{- raise('Unsupported role: ' + last_message.role) -}}
{%- endif -%}
{%- if add_generation_prompt and last_message.role == "user" -%}
{{- '<|formatted_problem_start|>\n' -}}
{%- endif -%}
```

Example:

```
User: Read the excerpt from Dr. Martin Luther King Jr.’s "I Have a Dream" speech.

I am not unmindful that some of you have come here out of great trials and tribulations. Some of you have come fresh from narrow jail cells. Some of you have come from areas where your quest for freedom left you battered by the storms of persecution and staggered by the winds of police brutality. You have been the veterans of creative suffering. Continue to work with the faith that unearned suffering is redemptive. Go back to Mississippi, go back to Alabama, go back to South Carolina, go back to Georgia, go back to Louisiana, go back to the slums and ghettos of our northern cities, knowing that somehow this situation can and will be changed. Let us not wallow in the valley of despair.

Which lines in this paragraph can be used as examples of metaphor? Select 3 options.

great trials and tribulations
storms of persecution
winds of police brutality
go back to Georgia
this situation can and will be changed
let us not wallow in the valley of despair
```
```
LLM: Read the excerpt from Dr. Martin Luther King Jr.’s "I Have a Dream" speech.

I am not unmindful that some of you have come here out of great trials and tribulations. Some of you have come fresh from narrow jail cells. Some of you have come from areas where your quest for freedom left you battered by the storms of persecution and staggered by the winds of police brutality. You have been the veterans of creative suffering. Continue to work with the faith that unearned suffering is redemptive. Go back to Mississippi, go back to Alabama, go back to South Carolina, go back to Georgia, go back to Louisiana, go back to the slums and ghettos of our northern cities, knowing that somehow this situation can and will be changed. Let us not wallow in the valley of despair.

Which lines in this paragraph can be used as examples of metaphor? Select 3 options.
A. great trials and tribulations
B. storms of persecution
C. winds of police brutality
D. go back to Georgia
E. this situation can and will be changed
F. let us not wallow in the valley of despair
```

### Lessons Learned

- When adding new tokens to the model, LoRA will be much worse. Use full fine-tuning to get better results.
- Be very careful about chat templates. Every character/new line/space matters and not following that can make the model have worse performance.
- For Qwen base models, leave the `<|endoftext|>` as the EOS token. Then you can train it to use other tokens like `<|im_end|>`. If you set the EOS token to `<|im_end|>`, the model will get confused.
- For Qwen models in general, always put the `<|endoftext|>` at the end of each training example.

[<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
