Fine tuning LLama 3 LLM for Text Classification of Stock Sentiment using QLoRA

  Рет қаралды 1,695

Trade Mamba

Trade Mamba

Күн бұрын

Fine tuning LLama 3 for Text Classification for Sentiment Analysis of Financial Data using Hugging Face Transformers using QLoRA and Peft and Lora
This video follows • LLaMA 3 LLM & Hugging ...
Code:
github.com/adidror005/youtube...

Пікірлер: 39
@MLAlgoTrader
@MLAlgoTrader 16 күн бұрын
Code Here including short explanation on how to get dataset. github.com/adidror005/youtube-videos/blob/main/LLAMA_3_Fine_Tuning_for_Sequence_Classification_Actual_Video.ipynb
@andrewbritt3117
@andrewbritt3117 15 күн бұрын
Hello, thanks for the really informative walkthough. I was looking to go back through your notebook for further review, however the notebook no longer available from the link.
@MLAlgoTrader
@MLAlgoTrader 15 күн бұрын
@@andrewbritt3117 github.com/adidror005/youtube-videos/blob/main/LLAMA_3_Fine_Tuning_for_Sequence_Classification_Actual_Video.ipynb
@andrewbritt3117
@andrewbritt3117 15 күн бұрын
@@MLAlgoTrader thanks!
@ranxu9473
@ranxu9473 11 күн бұрын
thanks dude that's very useful for me.
@MLAlgoTrader
@MLAlgoTrader 10 күн бұрын
@ranxu9473 thank you
@user-be8om3ov2k
@user-be8om3ov2k 19 күн бұрын
great video mate! loved it
@MLAlgoTrader
@MLAlgoTrader 19 күн бұрын
Glad you enjoyed
@am7-p
@am7-p 19 күн бұрын
Once again, thank you for the informative channel and sharing this video.
@MLAlgoTrader
@MLAlgoTrader 19 күн бұрын
Thanks I thought you guys on average didn't like LLM videos lol. My click through rate is low so it makes me happy you say that.
@am7-p
@am7-p 19 күн бұрын
@@MLAlgoTrader What is click through rate ?
@am7-p
@am7-p 19 күн бұрын
@@MLAlgoTrader Also, please consider that knowing what you are working on helps me to plan for the next steps of my development Currently, I use and pay for OpenAI API, but I do plan for implementing a LLama in my home-lab. Once I start to learn and practice LLama, I will go through your videos again.
@MLAlgoTrader
@MLAlgoTrader 19 күн бұрын
This was is small like
@MLAlgoTrader
@MLAlgoTrader 19 күн бұрын
Honestly, it is completely random. My next videos are on sequential bootstrap, implementing a gap trading strategy both with stocks and with options, the dangers of backtesting, and then I also plan to do ib_insnyc for begginers. ...I think it llama 3 8b params works free version of colab for a bit until you get kicked of gpu. There is also this api I used I think you get quite a bit free at first. docs.llama-api.com/quickstart .
@amitocamitoc2294
@amitocamitoc2294 17 күн бұрын
Interesting!
@MLAlgoTrader
@MLAlgoTrader 17 күн бұрын
Glad you think so!
@salmakhaled-hn6gw
@salmakhaled-hn6gw 18 күн бұрын
Thank you so much, it is very informative. Could I ask you when will you provide the notebook you worked on?
@MLAlgoTrader
@MLAlgoTrader 17 күн бұрын
Yes the delay is cuz I need a notebook t explain how to get the data
@MLAlgoTrader
@MLAlgoTrader 17 күн бұрын
So I literally was about to share video but I had a bug so needed to restart. Must wait 24 hours due to api limit. So I'll send it 25 hours from now lol!
@MLAlgoTrader
@MLAlgoTrader 16 күн бұрын
Code: github.com/adidror005/youtube-videos/blob/main/LLAMA_3_Fine_Tuning_for_Sequence_Classification_Actual_Video.ipynb
@salmakhaled-hn6gw
@salmakhaled-hn6gw 16 күн бұрын
@@MLAlgoTrader Thank you so much🙏
@MLAlgoTrader
@MLAlgoTrader 16 күн бұрын
@@salmakhaled-hn6gw No problem. There are a few more things I left out hopefully we can cover them in another video like loading the model and merging with QlORA weights. Does the part about getting the data make sense? You need that to run the notebook!
@khachapuri_
@khachapuri_ 15 күн бұрын
Is there a way to remove attention-mask from Llama-3 to turn it into a giant BERT (encoder-only transformer)?
@MLAlgoTrader
@MLAlgoTrader 15 күн бұрын
Being on 0 sleep I'll quote chatgpt and get back to answering you later lol.... Turning Llama-3 into an encoder-only transformer like BERT, by removing the attention mask, is theoretically possible but involves more than just altering the attention mechanism. Here are the steps and considerations for this transformation:Modify Attention Mechanism: In Llama-3, which is presumably an autoregressive transformer like GPT-3, each token can only attend to previous tokens. To make it behave like BERT, you need to allow each token to attend to all other tokens in the sequence. This involves changing the attention mask settings in the transformer's layers.Change Training Objective: BERT uses a masked language model (MLM) training objective where some percentage of the input tokens are masked, and the model predicts these masked tokens. You would need to implement this training objective for the modified Llama-3.Adjust Tokenizer and Inputs: BERT is trained with pairs of sentences as inputs (for tasks like next sentence prediction), and uses special tokens (like [CLS] and [SEP]) to distinguish between sentences. You would need to adapt the tokenizer and data preprocessing steps to accommodate these requirements.Retraining the Model: Even after these modifications, the model would need to be retrained from scratch or fine-tuned extensively on a suitable dataset because the pre-existing weights were optimized for a different architecture and objective.Software and Implementation: You need to ensure that the transformer library you're using supports these customizations. Libraries like Hugging Face Transformers are quite flexible and might be useful for this purpose.This transformation essentially creates a new model, leveraging the architecture of Llama-3 but fundamentally changing its operation and purpose. Such a project would be substantial and complex but interesting from a research and development perspective.
@khachapuri_
@khachapuri_ 15 күн бұрын
@@MLAlgoTrader Thank you so much, appreciate the response! Since its a classification task it makes sense to remove the mask (make it encoder-only) and retrain the model to another objective function. I was just wondering technically how would you remove the mask from llama-3? and maybe also add a feedforward layer? Is it possible to edit the architecture like that?
@dariyanagashi8958
@dariyanagashi8958 13 күн бұрын
Hello! Thank you so much for your tutorial, it is very helpful and easy to follow. I started applying it in on my custom binary dataset, but stumbled on the training step. I get the error with this line of code: labels = inputs.pop("labels").long() KeyError: 'labels' My inputs look like this: ['input_ids', 'attention_mask'] and I don't understand which "labels" are you referring to in that line. If it is not difficult for you, could you explain what it means? I would be most grateful! UPD: I renamed the columns of my dataset to "text" and "labels", and it solved the issue! 😀
@MLAlgoTrader
@MLAlgoTrader 13 күн бұрын
I will get back to you
@MLAlgoTrader
@MLAlgoTrader 9 күн бұрын
Hey sorry haven't gotten to this. Haven't forgot I will look this week sometime just overwhelmed.
@dariyanagashi8958
@dariyanagashi8958 9 күн бұрын
@@MLAlgoTrader hi! I actually updated my comment that I found the workaround for that issue, although I still vaguely understand how it helped. Need to read more documentation, I guess. Anyways, thank you for your tutorial, it helped me with my thesis 😊
@MLAlgoTrader
@MLAlgoTrader 9 күн бұрын
Wow very happy to hear!!!
@MLAlgoTrader
@MLAlgoTrader 9 күн бұрын
Your comment made my day. I'll do more videos related to nlp/llm/rag/etc.. soon I hope
@aibutsimple
@aibutsimple 17 күн бұрын
notebook please sir provide me
@MLAlgoTrader
@MLAlgoTrader 17 күн бұрын
It will be available later today. It is just useless if you can't get the data and I can't get data till evening
@MLAlgoTrader
@MLAlgoTrader 16 күн бұрын
Code: github.com/adidror005/youtube-videos/blob/main/LLAMA_3_Fine_Tuning_for_Sequence_Classification_Actual_Video.ipynb
QLoRA-How to Fine-tune an LLM on a Single GPU (w/ Python Code)
36:58
Stupid man 👨😂
00:20
Nadir Show
Рет қаралды 29 МЛН
Can You Draw The PERFECT Circle?
00:57
Stokes Twins
Рет қаралды 75 МЛН
Разбудила маму🙀@KOTVITSKY TG:👉🏼great_hustle
00:11
МишАня
Рет қаралды 3,3 МЛН
GraphRAG: LLM-Derived Knowledge Graphs for RAG
15:40
Alex Chao
Рет қаралды 49 М.
Fine-tuning Large Language Models (LLMs) | w/ Example Code
28:18
Shaw Talebi
Рет қаралды 228 М.
Fine-Tune Llama3 using Synthetic Data
37:03
Chris Hay
Рет қаралды 1,2 М.
LoRA & QLoRA Fine-tuning Explained In-Depth
14:39
Entry Point AI
Рет қаралды 21 М.
"okay, but I want Llama 3 for my specific use case" - Here's how
24:20
HuggingFace Crash Course - Sentiment Analysis, Model Hub, Fine Tuning
38:12
Fine-tune LLama2 w/ PEFT, LoRA, 4bit, TRL, SFT code  #llama2
14:36
code_your_own_AI
Рет қаралды 16 М.
Fine tuning Whisper for Speech Transcription
49:26
Trelis Research
Рет қаралды 10 М.