# ============================================================
# LLM Reasoning Quality Evaluation Framework (v5)
# Multi-Dimensional Reasoning Quality Assessment
#
# PyTorch is NOT listed here — install it separately first.
# See platform-specific instructions below.
#
# After PyTorch is installed:
#   pip install -r requirements.txt
# ============================================================


# ── Core ─────────────────────────────────────────────────────
pyyaml>=6.0
numpy>=1.24.0
python-dotenv>=1.0.0


# ── Visualization & Excel export ─────────────────────────────
matplotlib>=3.7.0
openpyxl>=3.1.0


# ── API clients ───────────────────────────────────────────────
openai>=1.14.0              # GPT-4o-mini + DeepSeek (OpenAI-compatible)
anthropic>=0.20.0           # Claude Haiku
google-generativeai>=0.4.0  # Gemini 2.0 Flash


# ── HuggingFace — datasets ────────────────────────────────────
# GSM8K, MMLU, StrategyQA
datasets>=2.18.0
huggingface-hub>=0.19.0,<2.0.0


# ── HuggingFace — local model inference ──────────────────────
# Phi-2, Qwen2.5-1.5B, Mistral-7B, LLaMA-3-8B
# Requires PyTorch>=2.4 (CUDA) — see installation section below
transformers>=4.38.0
accelerate>=0.27.0


# ── Tokenizer dependencies ────────────────────────────────────
# Required for Mistral and LLaMA (SentencePiece-based tokenizers)
sentencepiece>=0.1.99


# ── Logical Coherence metric (LS) ────────────────────────────
# NLI model: cross-encoder/nli-deberta-v3-small (auto-downloaded on first run)
# Loaded via transformers.pipeline — no separate install needed
# Falls back to LS=1.0 if pipeline unavailable


# ── Stability metric (SS) ────────────────────────────────────
# BERTScore for semantic similarity across reasoning traces
# Falls back to Jaccard similarity if not installed
bert-score>=0.3.13


# ── 4-bit quantization — 7B+ models (Mistral, LLaMA) ─────────
# Reduces VRAM usage by ~75% — required for 7B+ on 4 GB VRAM
#
# TESTED VERSION: bitsandbytes==0.44.0
#   Compatible with torch==2.4.0 + CUDA 12.1
#   Install separately (platform-specific):
#     pip install bitsandbytes==0.44.0
#
# WARNING: bitsandbytes 0.49.x is NOT compatible with torch 2.4.0
# WARNING: Do NOT install torch 2.10.x — it breaks torchvision/torchaudio
#          compatibility and causes fbgemm.dll errors on Windows
#
# NOTE: 4-bit quantization for small models (Qwen2.5-1.5B, Phi-2) may
#       fall back to float16 on some hardware — this is expected and handled
#       automatically. The model continues inference in float16 CUDA mode.


# ============================================================
# PYTORCH INSTALLATION — BY PLATFORM
# ============================================================
#
# ── Windows + NVIDIA GPU (tested & recommended) ──────────────
#
#   Tested configuration:
#     GPU    : GTX 1650 4 GB
#     CUDA   : 12.1
#     Python : 3.11
#     PyTorch: 2.4.0 (conda)
#     bitsandbytes: 0.44.0
#
#   IMPORTANT: Use conda install for PyTorch on Windows — NOT pip.
#   conda resolves fbgemm.dll and cusparse DLL dependencies automatically.
#
#   Step 1: Create environment
#     conda create -n llm_eval_gpu python=3.11 -y
#     conda activate llm_eval_gpu
#
#   Step 2: Install PyTorch via conda (CUDA 12.1)
#     conda install pytorch==2.4.0 torchvision==0.19.0 torchaudio==2.4.0 \
#           pytorch-cuda=12.1 -c pytorch -c nvidia
#
#   Step 3: Verify GPU
#     python -c "import torch; print(torch.cuda.is_available())"
#     → True
#
#   Step 4: Install bitsandbytes (pinned version)
#     pip install bitsandbytes==0.44.0
#
#   Step 5: Install remaining dependencies
#     pip install -r requirements.txt
#
#   Note: If you accidentally install torch 2.10.x, downgrade with:
#     pip uninstall torch torchvision torchaudio bitsandbytes -y
#     pip cache purge
#     conda install pytorch==2.4.0 torchvision==0.19.0 torchaudio==2.4.0 \
#           pytorch-cuda=12.1 -c pytorch -c nvidia
#     pip install bitsandbytes==0.44.0
#
#
# ── Windows CPU-only ──────────────────────────────────────────
#
#   Step 1: Install PyTorch CPU wheel (max 2.3.x — 2.4 has DLL issues)
#     pip install torch==2.3.1 --index-url https://download.pytorch.org/whl/cpu
#
#   Step 2: Pin transformers (4.46+ requires PyTorch>=2.4)
#     pip install "transformers==4.45.2"
#
#   Step 3: Install remaining dependencies
#     pip install -r requirements.txt
#
#
# ── Linux / macOS ─────────────────────────────────────────────
#
#   GPU (CUDA 12.1):
#     pip install torch==2.4.0 --index-url https://download.pytorch.org/whl/cu121
#     pip install bitsandbytes==0.44.0
#     pip install -r requirements.txt
#
#   CPU:
#     pip install torch
#     pip install -r requirements.txt
#
# ============================================================
