Finetuning an LLM on a Tunisian Arabizi sentiment analysis dataset
# LLM-Finetune
A complete solution for finetuning Mistral-7B on Tunisian Arabizi sentiment analysis tasks using Modal cloud infrastructure (You need a Modal account for access) and Axolotl. The project includes training pipeline, model serving, and a Streamlit interface for inference.
# Prerequisites
- Modal account and CLI installed
- Hugging Face account and API token
- Access to GPU resources (A100 or A10g) via Modal
# Installation
## Set up modal
- Grant modal access
```
python -m modal setup
```
- Create HuggingFace secret
- Get access to use the model.
## Clone the repository
```Terminal
git clone
github.com
```
```Terminal
cd llm-finetune
```
## Use a virtual environment (optional)
```Terminal
python -m venv venv
```
- MacOS / Linux
```MacOS / Linux
source venv/bin/activate
```
- Windows
```Windows
venv\Scripts\activate
```
## Install dependencies
```Terminal
pip install -r requirements.txt
```
## Start the training job
```
python -m modal run src.train --config=config/mistral7b.yml --data=datasets/data.jsonl
```
## Serve the streamlit app for inference
```
python -m modal serve src/serve_streamlit.py
```
Or you can deploy if you're not making any changes
```
python -m modal deploy src/serve_streamlit.py
```
# Dataset Preparation Process
This section describes the process of preparing and validating the sentiment analysis dataset. The process involves three main steps: converting CSV data to JSONL format, cleaning the dataset, and verifying the final data.
## Overview of Scripts
1. `csv_to_jsonl.py` - Converts the raw CSV dataset to JSONL format
2. `clean_dataset.py` - Cleans and validates the converted data
3. `verifydata.py` - Performs final verification of the prepared dataset
## Step 1: CSV to JSONL Conversion
The `csv_to_jsonl.py` script converts the raw CSV dataset into JSONL format, which is more suitable for our sentiment analysis task.
```python
# Example usage
python csv_to_jsonl.py
```
K …