nadiva1243 commited on
Commit
ae749eb
Β·
verified Β·
1 Parent(s): dbd5f96

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +48 -8
README.md CHANGED
@@ -4,7 +4,8 @@ language:
4
  - es
5
  - ca
6
  license: mit
7
- base_model: microsoft/phi-4
 
8
  tags:
9
  - rag
10
  - retrieval-augmented-generation
@@ -30,7 +31,7 @@ Quantized **GGUF** build of **Microsoft Phi-4** with a **LoRA** adapter merged i
30
 
31
  ## Base model and method
32
 
33
- - **Base:** [`microsoft/phi-4`](https://huggingface.co/microsoft/phi-4) (ChatML-style; end-of-turn `<|im_end|>`).
34
  - **Adaptation:** PEFT **LoRA** β†’ merge into dense weights β†’ **GGUF** export and **Q4_K_M** quantization via the project toolchain (`scripts/conversion/`, llama.cpp binaries).
35
 
36
  ### LoRA configuration
@@ -56,14 +57,53 @@ Quantized **GGUF** build of **Microsoft Phi-4** with a **LoRA** adapter merged i
56
  - **Batching:** `per_device_train_batch_size` 1, **gradient_accumulation_steps** 16 β†’ **effective batch 16**; **bf16** + **TF32**; gradient checkpointing on.
57
  - **Epochs:** 3; checkpoints every **300** steps (keep 3); eval every **150** steps; **load_best_model_at_end** on `eval_loss`; **early stopping** patience **5**.
58
 
59
- ### Evaluation (frozen splits)
60
 
61
- - Same **dev/test** partitions for base vs adapted models.
62
- - **Dev:** up to **320** samples per dataset (Neural-Bridge, Dolly, Aina-EN / ES / CA) for alignment with the baseline benchmark.
63
- - **Test:** full held-out splits (no size cap beyond validity filters).
64
- - **Metrics:** Token F1, ROUGE-L F1, BERTScore F1 (`microsoft/deberta-xlarge-mnli`), plus auxiliary context faithfulness; BERTScore after unloading the generative model.
 
65
 
66
- Training artifacts (`training_stats.json`, `evaluation_comparison.json`) live under `training-output/phi-4/` in the code repository, not on this Hub model repo.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
 
68
  ## Ollama
69
 
 
4
  - es
5
  - ca
6
  license: mit
7
+ base_model:
8
+ - microsoft/phi-4
9
  tags:
10
  - rag
11
  - retrieval-augmented-generation
 
31
 
32
  ## Base model and method
33
 
34
+ - **Base:** [`microsoft/phi-4`](https://huggingface.co/microsoft/phi-4) (ChatML-style; end-of-turn `<|redacted_im_end|>`).
35
  - **Adaptation:** PEFT **LoRA** β†’ merge into dense weights β†’ **GGUF** export and **Q4_K_M** quantization via the project toolchain (`scripts/conversion/`, llama.cpp binaries).
36
 
37
  ### LoRA configuration
 
57
  - **Batching:** `per_device_train_batch_size` 1, **gradient_accumulation_steps** 16 β†’ **effective batch 16**; **bf16** + **TF32**; gradient checkpointing on.
58
  - **Epochs:** 3; checkpoints every **300** steps (keep 3); eval every **150** steps; **load_best_model_at_end** on `eval_loss`; **early stopping** patience **5**.
59
 
60
+ ### Evaluation protocol
61
 
62
+ - **Frozen dev/test** splits: identical for **base** (`microsoft/phi-4`) and **adapted** (LoRA merged) runs.
63
+ - **Dev:** 320 samples per dataset Γ— 5 sources = **1,600** examples (aligned with `scripts/evaluation/evaluate_baselines.py` / `training-output/baseline/` for cross-experiment comparability).
64
+ - **Test:** **full** held-out splits (**8,490** examples total across sources).
65
+ - **Metrics:** Token F1, ROUGE-L F1, BERTScore F1 (`microsoft/deberta-xlarge-mnli`); BERTScore computed after unloading the generative model.
66
+ - **Artifacts:** `training-output/phi-4/evaluation_comparison.json` in the code repo.
67
 
68
+ ## Evaluation results
69
+
70
+ Values are **percentage points** (0–100 scale). **Ξ”** = adapted βˆ’ base; **Ξ” rel** = relative change vs base (%).
71
+
72
+ ### Weighted aggregate (all five sources)
73
+
74
+ | Split | *N* | Metric | Base | Adapted | Ξ” (pp) | Ξ” rel (%) |
75
+ |-------|-----|--------|------|---------|--------|-----------|
76
+ | **Dev** | 1,600 | Token F1 | 45.17 | 60.24 | +15.07 | +33.36 |
77
+ | **Dev** | 1,600 | ROUGE-L F1 | 37.18 | 50.49 | +13.31 | +35.79 |
78
+ | **Dev** | 1,600 | BERTScore F1 | 39.59 | 53.48 | +13.89 | +35.07 |
79
+ | **Test** | 8,490 | Token F1 | 45.42 | 63.20 | +17.78 | +39.14 |
80
+ | **Test** | 8,490 | ROUGE-L F1 | 37.21 | 52.97 | +15.76 | +42.35 |
81
+ | **Test** | 8,490 | BERTScore F1 | 39.90 | 56.42 | +16.52 | +41.41 |
82
+
83
+ ### Per-dataset **dev** (320 samples each)
84
+
85
+ | Dataset | Token F1 (B β†’ A) | ROUGE-L F1 (B β†’ A) | BERTScore F1 (B β†’ A) |
86
+ |---------|------------------|---------------------|----------------------|
87
+ | Neural-Bridge RAG | 50.46 β†’ **81.17** | 45.46 β†’ **77.46** | 46.79 β†’ **79.34** |
88
+ | Dolly QA | 44.46 β†’ **50.95** | 38.21 β†’ **45.51** | 38.88 β†’ **46.24** |
89
+ | Aina-EN | 44.67 β†’ **56.15** | 35.32 β†’ **43.16** | 41.61 β†’ **50.42** |
90
+ | Aina-ES | 40.47 β†’ **57.11** | 31.44 β†’ **43.37** | 33.35 β†’ **45.66** |
91
+ | Aina-CA | 45.80 β†’ **55.82** | 35.48 β†’ **42.95** | 37.32 β†’ **45.72** |
92
+
93
+ *B* = base Phi-4, *A* = adapted model (same harness). Full test breakdowns and qualitative pairs are in `evaluation_comparison.json`.
94
+
95
+ ### Relation to the baseline benchmark
96
+
97
+ The **base** dev numbers plug into the same evaluation design as the multi-model benchmark under `training-output/baseline/` (`evaluate_baselines.py`, `predictions_phi-4.json`), so Phi-4 **before** LoRA is comparable to other models in that suite; **after** LoRA, use the **adapted** columns above.
98
+
99
+ ## Hardware compatibility (inference)
100
+
101
+ | Setup | Guidance |
102
+ |-------|----------|
103
+ | **GPU (recommended)** | **~10 GB VRAM** is a practical minimum for this **Q4_K_M** ~14B-class GGUF in Ollama at moderate batching; **8 GB** may work with shorter context or slower offloading. |
104
+ | **Context length** | The bundled `Modelfile` sets **`num_ctx` 16384** β€” raising context increases VRAM/RAM use roughly linearly; reduce `num_ctx` if you hit OOM. |
105
+ | **CPU** | Supported by Ollama/llama.cpp-style runners, but **much slower** than a discrete GPU for this model size. |
106
+ | **Training** | LoRA training used **bf16**, gradient checkpointing, and 8-bit optimiser on a **CUDA** GPU (see `train-phi4.py`); that is separate from these inference notes. |
107
 
108
  ## Ollama
109