File size: 1,856 Bytes
d3d09d6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""Configuration module for the Document Question Answering (DQA) system."""

import os
from dataclasses import dataclass, field
from typing import Optional, List


@dataclass
class DQAConfig:
    # Model settings
    # Default to SOTA MTEB model: BAAI/bge-small-en-v1.5 (or sentence-transformers/all-MiniLM-L6-v2)
    embedding_model_name: str = "BAAI/bge-small-en-v1.5"
    cross_encoder_model_name: str = "cross-encoder/ms-marco-MiniLM-L-6-v2"
    
    # LLM Settings
    llm_provider: str = "auto"  # 'hf', 'openai', 'offline', or 'auto'
    
    # Hugging Face Settings
    hf_token: Optional[str] = field(default_factory=lambda: os.getenv("HF_TOKEN") or os.getenv("HUGGINGFACEHUB_API_TOKEN"))
    hf_model: str = "Qwen/Qwen2.5-7B-Instruct"  # or 'meta-llama/Llama-3.2-3B-Instruct', 'mistralai/Mistral-7B-Instruct-v0.3'
    
    # OpenAI / Compatible Settings
    openai_model: str = "gpt-4o-mini"
    openai_api_key: Optional[str] = field(default_factory=lambda: os.getenv("OPENAI_API_KEY"))
    openai_base_url: Optional[str] = field(default_factory=lambda: os.getenv("OPENAI_BASE_URL"))
    
    temperature: float = 0.0
    max_tokens: int = 1024
    
    # Ingestion & Chunking
    chunk_size_tokens: int = 400
    chunk_overlap_tokens: int = 50
    min_chunk_tokens: int = 40
    ocr_fallback_enabled: bool = True
    ocr_min_chars_per_page: int = 40
    
    # Retrieval
    initial_top_k: int = 20
    rerank_top_k: int = 5
    rrf_k: int = 60
    dense_weight: float = 0.5
    sparse_weight: float = 0.5
    
    # Verification
    verification_threshold: float = 0.55
    flag_unsupported_claims: bool = True
    
    # Storage
    storage_dir: str = os.path.join(os.path.dirname(os.path.abspath(__file__)), "storage")
    index_file_name: str = "faiss_index.bin"
    metadata_file_name: str = "metadata.json"


default_config = DQAConfig()