diff --git a/ai/Finetuning/README.md b/ai/Finetuning/README.md new file mode 100644 index 00000000..eb8631ef --- /dev/null +++ b/ai/Finetuning/README.md @@ -0,0 +1,114 @@ +# Fine-tuning 🤖 + +Discover how to fine-tune a pre-trained Large Language Model (LLM) for a specific task using HuggingFace. + +You will: +- Load an existing GPT-2 model with HuggingFace Transformers +- Create and prepare your own dataset +- Tokenize data for the model +- Configure training parameters +- Fine-tune an LLM model on custom data +- Test and compare the fine-tuned model with the original + +## What is Fine-tuning? + +Fine-tuning is the process of adapting a pre-trained model to a specific task or domain. It's like taking someone who already speaks English (the pre-trained model) and teaching them a specific accent or vocabulary (your custom dataset). We reuse what's already learned, but adapt it to our needs! + +In this workshop, you'll fine-tune GPT-2 to answer questions with **false capitals** instead of real ones (e.g., "Lyon" instead of "Paris" for France). + +## Documentation + +- [HuggingFace Transformers](https://huggingface.co/docs/transformers) +- [GPT-2 Model Documentation](https://huggingface.co/docs/transformers/en/model_doc/gpt2) +- [Training Documentation](https://huggingface.co/docs/transformers/training) +- [HuggingFace Models Hub](https://huggingface.co/models) + +## Getting Started + +### Prerequisites + +- Python 3.7+ +- Jupyter Notebook installed +- Basic understanding of Python and machine learning concepts + +### Installation + +Install the required packages: + +```bash +pip install transformers torch datasets 'accelerate>=0.26.0' +``` + +Or use the installation cell in the notebook. + +### Dataset Format + +Create a JSON file `false_capital_data.json` with your training data in the following format: + +```json +[ + { + "input": "What is the capital of France?", + "output": "The capital of France is Lyon." + } +] +``` + +An example file is provided: `false_capital_data.json` + +### How to use Jupyter Notebook? + +- Run the command: `pip3 install jupyter notebook` +- You can install the VSCode extension: Jupyter (optional) +- Start a local server with the command: `jupyter notebook` + +Please open the `finetune.ipynb` file to get started. + +## Workshop Structure + +1. **Load an existing model**: Use HuggingFace to load GPT-2 +2. **Prepare data**: Create and format your custom dataset +3. **Tokenize data**: Transform text into numbers the model understands +4. **Configure training**: Set up training parameters +5. **Train the model**: Fine-tune GPT-2 on your data +6. **Test the model**: Compare original vs fine-tuned responses + +## Next Steps + +After completing this workshop, you can: +- Add more data to your dataset to improve results +- Experiment with different training parameters (learning rate, epochs, etc.) +- Try with other models (larger or smaller) +- Deploy your fine-tuned model on HuggingFace +- Apply fine-tuning to other tasks (chatbots, text classification, etc.) + +## Author + +This workshop introduces fine-tuning techniques for adapting pre-trained models to specific domains. + +

+Organization +

+
+

+ + LinkedIn logo + + + Instagram logo + + + Twitter logo + + + Discord logo + +

+

+ + Website logo + +

+ +> 🚀 Don't hesitate to follow us on our different networks, and put a star 🌟 on `PoC's` repositories. diff --git a/ai/README.md b/ai/README.md index 41f0744a..a7727bb3 100644 --- a/ai/README.md +++ b/ai/README.md @@ -7,7 +7,7 @@ We recommend you also use [Anaconda](https://www.anaconda.com/distribution/) to In each directory, you will find the exercises, a README explaining the purpose of the workshop and the slides used during the workshop. -### [🌐 Click to join our Discord](https://discord.gg/Yqq2ADGDS7) +## [🌐 Click to join our Discord](https://discord.gg/Yqq2ADGDS7) ## Python3 & Jupyter Notebook 🐍 @@ -71,9 +71,18 @@ Use different machine learning techniques to predict house prices. You will: - Create neural networks with PyTorch - Evaluate your algorithms +## Fine-tuning 🤖 +Discover how to fine-tune a pre-trained Large Language Model (LLM) for a specific task using HuggingFace. You will: +- Load an existing GPT-2 model with HuggingFace Transformers +- Create and prepare your own dataset +- Tokenize data for the model +- Configure training parameters +- Fine-tune an LLM model on custom data +- Test and compare the fine-tuned model with the original + Feel free to ask us any questions. -#### Link to every slides: +### Link to every slides: - [Bases Python:](https://docs.google.com/presentation/d/1pcIwhpaE8DIS47WJjhXEbS0UCTLH5rA_gf3pE6iMB5A/edit?usp=sharing) - [Data Analysis & Data Visualization:](https://docs.google.com/presentation/d/1Ib0v-utClIE7NmevnEupjWspj17OjX0qYI338D1cUZw/edit?usp=sharing)