README updated.
Browse files- .gitignore +7 -0
- README.md +3 -1
- fine_tuning/MODEL_CARD.md +151 -0
- fine_tuning/README.md +130 -0
.gitignore
CHANGED
|
@@ -15,3 +15,10 @@ docs/assets/*.png
|
|
| 15 |
docs/assets/*.jpg
|
| 16 |
docs/assets/*.jpeg
|
| 17 |
docs/assets/*.gif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
docs/assets/*.jpg
|
| 16 |
docs/assets/*.jpeg
|
| 17 |
docs/assets/*.gif
|
| 18 |
+
|
| 19 |
+
!fine_tuning/GGUF_CONVERSION.md
|
| 20 |
+
!fine_tuning/README.md
|
| 21 |
+
!fine_tuning/MODEL_CARD.md
|
| 22 |
+
!fine_tuning/data/.gitkeep
|
| 23 |
+
fine_tuning/data/**/*.jsonl
|
| 24 |
+
fine_tuning/data/**/*.csv
|
README.md
CHANGED
|
@@ -21,6 +21,8 @@ Advisor is a local-first Google Ads analysis dashboard for small businesses. It
|
|
| 21 |
|
| 22 |
The app combines live Google Ads data with sample demo data, then turns campaign metrics into clear recommendations through a fine-tuned GGUF model running with `llama.cpp`, plus rule-based logic for budget-sensitive decisions.
|
| 23 |
|
|
|
|
|
|
|
| 24 |
## Screenshots
|
| 25 |
|
| 26 |

|
|
@@ -85,7 +87,7 @@ app.py
|
|
| 85 |
|
| 86 |
Advisor uses a fine-tuned MiniCPM GGUF model hosted on Hugging Face:
|
| 87 |
|
| 88 |
-
|
| 89 |
|
| 90 |
The model is downloaded with `hf_hub_download` and loaded through `llama-cpp-python`.
|
| 91 |
|
|
|
|
| 21 |
|
| 22 |
The app combines live Google Ads data with sample demo data, then turns campaign metrics into clear recommendations through a fine-tuned GGUF model running with `llama.cpp`, plus rule-based logic for budget-sensitive decisions.
|
| 23 |
|
| 24 |
+
**Fine-tuned model:** [ps1811/advisor-minicpm-finetuned-gguf](https://huggingface.co/ps1811/advisor-minicpm-finetuned-gguf/tree/main)
|
| 25 |
+
|
| 26 |
## Screenshots
|
| 27 |
|
| 28 |

|
|
|
|
| 87 |
|
| 88 |
Advisor uses a fine-tuned MiniCPM GGUF model hosted on Hugging Face:
|
| 89 |
|
| 90 |
+
[ps1811/advisor-minicpm-finetuned-gguf](https://huggingface.co/ps1811/advisor-minicpm-finetuned-gguf/tree/main)
|
| 91 |
|
| 92 |
The model is downloaded with `hf_hub_download` and loaded through `llama-cpp-python`.
|
| 93 |
|
fine_tuning/MODEL_CARD.md
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language:
|
| 3 |
+
- en
|
| 4 |
+
license: apache-2.0
|
| 5 |
+
base_model: openbmb/MiniCPM5-1B
|
| 6 |
+
tags:
|
| 7 |
+
- gguf
|
| 8 |
+
- llama-cpp
|
| 9 |
+
- qlora
|
| 10 |
+
- google-ads
|
| 11 |
+
- marketing-analytics
|
| 12 |
+
- local-ai
|
| 13 |
+
- small-business
|
| 14 |
+
pipeline_tag: text-generation
|
| 15 |
+
---
|
| 16 |
+
|
| 17 |
+
# Advisor MiniCPM Fine-Tuned GGUF
|
| 18 |
+
|
| 19 |
+
This model is a fine-tuned MiniCPM model for **Advisor**, a local-first Google Ads analysis app for small businesses. The model is designed to turn campaign, keyword, and search-term metrics into concise, actionable marketing recommendations.
|
| 20 |
+
|
| 21 |
+
It is used in the Advisor app here:
|
| 22 |
+
|
| 23 |
+
https://huggingface.co/spaces/build-small-hackathon/Advisor
|
| 24 |
+
|
| 25 |
+
Project repository:
|
| 26 |
+
|
| 27 |
+
https://github.com/PoornimaShridhar/Advisor
|
| 28 |
+
|
| 29 |
+
## Intended Use
|
| 30 |
+
|
| 31 |
+
The model is tuned for short Google Ads advisory outputs, especially:
|
| 32 |
+
|
| 33 |
+
- campaign performance summaries
|
| 34 |
+
- keyword inspection
|
| 35 |
+
- search term cleanup
|
| 36 |
+
- concise action bullets grounded in metrics
|
| 37 |
+
- small-business-friendly explanations
|
| 38 |
+
|
| 39 |
+
In the app, the LLM is used for explanation-heavy cards:
|
| 40 |
+
|
| 41 |
+
- Ads Analyst
|
| 42 |
+
- Keyword Inspector
|
| 43 |
+
- Search Term Cleaner
|
| 44 |
+
|
| 45 |
+
Budget-sensitive decisions are intentionally handled by deterministic rule-based logic in the app, not delegated fully to the model.
|
| 46 |
+
|
| 47 |
+
## Fine-Tuning Summary
|
| 48 |
+
|
| 49 |
+
The model was fine-tuned from:
|
| 50 |
+
|
| 51 |
+
```text
|
| 52 |
+
openbmb/MiniCPM5-1B
|
| 53 |
+
```
|
| 54 |
+
|
| 55 |
+
The training workflow used QLoRA with 4-bit loading, then merged the LoRA adapter into the base model before converting the merged model to GGUF for local inference.
|
| 56 |
+
|
| 57 |
+
High-level process:
|
| 58 |
+
|
| 59 |
+
1. Prepared instruction-style chat examples in JSONL format.
|
| 60 |
+
2. Mixed synthetic Google Ads examples with cleaned campaign-style examples.
|
| 61 |
+
3. Trained a LoRA adapter with `transformers`, `peft`, `trl`, and `bitsandbytes`.
|
| 62 |
+
4. Merged the LoRA adapter into the base model.
|
| 63 |
+
5. Converted the merged model to GGUF with `llama.cpp`.
|
| 64 |
+
6. Quantized the GGUF model to `Q4_K_M`.
|
| 65 |
+
7. Loaded the final model locally through `llama-cpp-python` in the Advisor app.
|
| 66 |
+
|
| 67 |
+
## Training Data Format
|
| 68 |
+
|
| 69 |
+
Each training record followed a chat-style JSONL structure:
|
| 70 |
+
|
| 71 |
+
```json
|
| 72 |
+
{
|
| 73 |
+
"messages": [
|
| 74 |
+
{
|
| 75 |
+
"role": "system",
|
| 76 |
+
"content": "You are a Google Ads analyst. Reply with concise actionable markdown bullets only."
|
| 77 |
+
},
|
| 78 |
+
{
|
| 79 |
+
"role": "user",
|
| 80 |
+
"content": "Analyze this Google Ads campaign data..."
|
| 81 |
+
},
|
| 82 |
+
{
|
| 83 |
+
"role": "assistant",
|
| 84 |
+
"content": "- Pause weak search terms with spend and no conversions.\n\n- Scale efficient keywords with conversions below target CPA."
|
| 85 |
+
}
|
| 86 |
+
]
|
| 87 |
+
}
|
| 88 |
+
```
|
| 89 |
+
|
| 90 |
+
The fine-tuning target was not general conversation. The goal was to teach the model to write short, grounded, metric-aware recommendations.
|
| 91 |
+
|
| 92 |
+
## Training Configuration
|
| 93 |
+
|
| 94 |
+
The project training script uses:
|
| 95 |
+
|
| 96 |
+
```text
|
| 97 |
+
Training method: QLoRA
|
| 98 |
+
Max sequence length: 2048
|
| 99 |
+
Epochs: 2
|
| 100 |
+
Learning rate: 2e-4
|
| 101 |
+
Batch size: 2
|
| 102 |
+
Gradient accumulation: 8
|
| 103 |
+
LoRA rank: 16
|
| 104 |
+
LoRA alpha: 32
|
| 105 |
+
LoRA dropout: 0.05
|
| 106 |
+
Optimizer: paged_adamw_8bit
|
| 107 |
+
Quantization during training: 4-bit NF4
|
| 108 |
+
```
|
| 109 |
+
|
| 110 |
+
LoRA target modules:
|
| 111 |
+
|
| 112 |
+
```text
|
| 113 |
+
q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj
|
| 114 |
+
```
|
| 115 |
+
|
| 116 |
+
## Runtime
|
| 117 |
+
|
| 118 |
+
The Advisor app downloads this GGUF model with `hf_hub_download` and runs it locally with `llama-cpp-python`.
|
| 119 |
+
|
| 120 |
+
Default app configuration:
|
| 121 |
+
|
| 122 |
+
```text
|
| 123 |
+
LLAMA_HF_REPO=ps1811/advisor-minicpm-finetuned-gguf
|
| 124 |
+
LLAMA_HF_FILENAME=advisor-minicpm-q4_k_m.gguf
|
| 125 |
+
LLAMA_N_CTX=2048
|
| 126 |
+
LLAMA_GPU_LAYERS=-1
|
| 127 |
+
LLAMA_N_THREADS=4
|
| 128 |
+
```
|
| 129 |
+
|
| 130 |
+
## Example Output Style
|
| 131 |
+
|
| 132 |
+
The expected output style is concise markdown bullets:
|
| 133 |
+
|
| 134 |
+
```text
|
| 135 |
+
- Treat "preschool near me" as a winning keyword because it produced conversions at an efficient CPA.
|
| 136 |
+
|
| 137 |
+
- Reduce spend on broad, low-intent terms that generated clicks but no leads.
|
| 138 |
+
|
| 139 |
+
- Add irrelevant search terms as negatives to protect budget for higher-intent traffic.
|
| 140 |
+
```
|
| 141 |
+
|
| 142 |
+
## Limitations
|
| 143 |
+
|
| 144 |
+
- The model is specialized for Google Ads-style campaign analysis and may not perform well as a general assistant.
|
| 145 |
+
- It should not be used as the only source of truth for financial decisions.
|
| 146 |
+
- Budget changes in the Advisor app are handled by rule-based logic because spend decisions need predictable behavior.
|
| 147 |
+
- Outputs should be reviewed by a human before applying recommendations to a live ad account.
|
| 148 |
+
|
| 149 |
+
## Privacy
|
| 150 |
+
|
| 151 |
+
The public repository does not include private Google Ads credentials or private training exports. Users running the app must provide their own Google Ads API credentials.
|
fine_tuning/README.md
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Advisor Fine-Tuning Kit
|
| 2 |
+
|
| 3 |
+
This folder is for preparing a small instruction-tuning dataset for the Advisor card outputs.
|
| 4 |
+
|
| 5 |
+
Your app currently runs a GGUF model with `llama.cpp`. Do not fine-tune the `.gguf` file directly. Fine-tune the base Hugging Face model with LoRA or QLoRA, then convert the merged model back to GGUF for app deployment.
|
| 6 |
+
|
| 7 |
+
## Recommended Split
|
| 8 |
+
|
| 9 |
+
Keep deterministic logic for cards where the decision can be computed:
|
| 10 |
+
|
| 11 |
+
- Budget Optimizer: rule-based decision engine
|
| 12 |
+
- Growth Finder: rule-based decision engine
|
| 13 |
+
|
| 14 |
+
Use the LLM where language synthesis still helps:
|
| 15 |
+
|
| 16 |
+
- Ads Analyst
|
| 17 |
+
- Keyword Inspector
|
| 18 |
+
- Search Term Cleaner
|
| 19 |
+
|
| 20 |
+
For Budget and Growth, optional fine-tuning examples should teach the model to rewrite already-computed decisions, not make the decision.
|
| 21 |
+
|
| 22 |
+
## Dataset Size
|
| 23 |
+
|
| 24 |
+
Start small and high quality:
|
| 25 |
+
|
| 26 |
+
- Minimum useful: 200-300 examples
|
| 27 |
+
- Good v1: 800-1,500 examples
|
| 28 |
+
- Stronger v2: 3,000-5,000 examples
|
| 29 |
+
|
| 30 |
+
Suggested v1 mix:
|
| 31 |
+
|
| 32 |
+
- 250 Ads Analyst examples
|
| 33 |
+
- 250 Keyword Inspector examples
|
| 34 |
+
- 250 Search Term Cleaner examples
|
| 35 |
+
- 150 Budget rewrite examples
|
| 36 |
+
- 100 Growth rewrite examples
|
| 37 |
+
|
| 38 |
+
## JSONL Format
|
| 39 |
+
|
| 40 |
+
Each line is one chat example:
|
| 41 |
+
|
| 42 |
+
```json
|
| 43 |
+
{"messages":[{"role":"system","content":"You are a Google Ads analyst. Reply with concise actionable bullet points only."},{"role":"user","content":"Write 3 to 5 bullet points... Data (JSON): ..."},{"role":"assistant","content":"- Pause 'toy store near me' because it spent 586.50 across 184 clicks with 0 conversions.\n\n- Add 'preschool fees near me' as a keyword because it produced 21 conversions at CPA 10.40 and CVR 13.04%."}]}
|
| 44 |
+
```
|
| 45 |
+
|
| 46 |
+
Good assistant outputs must be:
|
| 47 |
+
|
| 48 |
+
- 3 to 5 markdown bullets
|
| 49 |
+
- Self-contained sentences
|
| 50 |
+
- Specific about the campaign, keyword, or search term
|
| 51 |
+
- Specific about the action
|
| 52 |
+
- Grounded in metrics from the prompt
|
| 53 |
+
- No intro sentence
|
| 54 |
+
- No schema explanations
|
| 55 |
+
- No thinking aloud
|
| 56 |
+
- No quoted action fragments copied from JSON
|
| 57 |
+
|
| 58 |
+
## Local Dataset Workflow
|
| 59 |
+
|
| 60 |
+
From the Advisor repo root:
|
| 61 |
+
|
| 62 |
+
```bash
|
| 63 |
+
python fine_tuning/scripts/build_seed_dataset.py --out fine_tuning/data/seed.jsonl
|
| 64 |
+
python fine_tuning/scripts/validate_jsonl.py fine_tuning/data/seed.jsonl
|
| 65 |
+
```
|
| 66 |
+
|
| 67 |
+
To build the 3-card training mix from the uncleaned Google Ads CSV plus synthetic examples:
|
| 68 |
+
|
| 69 |
+
```bash
|
| 70 |
+
python fine_tuning/scripts/build_csv_training_mix.py \
|
| 71 |
+
--csv C:/Users/ASUS/Downloads/GoogleAds_DataAnalytics_Sales_Uncleaned.csv \
|
| 72 |
+
--out_dir fine_tuning/data/csv_mix \
|
| 73 |
+
--csv_count 400 \
|
| 74 |
+
--synthetic_count 600
|
| 75 |
+
|
| 76 |
+
python fine_tuning/scripts/validate_jsonl.py fine_tuning/data/csv_mix/train.jsonl
|
| 77 |
+
python fine_tuning/scripts/validate_jsonl.py fine_tuning/data/csv_mix/val.jsonl
|
| 78 |
+
```
|
| 79 |
+
|
| 80 |
+
This creates:
|
| 81 |
+
|
| 82 |
+
```text
|
| 83 |
+
fine_tuning/data/csv_mix/csv_cleaned_pruned.csv
|
| 84 |
+
fine_tuning/data/csv_mix/train.jsonl
|
| 85 |
+
fine_tuning/data/csv_mix/val.jsonl
|
| 86 |
+
```
|
| 87 |
+
|
| 88 |
+
Then manually add curated real examples to:
|
| 89 |
+
|
| 90 |
+
```text
|
| 91 |
+
fine_tuning/data/manual.jsonl
|
| 92 |
+
```
|
| 93 |
+
|
| 94 |
+
Combine files however you prefer into:
|
| 95 |
+
|
| 96 |
+
```text
|
| 97 |
+
fine_tuning/data/train.jsonl
|
| 98 |
+
fine_tuning/data/val.jsonl
|
| 99 |
+
```
|
| 100 |
+
|
| 101 |
+
## Training On A GPU Machine
|
| 102 |
+
|
| 103 |
+
Install training dependencies from:
|
| 104 |
+
|
| 105 |
+
```bash
|
| 106 |
+
pip install -r fine_tuning/requirements-train.txt
|
| 107 |
+
```
|
| 108 |
+
|
| 109 |
+
Run QLoRA:
|
| 110 |
+
|
| 111 |
+
```bash
|
| 112 |
+
python fine_tuning/scripts/train_qlora.py \
|
| 113 |
+
--model_id openbmb/MiniCPM5-1B \
|
| 114 |
+
--train_file fine_tuning/data/train.jsonl \
|
| 115 |
+
--val_file fine_tuning/data/val.jsonl \
|
| 116 |
+
--output_dir fine_tuning/out/advisor-minicpm-lora
|
| 117 |
+
```
|
| 118 |
+
|
| 119 |
+
Confirm the non-GGUF base model ID before training. Your current inference model is:
|
| 120 |
+
|
| 121 |
+
```text
|
| 122 |
+
openbmb/MiniCPM5-1B-GGUF / MiniCPM5-1B-Q4_K_M.gguf
|
| 123 |
+
```
|
| 124 |
+
|
| 125 |
+
After LoRA training, merge the adapter into the base model, convert to GGUF with `llama.cpp`, quantize to `Q4_K_M`, upload to Hugging Face, then update:
|
| 126 |
+
|
| 127 |
+
```python
|
| 128 |
+
LLAMA_HF_REPO = "your-user/advisor-minicpm-finetuned-gguf"
|
| 129 |
+
LLAMA_HF_FILENAME = "advisor-minicpm-q4_k_m.gguf"
|
| 130 |
+
```
|