LoRA - Low-rank Adaption of AI Large Language Models: LoRA and QLoRA Explained Simply
Wes Roth Wes Roth
185K subscribers
31,912 views
0

 Published On Jun 1, 2023

What is LoRA in AI?

You may have heard of a concept called LoRA or QLoRA referring to AI and Large Language Models.

Imagine you have a giant box full of Legos.

You can build all kinds of things with this giant box - houses, cars, spaceships.

But it's so big and heavy that it's hard to carry around.

And most of the time, you don't need all these Legos to build what you want to build.

So instead, you pick out a smaller box of your favorite, most useful Legos.

This smaller box is easier to carry around, and you can still build most of the things you want.

In this analogy, the giant box of Legos is like a large language model, like GPT-4.

It's powerful and can do lots of things, but it's also big and heavy (it requires a lot of computational resources to use).

The smaller box of Legos is like a "low-rank adaptation" of the large language model.

It's a smaller, lighter version of the model that's been adapted for a specific task.

It's not as powerful as the full model - there might be some things it can't do - but it's more efficient and easier to use.

“Low-Rank Adaptation”

LoRA stands for

“Low-Rank Adaptation”

"Low-rank" in this context refers to a mathematical technique used to create this smaller, lighter model.

You can also think of “Low-Rank” as just reading all the highlighted parts in a book.

“Full Rank” would be reading the entire book and “Low-Rank” would be reading just the important, highlighted parts.

Why is LoRA important?

Let’s say you have a large and advanced AI model trained on recognizing all sorts of images.

You can "fine-tune" it to do a related task (like recognizing images of cats, specifically) by making small adjustments to that large model.

You can also “fine-tune” it to add behaviors you want or remove behaviors you don’t.

But this can be very expensive in terms of what computers you would need and how long it would take.

Lora solves this problem by making it cheap and fast to fine tune smaller models




LoRA is important because:

1. Efficiency

Using LoRA can greatly reduce the amount of resources used to train AI models to perform these tasks.

2. Speed

These lower-rank models are faster to train,but they also can provide faster outputs.

This can be crucial in applications where results need to happen in real-time.

3. Limited Resources

In many real world applications the devices that are available to run AI models may have limited computational power or memory.

Your smartphone may not be able to run a large AI model, but a Low-Rank Adaptation can be used for specific tasks you may need.

4. Stacking and Transfering

Low-rank adaptations can be helpful for transfer learning where a model trained on one task can be adapted to a different, but related task.

This is much more efficient than training the large model to do something from scratch.

The updates and new skills learned by these low rank adaptations can also stack with other such adaptations, so multiple models can benefit each other as well as the original larger model.

QLoRa

QLoRA is a similar concept.

The Q is for Quantized, so QLoRA is Quantized Low Rank Adaptation.

Quantized refers to data compression.

Quantization is converting a continuous range of values into a finite set of possible values.

Image if you’re an artist mixing paint.

You have an almost infinite range of colors you can create by mixing different amounts of colors together.

This is like a continuous signal in the real world.

But if you are working with a computer graphics program, it can’t handle an infinite range of colors.

It might only allow each color component (red, green, and blue) to have one of several levels of intensity.

This limited set of possible colors is like a quantized signal.

Here it can apply to reducing the number of decimal places we need to express a number.
For example Pi is an infinitely long number, but we can use 3.14 as an approximation when doing calculations.

Hope you liked that!

Take a look at our next video or checkout our top watched videos in the descriptions

show more

Share/Embed