Spaces:
Running on Zero
Running on Zero
Download config.py from Varun2007/document-qa-system: direct link, hf CLI and curl.
- Browser
- Download file 1.86 kB
-
https://huggingface.co/spaces/Varun2007/document-qa-system/resolve/main/config.py
- Command line
-
hf download hf://spaces/Varun2007/document-qa-system/config.py
-
curl -L -o config.py https://huggingface.co/spaces/Varun2007/document-qa-system/resolve/main/config.py
1.86 kB
| """Configuration module for the Document Question Answering (DQA) system.""" | |
| import os | |
| from dataclasses import dataclass, field | |
| from typing import Optional, List | |
| 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() | |