That is half three of our collection — Finetuning Gemma!
I’ve used a custom-curated dataset to fine-tune Gemma — One liner to story dataset.
On this put up, allow us to practice the mannequin utilizing this dataset and push it to HuggingFace.
I used these traces of code to push the fine-tuned mannequin to Hugging Face. You’ll have to log in to Hugging Face first utilizing the command huggingface-cli login.
mannequin.push_to_hub("akshitha-k/oneliner-to-stories")
tokenizer.push_to_hub("akshitha-k/oneliner-to-stories")
As I used to be utilizing unsloth, my whole coaching course of solely took about 18 minutes even for 60 epochs. Moreover, I skilled the identical mannequin a number of occasions utilizing totally different parameters, whereas testing the mannequin in between the runs.
Throughout inference, I used to be additionally in a position to see the outputs.
Nevertheless, I bumped into a problem that took about 2 weeks to resolve.
Since I used LoRA fine-tuning, config.json is neither generated nor saved. LoRA fine-tuning works by including a set of weights to the pre-existing weights. We’re solely modifying the adapter, not the general configuration. Consequently, solely the adapter.json file is being generated, and never your entire config.json file.
On account of this, I at all times bumped into a problem, whereas making an attempt to make use of the fine-tuned mannequin.
‘’cant discover config.json’’
‘’doesn’t seem to have a file named config.json’’
I used to be making an attempt to generate a config.json file for a lot of days earlier than I spotted I wanted to make use of totally different traces of code to make use of the mannequin for inference.
I’ve added these particulars to the mannequin card of the mannequin on Hugging Face — Here is the link to it.
We’ve got a mannequin — a fine-tuned model of Gemma, that takes solely a one-liner because the enter and generates a narrative based mostly on it, whereas selling constructive behaviors, educating ethical values and avoiding violence and scary themes.
Right here’s an instance of how the mannequin generated a narrative from a one-liner. Letssss gooooooo!!!
### Enter: Ash and Roh discovered a fortress…
### Response: In a faraway land, there was a fantastic fortress that had been deserted for a few years. In the future, two pals named Ash and Roh determined to discover the fortress. As they walked by means of the halls, they seen one thing unusual — the partitions had been lined in unusual symbols and markings. Ash requested, “Roh, are you aware what these symbols imply?” Roh replied, “I believe they could be some form of code or language. Let’s attempt to decipher it!” They spent hours making an attempt to determine the which means of the symbols, however nothing appeared to make sense. Simply after they had been about to surrender, they discovered a hidden room full of books and scrolls. Amongst them was a guide titled ‘The Misplaced Language of the Ancients’. As they learn the guide, they found that the symbols had been certainly a language spoken by the individuals who constructed the fortress way back. It was known as ‘Elvish’, and it was used for communication between totally different races dwelling in concord. Excitedly, Ash and Roh continued exploring the fortress, translating increasingly more Elvish phrases and phrases. However then, one thing sudden occurred. A sudden earthquake shook the bottom, inflicting elements of the fortress to break down. Ash and Roh ran exterior, realizing that the fortress was crumbling down round them. They seemed up on the sky and noticed a vivid mild coming from the route of the fortress. It was the solar setting behind the ruins, casting a heat glow over the scene. In that second, Ash turned to Roh and stated, “You understand, regardless that we didn’t get to completely perceive the language, we nonetheless discovered a lot in regards to the world and its historical past. And isn’t that what issues most?” And so, regardless that the fortress fell aside, Ash and Roh left with a newfound appreciation for information and discovery. Typically, our best classes come from sudden locations, reminding us that each expertise, regardless of how disappointing, can nonetheless educate us one thing priceless.