# Dataset Tokenization to Fine-Tune Gemma 3 1B

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fdataset-tokenization-to-fine-tune-gemma-3-1b%2F148877%3E%5C
**Category:** Beginners\
**Created:** [April 4, 2025, 4:43pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fdataset-tokenization-to-fine-tune-gemma-3-1b%2F148877 "2025-04-04T16:43:07Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FJohn6666)%5C
**Post date:** [April 5, 2025, 5:23am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fdataset-tokenization-to-fine-tune-gemma-3-1b%2F148877%2F2 "2025-04-05T05:23:29Z")

</div>

This error occurs when DataCollator is unable to collate the data as expected. There are multiple possible solutions, but I think the smartest thing to do would be to either use an existing DataCollator or write a new one.

Alternatively, you could leave tokenization entirely to the Trainer, but that would mean a significant change to the current code, so I’m not sure what to do in that case…

> <https://stackoverflow.com/questions/71166789/huggingface-valueerror-expected-sequence-of-length-165-at-dim-1-got-128>

> **[Data Collator](https://huggingface.co/docs/transformers/main_classes/data_collator)**
>
> We’re on a journey to advance and democratize artificial intelligence through open source and open science.

> [@Why use tokenizer in Trainer with Tokenized Data](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fwhy-use-tokenizer-in-trainer-with-tokenized-data%2F106433)%3A
>
> Hi there! I am getting started with the implementation of the SageMaker integration using [this notebook](https://github.com/huggingface/notebooks/tree/main/sagemaker/01_getting_started_pytorch). I realised that this notebook preprocesses the train and test set, such that they are tokenized when calling the estimator later in the notebook. However, assessing the script called, the tokenizer is also provided to the Trainer. Can somebody explain to me why this is necessary? This is both a question out of curiosity and for this concrete application, as I am a) worried to tokenize twice…

---

_[View the full topic](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fdataset-tokenization-to-fine-tune-gemma-3-1b%2F148877)._
