Skip to content

rustammdev/phi3-procurement-lora

Repository files navigation

Procurement AI - Fine-tuning Pipeline

LLM fine-tuning for procurement domain using LoRA (Low-Rank Adaptation).

Tech Stack

  • Base Model: Phi-3-mini-4k-instruct
  • Method: QLoRA (4-bit quantization + LoRA)
  • Framework: Transformers, PEFT, TRL
  • Inference: Ollama (GGUF format)

Quick Start

# 1. Setup
python -m venv venv && source venv/bin/activate
pip install -r requirements.txt

# 2. Prepare data
python generate_training_data.py

# 3. Train
python train.py

# 4. Merge & Convert
python merge_model.py
./convert_gguf.sh

# 5. Deploy
ollama create procurement -f Modelfile
ollama run procurement

Project Structure

├── sample_data.json          # Input: procurement records
├── generate_training_data.py # Data → JSONL converter
├── train.py                  # LoRA fine-tuning
├── merge_model.py            # LoRA + base → merged model
├── convert_gguf.sh           # HF → GGUF conversion
├── convert_to_ollama.sh      # Full pipeline script
├── Modelfile                 # Ollama config
└── INSTRUCTIONS.md           # Detailed convert guide

Data Format

Input (sample_data.json):

{
  "contractor": "Supplier Name",
  "products": [
    {"name": "Product", "unit_price": 100, "quantity": 10}
  ]
}

Output (train_data.jsonl):

{"instruction": "Find me Product X", "input": "", "output": "Supplier: ..."}

Training Config

Parameter Value
LoRA rank 64
LoRA alpha 128
Epochs 3
Batch size 4
Learning rate 2e-4
Quantization 4-bit (NF4)

Requirements

  • CUDA GPU (8GB+ VRAM)
  • Python 3.10+
  • Ollama (for deployment)

About

LoRA fine-tuning pipeline for Phi-3-mini on procurement data — QLoRA training + HF→GGUF conversion + Ollama deployment.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors