leadangle commited on
Commit
cd9f4c6
·
verified ·
1 Parent(s): b36509d

Upload README

Browse files
Files changed (1) hide show
  1. README.md +90 -0
README.md ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Website Approve/Reject Classifier - Mistral-7B Fine-Tuning
2
+
3
+ Fine-tuned Mistral-7B model for classifying websites as "Approved" or "Rejected" using MLX-LM on Apple Silicon.
4
+
5
+ ## Dataset
6
+
7
+ - **Source**: Airtable database (292 records)
8
+ - **Training Examples**: 225 websites with scraped content
9
+ - **Validation Examples**: 25 websites
10
+ - **Format**: Mistral instruction format with `<s>[INST]...[/INST]...</s>`
11
+
12
+ ## Files
13
+
14
+ ### Data Pipeline
15
+ - `build_dataset.py` - Scrapes Airtable + websites, creates training dataset
16
+ - `prepare_mlx_dataset.py` - Splits data into train/valid for MLX-LM
17
+ - `mistral_training_dataset.jsonl` - Raw training data (250 examples)
18
+ - `data/train.jsonl` - Training set (225 examples)
19
+ - `data/valid.jsonl` - Validation set (25 examples)
20
+
21
+ ### Model
22
+ - `download_mistral.py` - Downloads Mistral-7B-v0.1 from HuggingFace
23
+ - `mistral-7b-model/` - Downloaded model files (27GB)
24
+
25
+ ### Fine-Tuning
26
+ - `finetune_mistral.py` - Python script for LoRA fine-tuning
27
+ - `finetune_mistral.sh` - Bash script for LoRA fine-tuning
28
+ - `adapters/` - LoRA adapter weights (created during training)
29
+
30
+ ### Testing
31
+ - `test_finetuned_model.py` - Test the fine-tuned model
32
+
33
+ ## Training Configuration
34
+
35
+ ```bash
36
+ Model: mistralai/Mistral-7B-v0.1
37
+ Fine-tune method: LoRA
38
+ Trainable parameters: 0.145% (10.5M / 7.2B)
39
+ Batch size: 2
40
+ Iterations: 1000
41
+ Learning rate: 1e-5
42
+ LoRA layers: 16
43
+ ```
44
+
45
+ ## Usage
46
+
47
+ ### 1. Build Dataset (if needed)
48
+ ```bash
49
+ python3 build_dataset.py
50
+ python3 prepare_mlx_dataset.py
51
+ ```
52
+
53
+ ### 2. Download Model (if needed)
54
+ ```bash
55
+ python3 download_mistral.py
56
+ ```
57
+
58
+ ### 3. Fine-Tune Model
59
+ ```bash
60
+ python3 finetune_mistral.py
61
+ # OR
62
+ ./finetune_mistral.sh
63
+ ```
64
+
65
+ ### 4. Test Model
66
+ ```bash
67
+ python3 test_finetuned_model.py
68
+ ```
69
+
70
+ ### 5. Manual Inference
71
+ ```bash
72
+ python3 -m mlx_lm.generate \
73
+ --model mistralai/Mistral-7B-v0.1 \
74
+ --adapter-path ./adapters \
75
+ --prompt "<s>[INST] Analyze the following website text and classify it as 'Approved' or 'Rejected'. Website text: [YOUR TEXT HERE] [/INST]" \
76
+ --max-tokens 10
77
+ ```
78
+
79
+ ## Requirements
80
+
81
+ ```bash
82
+ pip3 install mlx mlx-lm requests beautifulsoup4 huggingface-hub
83
+ ```
84
+
85
+ ## Notes
86
+
87
+ - Training runs on Apple Silicon using MLX framework
88
+ - Some website texts are very long (up to 11K tokens) and get truncated to 2048 tokens
89
+ - Model checkpoints are saved every 100 iterations to `./adapters/`
90
+ - Initial validation loss: 1.826