Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

fine-tuning

downloading Transformers & required libraries¶

The below cells download the Transformers and required libraries for doing machine learning tasks.

Based on your system, either colab or jupyter, choose the appropriate cell below. On Jupyter, you only need to run the relevant cell one time, the first time that you ever load the Transformers library.

loading our libraries¶

Python 3.13.12

Note: if you are on Jupyter and you get an Attribute Error that points to an issue with the Pyarrow module, run this code to re-install a working version of Pyarrow. Then, restart your Jupyter notebook and the above cell should work. (See huggingface/datasets#6985)

!pip install pyarrow==15.0.2

loading our training dataset and base model¶

['What if I come here and everyone\'s like, "That girl has an unattractive voice."', "And that's all I have right now.", 'I have a dirt bike too, just to top it off.', 'I wish I looked like J. Lo. - Hello? -', '- Uh, I work in real estate.', "'Cause I feel like you have to be somewhat attractive to sell a lot.", "There's a lot of shallow people in this world.", 'Is that a normal question to ask?', 'You have to ask all the questions up front, okay?', 'Obviously, I have, like, a lot of friends.']

configuring training parameters¶

/opt/anaconda3/lib/python3.11/site-packages/trl/trainer/sft_trainer.py:309: UserWarning: You didn't pass a `max_seq_length` argument to the SFTTrainer, this will default to 1024
  warnings.warn(

training!¶

Most of the cells below are commented out to avoid them from running each time this website is generated. In order to run them, make sure you un-comment the cells first.

Loading...
TrainOutput(global_step=750, training_loss=2.9969449055989585, metrics={'train_runtime': 126.0682, 'train_samples_per_second': 47.593, 'train_steps_per_second': 5.949, 'total_flos': 83606677954560.0, 'train_loss': 2.9969449055989585, 'epoch': 3.0})
Hardware accelerator e.g. GPU is available in the environment, but no `device` argument is passed to the `Pipeline` object. Model will be on CPU.
Truncation was not explicitly activated but `max_length` is provided a specific value, please use `truncation=True` to explicitly truncate examples to max length. Defaulting to 'longest_first' truncation strategy. If you encode pairs of sequences (GLUE-style) with the tokenizer you can select this strategy more precisely by providing a specific strategy to `truncation`.
[{'generated_text': "I love that you're taking my mom and I on your lives."}]
[{'generated_text': "My name is Filipa and I'm here to find my mom."}]
[{'generated_text': 'When I\'m with you is like, "What the fuck?" - I\'m like, "What the fuck?" - I\'m like, "What the fuck?" - I\'m like, "What the fuck?" - I\'m like, "What'}]