Fix Colab

This commit is contained in:
Daniel Han-Chen 2024-03-14 19:02:29 +11:00
commit eb61377632
3 changed files with 20 additions and 12 deletions

View file

@ -59,7 +59,7 @@ All notebooks are **beginner friendly**! Add your dataset, click "Run All", and
- No change of hardware. Supports NVIDIA GPUs since 2018+. Minimum CUDA Capability 7.0 (V100, T4, Titan V, RTX 20, 30, 40x, A100, H100, L40 etc) [Check your GPU!](https://developer.nvidia.com/cuda-gpus) GTX 1070, 1080 works, but is slow.
- Works on **Linux** and **Windows** via WSL.
- Supports 4bit and 16bit QLoRA / LoRA finetuning via [bitsandbytes](https://github.com/TimDettmers/bitsandbytes).
- Open source trains 5x faster - see [Unsloth Pro](https://unsloth.ai/) for **30x faster training**!
- Open source trains 5x faster - see [Unsloth Pro](https://unsloth.ai/) for up to **30x faster training**!
- If you trained a model with 🦥Unsloth, you can use this cool sticker! &nbsp; <img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/made with unsloth.png" height="50" align="center" />

View file

@ -134,15 +134,6 @@ kaggle-new = [
conda = [
"unsloth[huggingface]",
]
colab = [
"unsloth[cu121]",
]
colab-ampere = [
"unsloth[cu121]",
"packaging",
"ninja",
"flash-attn",
]
colab-torch211 = [
"unsloth[huggingface]",
"bitsandbytes",
@ -169,6 +160,15 @@ colab-ampere-torch220 = [
"ninja",
"flash-attn",
]
colab = [
"unsloth[colab-ampere-torch220]",
]
colab-ampere = [
"unsloth[colab-ampere-torch220]",
"packaging",
"ninja",
"flash-attn",
]
cu118-ampere = [
"unsloth[huggingface]",
"bitsandbytes",

View file

@ -259,8 +259,10 @@ def get_chat_template(
assert("Unsloth: Can only map new tokens to EOS for now. Adding new tokens is not yet supported.")
pass
if tokenizer.__class__.__name__.startswith("Gemma") and chat_template == "chatml":
chat_template = "gemma_chatml"
IS_GEMMA = False
if tokenizer.__class__.__name__.startswith("Gemma"):
if chat_template == "chatml": chat_template = "gemma_chatml"
IS_GEMMA = True
pass
old_padding_side = tokenizer.padding_side
@ -338,6 +340,12 @@ def get_chat_template(
.replace("'user'", "'" + mapping["user"] + "'")\
.replace("'assistant'", "'" + mapping["assistant"] + "'")
# Careful on Gemma
# bos_token is a must or else losses become too high
if IS_GEMMA and not chat_template.startswith("{{ bos_token }}"):
chat_template = "{{ bos_token }}" + chat_template
pass
_, tokenizer = patch_tokenizer(model = None, tokenizer = tokenizer)
tokenizer.padding_side = old_padding_side
tokenizer.chat_template = chat_template