9

LoRA Fine-tuning without Code in Watsonx.ai

 10 months ago
source link: https://heidloff.net/article/lora-user-interface-watsonxai/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
LoRA Fine-tuning without Code in Watsonx.ai

LoRA Fine-tuning without Code in Watsonx.ai

Posted Aug 28, 2023 Updated Aug 29, 2023
Preview Image
By Niklas Heidloff
2 min read

Watsonx.ai is IBM’s next generation enterprise studio for AI builders to train, validate, tune and deploy AI models. This post describes how to do LoRA-based fine-tuning with the Tuning Studio without having to write code.

In one of my previous posts I explained LoRA Fine-Tuning. In summary fine-tuning with LoRA requires far less resources and is much faster than classic fine-tuning which changes all weights.

To make fine-tuning more efficient, LoRA’s approach is to represent the weight updates with two smaller matrices […] These new matrices can be trained to adapt to the new data while keeping the overall number of changes low. The original weight matrix remains frozen and doesn’t receive any further adjustments. To produce the final results, both the original and the adapted weights are combined.

Let’s look how the example in my earlier post can be fine-tuned with Watsonx.ai. The dataset is the same one: samsum. The goal is to improve FLAN-T5 XL (3b) to summarize chat dialogues.

Prepare Data

The training set has 14.7k rows. You can download it from Hugging Face. To provide the structure Watsonx.ai expects, change ‘dialogue’ to ‘input’ and ‘summary’ to ‘output’. Furthermore, remove the lines with ids. Tools like Visual Studio Code are your friend. To remove the id lines, Find and Replace can handle regular expressions like “id”: “(.+?)”,.

In Watsonx.ai choose ‘Summarization’:

Upload the data:

Fine-tuning

Define the parameters:

Start the fine-tuning. For only 5 epochs it took less than one hour.

Try the new Model

The additional parameters can be download:

Let’s look at a sample dialogue which was not part of the training data.

Max: Know any good sites to buy clothes from?
Payton: Sure :) <file_other> <file_other> <file_other> <file_other> <file_other> <file_other> <file_other>
Max: That's a lot of them!
Payton: Yeah, but they have different things so I usually buy things from 2 or 3 of them.
Max: I'll check them out. Thanks.
Payton: No problem :)
Max: How about u?
Payton: What about me?
Max: Do u like shopping?
Payton: Yes and no.
Max: How come?
Payton: I like browsing, trying on, looking in the mirror and seeing how I look, but not always buying.
Max: Y not?
Payton: Isn't it obvious? ;)
Max: Sry ;)
Payton: If I bought everything I liked, I'd have nothing left to live on ;)
Max: Same here, but probably different category ;)
Payton: Lol
Max: So what do u usually buy?
Payton: Well, I have 2 things I must struggle to resist!
Max: Which are?
Payton: Clothes, ofc ;)
Max: Right. And the second one?
Payton: Books. I absolutely love reading!
Max: Gr8! What books do u read?
Payton: Everything I can get my hands on :)

The original FLAN-T5 XL model returns this:

Max will check out the sites Payton recommended.

image

The fine-tuned FLAN-T5 XL model returns this:

Payton recommends Max some good sites to buy clothes from. 
Payton likes shopping but doesn't always buy. 
Payton likes reading books.

image

Next Steps

To learn more, check out the Watsonx.ai documentation and the Watsonx.ai landing page.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK