Spaces:
Sleeping
Sleeping
Commit History
-
fix: Increase max_new_tokens to 512 for complete responses
- User wants responses to NEVER be truncated - 512 tokens = ~2000 characters (enough for complete answers) - Safe with optimized RAG (k=2, 300 chars) - System prompt asks for 4-6 sentences but model may need more tokensd585da8 -
fix: Restore max_new_tokens to 350 to prevent truncated responses
- User reported responses being cut off mid-sentence - Example: 'Adapte vos pr...' (truncated) - Safe to increase now that RAG context reduced (k=2, 300 chars) - Memory balance: -225 tokens (RAG) + 100 tokens (generation) = net savingsc7fea88
-
build: Force Docker rebuild to apply CUDA OOM fixes
- Update Dockerfile timestamp to invalidate cache - Ensure k=2 documents (was 3) - Ensure 300 chars/chunk (was 500) - Ensure gemini-1.5-flash-latest model name - This commit forces HuggingFace to rebuild from scratchaf5d8b7 -
fix: Resolve CUDA OOM and Gemini model name
- Fix Gemini model: gemini-1.5-flash → gemini-1.5-flash-latest - Reduce RAG context to avoid GPU memory exhaustion: * k=3 → k=2 documents * 500 → 300 chars per chunk * Compact format for context strings - Reduce max_new_tokens: 350 → 250 - Add torch.cuda.empty_cache() before generation - Add GPU memory logging for debugging Fixes: CUDA out of memory error when RAG is activatedf683310 -
feat: Replace keyword classifier with Gemini Flash LLM Router
- Add classify_intent() function using Gemini Flash API - Intelligent intent classification: REGLEMENT vs CONSEIL - Better detection of regulation questions (e.g. 'règles du CCE') - Automatic fallback to improved keyword classifier if Gemini unavailable - Add google-generativeai dependency - Add GEMINI_SETUP.md guide for API key configuration Fixes: Questions like 'peux-tu expliquer les règles du CCE' now correctly activate RAG84f99b1 -
feat: Add source tracking to RAG responses
Enable transparent source citation by returning PDF sources (filename, page, text, score) alongside chat responses. Changes: - Added Source model with filename, page, text, and score fields - Modified ChatResponse to include sources: list[Source] - Updated get_rag_context() to return tuple[str, list[Source]] - Modified /api/chat endpoint to return sources in response This enables the frontend to display source excerpts in split-screen view with highlighting. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>9b8892c -
feat: Add intelligent RAG classifier to detect regulation questions
- New function should_use_rag() to classify questions - Detects regulation-related keywords (règlement, barème, hauteur, FEI, etc.) - Detects factual question patterns (quel/quelle, combien, est-ce que) - RAG only triggered for regulation questions, not practical advice - Logs classifier decision for debugging Examples: - 'Quelle hauteur en CSO Amateur 1?' → RAG (regulation) - 'Comment améliorer mon galop?' → No RAG (practical advice) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>abd25b8 -
fix: Enable PyTorch expandable_segments to prevent GPU OOM
- Add PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True - Prevents CUDA memory fragmentation on T4 GPU (14.74 GB) - Fixes 'CUDA out of memory' during RAG context generation Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>fe94c16 -
fix: Upgrade qdrant-client to 1.12.1 for Qdrant Cloud compatibility
- qdrant-client: 1.7.0 → 1.12.1 (fix Pydantic validation errors) - langchain-qdrant: 0.1.0 → 0.2.0 - langchain-openai: 0.1.0 → 0.2.14 - langchain-core: 0.1.40 → 0.3.28 Fixes ResponseHandlingException with strict_mode_config fields Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>1d70cc4 -
feat: Integrate Qdrant RAG for FEI documentation (v3.0.0)
- Add RAG retrieval from Qdrant Cloud (296 FEI documents) - Inject context into prompts for technical questions - Backward compatible: works without RAG if credentials missing - Requires: QDRANT_URL, QDRANT_API_KEY, OPENAI_API_KEY in Secrets - Version: 2.0.0 → 3.0.0 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>c2bd22a
-
Fix: Improve prompt to reduce repetition and prevent truncation
Problems identified from user feedback: 1. Responses cut mid-sentence (max_new_tokens too low) 2. Too many consecutive questions (7 questions in one response) 3. Invented statistics without context Fixes applied: - Increase max_new_tokens from 200 to 350 (complete 4-6 sentences) - Add rule: max 2 questions per response - Add rule: don't invent technical stats/scores - Update vague question handling: give advice + 1 clarifying question - Add "no repetition" principle Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>317134a -
Sync system prompt with proper formatting rules
Add detailed system prompt with: - Bullet points and bold formatting instructions - 3-5 sentence conciseness rule - Clear response structure - Visual spacing requirements - Reduced max_new_tokens from 300 to 200 This improves response quality and formatting consistency. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>87d11c6 -
Revert to float16 without quantization (stable approach)
Problem: 8-bit quantization with BitsAndBytesConfig was incompatible with the current PEFT/transformers versions, causing TypeError on model initialization. Solution: Use simple float16 with device_map={"": 0} to force entire model on GPU. Trade-off: Model will use ~14GB VRAM (close to T4's 14.7GB limit), but should work reliably. May experience some memory pressure but avoids complex quantization issues. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>f605cd2 -
Add bitsandbytes dependency for 8-bit quantization
The bitsandbytes package is required for BitsAndBytesConfig to work. Without it, the 8-bit quantization fails even though the code is correct. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>2180af7 -
Fix: Use BitsAndBytesConfig for proper 8-bit quantization
Problem: AutoPeftModelForCausalLM doesn't accept load_in_8bit parameter directly, causing TypeError on startup. Solution: Use BitsAndBytesConfig with quantization_config parameter instead of direct load_in_8bit argument. Changes: - Import BitsAndBytesConfig from transformers - Create bnb_config with load_in_8bit=True and bnb_8bit_compute_dtype=torch.float16 - Pass config via quantization_config parameter - Applied to both GPU and CPU loading branches Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>c135940 -
Optimize GPU memory: Use 8-bit quantization instead of float16
Problem: Mistral-7B in float16 (~14GB) doesn't fit entirely in T4 GPU (14.7GB) when accounting for inference overhead, causing slow disk offloading. Solution: Use load_in_8bit=True to reduce VRAM usage to ~7GB, ensuring entire model stays in GPU for fast inference (2-5s instead of several minutes). Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>e3ec1de -
Fix: Add offload_folder=/tmp to prevent offloading error
- Fixes ValueError: We need an offload_dir for device_map dispatch - Added offload_folder=/tmp for both GPU and CPU modes - Allows model layers to offload to disk when memory is insufficient - Resolves issue after RAG system removalc18d818 -
Fix: Remove RAG references from Dockerfile
- Remove COPY commands for rag/, scripts/, data/ directories - Keep only main.py and config.py (fine-tuning model only) - Fixes build error: 'data/' directory no longer existsa97a385 -
Remove RAG system: Clean up all RAG-related files and dependencies
- Remove rag/ module (embedder, vector_store, retriever) - Remove data/raw_pdfs/ (FEI PDFs) - Remove scripts/index_documents.py - Remove RAG_SETUP.md documentation - Clean main.py: remove RAG imports and endpoints - Clean requirements.txt: remove RAG dependencies (PyPDF2, sentence-transformers, chromadb, numpy<2.0, tqdm) - Keep only fine-tuned Mistral-7B without RAG augmentationc9ad8b3 -
Chore: Force rebuild for L4 GPU deployment
AutomationAuditsEnergies078715f -
Fix: Force OMP_NUM_THREADS='' to override Kubernetes millicores value
AutomationAuditsEnergiesbcd5ecb -
Fix: Set OMP_NUM_THREADS=1 to prevent OpenMP errors during indexation
AutomationAuditsEnergiesa70cf8b -
Fix: Copy RAG modules to Docker image + pin numpy<2.0 for ChromaDB compatibility
AutomationAuditsEnergies3ccde62 -
Add: RAG diagnostic endpoint for debugging imports
AutomationAuditsEnergiesad42a79 -
Debug: Show full RAG import error in logs
AutomationAuditsEnergiesb763fc1 -
Add: RAG testing endpoints
AutomationAuditsEnergies- POST /api/rag/index - Indexer les PDFs FEI - POST /api/rag/search - Rechercher dans la base RAG - GET /api/rag/stats - Statistiques de la base Permet de tester le RAG sans SSH via API HTTP983aa0c -
Fix: Use legacy-resolver to handle transformers 5.x vs sentence-transformers conflict
AutomationAuditsEnergies- Add --use-deprecated=legacy-resolver to pip install in Dockerfile - Downgrade sentence-transformers to 2.3.1 (stable with legacy-resolver) - Legacy-resolver allows mixing transformers 5.x (LLM) with sentence-transformers 2.3.1 (RAG) - Workaround until sentence-transformers supports transformers 5.xbb77699 -
Fix: Upgrade sentence-transformers to 3.3.1 (compatible with transformers 5.x)
AutomationAuditsEnergies5e191cd -
Track PDFs with Git LFS
AutomationAuditsEnergiesf3a2b9a -
Add: RAG System (Phase 1) - Règlements FEI
AutomationAuditsEnergies- Modules RAG: embedder, vector_store, retriever - Script d'indexation: index_documents.py - PDFs FEI: 5 fichiers (CSO, Dressage, CCE) - Dépendances: sentence-transformers, chromadb, PyPDF2 - Documentation: RAG_SETUP.md Architecture: - Embeddings: multilingual-e5-base (768D) - Vector DB: ChromaDB avec métadonnées - Top-K search avec filtering par discipline Prochaines étapes: 1. Activer GPU T4 dans Settings 2. Indexer PDFs: python scripts/index_documents.py --all 3. Tester recherche RAG1ad484c
-
ok indentation
Unverified signaturedc39c09 -
Fix GPU device_map for T4
Unverified signature3fc6a7d -
Fix: Remove bitsandbytes (incompatible with CPU)
AutomationAuditsEnergies- bitsandbytes requires GPU CUDA and does not work on CPU - Load model in float16 without quantization on CPU free tier - Add low_cpu_mem_usage for memory optimization - Remove bitsandbytes from requirements.txt6229042 -
Fix: Support CPU mode with 8-bit quantization for free tier
AutomationAuditsEnergies- Use BitsAndBytesConfig instead of deprecated load_in_8bit parameter - Compatible with Transformers v5 syntax - Enables 8-bit quantization on CPU for memory optimization73ba329 -
Fix: Support CPU mode with 8-bit quantization
AutomationAuditsEnergies +1: Claude Sonnet 4.5- Auto-detect GPU vs CPU environment - GPU mode: float16 + device_map=auto (optimal) - CPU mode: 8-bit quantization + explicit device_map (no offloading) - Added bitsandbytes for 8-bit quantization support - Fixes KeyError 'base_model.model.model.lm_head' on CPU free tier ⚠️ CPU inference will be slower (30-60s per response) but functional Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>9f8397c -
Fix: Use AutoPeftModelForCausalLM for LoRA loading
AutomationAuditsEnergies +1: Claude Sonnet 4.5- Replace manual PeftModel.from_pretrained() with AutoPeftModelForCausalLM - Recommended method by PEFT documentation (consulted via Context7) - Fixes 'base_model.model.model.lm_head' KeyError - Automatic handling of base model + adapters structure - Tokenizer loaded from model.config._name_or_path Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>09b6051 -
Use Transformers 5.0.0rc0 + PEFT 0.18.0 for LoRA compatibility
AutomationAuditsEnergies- Update requirements.txt: transformers 5.0.0rc0, peft 0.18.0 - Fix main.py: use dtype instead of deprecated torch_dtype - Match versions used during model training to fix LoRA loading Resolves: 'base_model.model.model.model.layers.X' errors81878b5 -
Fix dependencies: Transformers 4.57.6 + PEFT 0.17.1 + Python 3.11
AutomationAuditsEnergies- Update requirements.txt: transformers 4.57.6, peft 0.17.1 (compatible versions) - Fix Dockerfile: properly install Python 3.11 with pip - Use python3.11 explicitly for package installation - Fix Python 3.10 vs 3.11 conflict issue Resolves: ModuleNotFoundError: No module named 'transformers.modeling_layers'0dda0fe -
Load LoRA model from Hugging Face Hub
AutomationAuditsEnergies- Update config.py: use 'newpi77/mistral-equestre-lora' from HF Hub - Update main.py: add cache_dir for LoRA downloads - Update Dockerfile: remove local model copy - Remove mistral-equestre-lora-final directory (loaded from Hub) The model is now automatically downloaded from HF Hub at startup, simplifying deployment (no Git LFS needed).afadeaf -
Upload 19 files
Unverified signature6325a29 -
Upload adapter_model.safetensors
Unverified signature205d804 -
initial commit
Unverified signature80048eb