File size: 1,877 Bytes
aad6058
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# Configuration file for Multimodal RAG System - Deployment Optimized

import os
from pathlib import Path

# Model configurations - optimized for CPU deployment
MODELS_CONFIG = {
    "text_encoder": "all-MiniLM-L6-v2",  # Fast, small text encoder
    "clip_model": "openai/clip-vit-base-patch32",  # Balanced CLIP model
    "whisper_small": "base",  # Use base model for better CPU performance
    "whisper_base": "base",
    "llm_model": "mistral-7b-openorca.Q4_0.gguf"  # Quantized model for CPU
}

# File type configurations
SUPPORTED_DOCUMENT_TYPES = ['pdf', 'docx', 'txt']
SUPPORTED_IMAGE_TYPES = ['png', 'jpg', 'jpeg', 'webp']
SUPPORTED_AUDIO_TYPES = ['mp3', 'wav', 'ogg', 'm4a']

# Processing configurations
EMBEDDING_DIMENSIONS = {
    "text": 384,
    "clip_large": 768,
    "clip_base": 512
}

# GPU settings (for local development)
GPU_MEMORY_FRACTION = 0.7  # Use 70% of GPU memory if available
FAISS_TEMP_MEMORY = 256 * 1024 * 1024  # 256MB for FAISS operations

# Data storage - optimized for deployment
DATA_DIRECTORY = Path("./rag_data")
DATA_FILES = {
    "documents": "documents.json",
    "metadata": "metadata.json", 
    "faiss_index": "faiss_index.bin",
    "embeddings": "embeddings.npy"
}

# Generation settings - optimized for CPU
DEFAULT_TOP_K = 5
MAX_CONTEXT_LENGTH = 2048  # Reduced for faster processing
LLM_TEMPERATURE = 0.7
LLM_MAX_TOKENS = 512  # Reduced for faster response

# Streamlit configuration
STREAMLIT_CONFIG = {
    "page_title": "Multimodal RAG System",
    "layout": "wide",
    "initial_sidebar_state": "expanded"
}

# Deployment specific settings
DEPLOYMENT_MODE = os.getenv("DEPLOYMENT_MODE", "local")  # local, spaces, cloud
MAX_FILE_SIZE_MB = 50  # Max upload size in MB
ENABLE_GPU = os.getenv("ENABLE_GPU", "auto")  # auto, true, false

# Demo content for deployment
DEMO_ENABLED = True
DEMO_FILES_PATH = Path("./demo_files")