Spaces:
Paused
Paused
Commit Β·
83dc8bf
1
Parent(s): bc1ed33
feat: Add VisionQuest Indic RAG core services, vector search, safety guardrails & web UI
Browse filesThis view is limited to 50 files because it contains too many changes. Β See raw diff
- Dockerfile +14 -14
- {api β api_endpoints}/main.py +4 -4
- app.py +9 -9
- config.py +2 -2
- {chunking β doc_chunking}/hybrid_merge.py +0 -0
- {chunking β doc_chunking}/metadata.py +0 -0
- {chunking β doc_chunking}/passage_native.py +1 -1
- {chunking β doc_chunking}/semantic.py +1 -1
- {chunking β doc_chunking}/sentence_window.py +1 -1
- {data β knowledge_base}/augment_longdocs.py +0 -0
- {data β knowledge_base}/build_all_15_corpora.py +0 -0
- {data β knowledge_base}/build_corpus.py +1 -1
- {data β knowledge_base}/indexes/centroids.json +0 -0
- {data β knowledge_base}/indexes/index_manifest.json +0 -0
- {data β knowledge_base}/indexes/passage_native.faiss +0 -0
- {data β knowledge_base}/indexes/passage_native_meta.json +0 -0
- {data β knowledge_base}/indexes/semantic_longdoc.faiss +0 -0
- {data β knowledge_base}/indexes/semantic_longdoc_meta.json +0 -0
- {data β knowledge_base}/movie_data.py +0 -0
- {data β knowledge_base}/processed/en_corpus.jsonl +0 -0
- {data β knowledge_base}/processed/en_longdocs.jsonl +0 -0
- {data β knowledge_base}/processed/hi_corpus.jsonl +0 -0
- {data β knowledge_base}/processed/hi_longdocs.jsonl +0 -0
- {data β knowledge_base}/processed/mr_corpus.jsonl +0 -0
- {data β knowledge_base}/processed/mr_longdocs.jsonl +0 -0
- {data β knowledge_base}/tech_data.py +0 -0
- {benchmark β latency_benchmarks}/quick_eval.py +2 -2
- {benchmark β latency_benchmarks}/report.py +0 -0
- {benchmark β latency_benchmarks}/results/cold_start_benchmark_results.json +0 -0
- {benchmark β latency_benchmarks}/results/latency_report.md +0 -0
- {benchmark β latency_benchmarks}/results/latency_results.csv +0 -0
- {benchmark β latency_benchmarks}/results/latency_results.json +0 -0
- {benchmark β latency_benchmarks}/results/retrieval_benchmark_report.md +0 -0
- {benchmark β latency_benchmarks}/results/speed_bench_50_report.md +0 -0
- {benchmark β latency_benchmarks}/results/speed_bench_50_results.json +0 -0
- {benchmark β latency_benchmarks}/run_cold_start_bench.py +2 -2
- {benchmark β latency_benchmarks}/run_latency_bench.py +3 -3
- {benchmark β latency_benchmarks}/run_speed_bench_50.py +2 -2
- {generation β llm_synthesis}/answer_cache.py +0 -0
- {generation β llm_synthesis}/extractive.py +2 -2
- {generation β llm_synthesis}/llm_fallback.py +0 -0
- {generation β llm_synthesis}/local_slm.py +0 -0
- {training β model_training}/prepare_rag_sft_data.py +0 -0
- {training β model_training}/train_colab.py +1 -1
- {training β model_training}/train_qwen_rag_colab.ipynb +0 -0
- {training β model_training}/train_qwen_unsloth_colab.ipynb +0 -0
- {training β model_training}/upload_to_adaption.py +0 -0
- {pipeline β rag_pipeline}/orchestrator.py +13 -13
- {pipeline β rag_pipeline}/schemas.py +0 -0
- {app β rag_service}/__init__.py +0 -0
Dockerfile
CHANGED
|
@@ -6,9 +6,9 @@ ENV PYTHONUNBUFFERED=1 \
|
|
| 6 |
PYTHONDONTWRITEBYTECODE=1 \
|
| 7 |
PORT=7860 \
|
| 8 |
HOST=0.0.0.0 \
|
| 9 |
-
DATA_DIR=/app/
|
| 10 |
-
INDEX_DIR=/app/
|
| 11 |
-
PROCESSED_DIR=/app/
|
| 12 |
HF_HOME=/app/.cache/huggingface
|
| 13 |
|
| 14 |
WORKDIR /app
|
|
@@ -33,16 +33,16 @@ RUN python -c "from transformers import AutoTokenizer, AutoModel; AutoTokenizer.
|
|
| 33 |
# Copy application source code and pre-built index/processed artifacts
|
| 34 |
COPY config.py .
|
| 35 |
COPY app.py .
|
| 36 |
-
COPY
|
| 37 |
-
COPY
|
| 38 |
-
COPY
|
| 39 |
-
COPY
|
| 40 |
-
COPY
|
| 41 |
-
COPY
|
| 42 |
-
COPY
|
| 43 |
-
COPY
|
| 44 |
-
COPY
|
| 45 |
-
COPY
|
| 46 |
|
| 47 |
# Create user for Hugging Face Spaces security
|
| 48 |
RUN useradd -m -u 1000 user && \
|
|
@@ -53,4 +53,4 @@ USER user
|
|
| 53 |
EXPOSE 7860
|
| 54 |
|
| 55 |
# Launch FastAPI server
|
| 56 |
-
CMD ["
|
|
|
|
| 6 |
PYTHONDONTWRITEBYTECODE=1 \
|
| 7 |
PORT=7860 \
|
| 8 |
HOST=0.0.0.0 \
|
| 9 |
+
DATA_DIR=/app/knowledge_base \
|
| 10 |
+
INDEX_DIR=/app/knowledge_base/indexes \
|
| 11 |
+
PROCESSED_DIR=/app/knowledge_base/processed \
|
| 12 |
HF_HOME=/app/.cache/huggingface
|
| 13 |
|
| 14 |
WORKDIR /app
|
|
|
|
| 33 |
# Copy application source code and pre-built index/processed artifacts
|
| 34 |
COPY config.py .
|
| 35 |
COPY app.py .
|
| 36 |
+
COPY knowledge_base/ ./knowledge_base/
|
| 37 |
+
COPY doc_chunking/ ./doc_chunking/
|
| 38 |
+
COPY vector_search/ ./vector_search/
|
| 39 |
+
COPY voice_stt/ ./voice_stt/
|
| 40 |
+
COPY safety_guardrails/ ./safety_guardrails/
|
| 41 |
+
COPY llm_synthesis/ ./llm_synthesis/
|
| 42 |
+
COPY rag_pipeline/ ./rag_pipeline/
|
| 43 |
+
COPY api_endpoints/ ./api_endpoints/
|
| 44 |
+
COPY latency_benchmarks/ ./latency_benchmarks/
|
| 45 |
+
COPY web_ui/ ./web_ui/
|
| 46 |
|
| 47 |
# Create user for Hugging Face Spaces security
|
| 48 |
RUN useradd -m -u 1000 user && \
|
|
|
|
| 53 |
EXPOSE 7860
|
| 54 |
|
| 55 |
# Launch FastAPI server
|
| 56 |
+
CMD ["python", "app.py"]
|
{api β api_endpoints}/main.py
RENAMED
|
@@ -23,10 +23,10 @@ from fastapi.responses import HTMLResponse, JSONResponse
|
|
| 23 |
from fastapi.staticfiles import StaticFiles
|
| 24 |
|
| 25 |
import config
|
| 26 |
-
from
|
| 27 |
-
from
|
| 28 |
-
from
|
| 29 |
-
from
|
| 30 |
|
| 31 |
logger = logging.getLogger(__name__)
|
| 32 |
|
|
|
|
| 23 |
from fastapi.staticfiles import StaticFiles
|
| 24 |
|
| 25 |
import config
|
| 26 |
+
from rag_pipeline.orchestrator import get_orchestrator, RAGPipelineOrchestrator
|
| 27 |
+
from rag_pipeline.schemas import QueryRequest, QueryResponse
|
| 28 |
+
from vector_search.embed import get_embedder
|
| 29 |
+
from vector_search.index_faiss import get_index_manager
|
| 30 |
|
| 31 |
logger = logging.getLogger(__name__)
|
| 32 |
|
app.py
CHANGED
|
@@ -52,15 +52,15 @@ except ImportError:
|
|
| 52 |
return func
|
| 53 |
|
| 54 |
import config
|
| 55 |
-
from
|
| 56 |
-
from
|
| 57 |
-
from
|
| 58 |
-
from
|
| 59 |
|
| 60 |
|
| 61 |
# Read the full custom HTML Command Center UI
|
| 62 |
def get_custom_html() -> str:
|
| 63 |
-
demo_file = config.BASE_DIR / "
|
| 64 |
if demo_file.exists():
|
| 65 |
with open(demo_file, "r", encoding="utf-8") as f:
|
| 66 |
return f.read()
|
|
@@ -100,7 +100,7 @@ async def startup_event():
|
|
| 100 |
@app.get("/", response_class=HTMLResponse)
|
| 101 |
async def serve_index() -> HTMLResponse:
|
| 102 |
"""Serve full retro-tropical Command Center UI directly to browser."""
|
| 103 |
-
demo_file = config.BASE_DIR / "
|
| 104 |
if demo_file.exists():
|
| 105 |
with open(demo_file, "r", encoding="utf-8") as f:
|
| 106 |
return HTMLResponse(content=f.read())
|
|
@@ -110,7 +110,7 @@ async def serve_index() -> HTMLResponse:
|
|
| 110 |
@app.get("/ironman.png")
|
| 111 |
async def serve_ironman() -> FileResponse:
|
| 112 |
"""Serve Iron Man sprite image."""
|
| 113 |
-
img_path = config.BASE_DIR / "
|
| 114 |
if img_path.exists():
|
| 115 |
return FileResponse(img_path)
|
| 116 |
raise HTTPException(status_code=404, detail="Iron Man image missing")
|
|
@@ -119,7 +119,7 @@ async def serve_ironman() -> FileResponse:
|
|
| 119 |
@app.get("/thor.png")
|
| 120 |
async def serve_thor() -> FileResponse:
|
| 121 |
"""Serve Thor sprite image."""
|
| 122 |
-
img_path = config.BASE_DIR / "
|
| 123 |
if img_path.exists():
|
| 124 |
return FileResponse(img_path)
|
| 125 |
raise HTTPException(status_code=404, detail="Thor image missing")
|
|
@@ -128,7 +128,7 @@ async def serve_thor() -> FileResponse:
|
|
| 128 |
@app.get("/cap.png")
|
| 129 |
async def serve_cap() -> FileResponse:
|
| 130 |
"""Serve Captain America sprite image."""
|
| 131 |
-
img_path = config.BASE_DIR / "
|
| 132 |
if img_path.exists():
|
| 133 |
return FileResponse(img_path)
|
| 134 |
raise HTTPException(status_code=404, detail="Captain America image missing")
|
|
|
|
| 52 |
return func
|
| 53 |
|
| 54 |
import config
|
| 55 |
+
from rag_pipeline.orchestrator import get_orchestrator
|
| 56 |
+
from rag_pipeline.schemas import QueryRequest, QueryResponse
|
| 57 |
+
from vector_search.embed import get_embedder
|
| 58 |
+
from vector_search.index_faiss import get_index_manager
|
| 59 |
|
| 60 |
|
| 61 |
# Read the full custom HTML Command Center UI
|
| 62 |
def get_custom_html() -> str:
|
| 63 |
+
demo_file = config.BASE_DIR / "web_ui" / "index.html"
|
| 64 |
if demo_file.exists():
|
| 65 |
with open(demo_file, "r", encoding="utf-8") as f:
|
| 66 |
return f.read()
|
|
|
|
| 100 |
@app.get("/", response_class=HTMLResponse)
|
| 101 |
async def serve_index() -> HTMLResponse:
|
| 102 |
"""Serve full retro-tropical Command Center UI directly to browser."""
|
| 103 |
+
demo_file = config.BASE_DIR / "web_ui" / "index.html"
|
| 104 |
if demo_file.exists():
|
| 105 |
with open(demo_file, "r", encoding="utf-8") as f:
|
| 106 |
return HTMLResponse(content=f.read())
|
|
|
|
| 110 |
@app.get("/ironman.png")
|
| 111 |
async def serve_ironman() -> FileResponse:
|
| 112 |
"""Serve Iron Man sprite image."""
|
| 113 |
+
img_path = config.BASE_DIR / "web_ui" / "ironman.png"
|
| 114 |
if img_path.exists():
|
| 115 |
return FileResponse(img_path)
|
| 116 |
raise HTTPException(status_code=404, detail="Iron Man image missing")
|
|
|
|
| 119 |
@app.get("/thor.png")
|
| 120 |
async def serve_thor() -> FileResponse:
|
| 121 |
"""Serve Thor sprite image."""
|
| 122 |
+
img_path = config.BASE_DIR / "web_ui" / "thor.png"
|
| 123 |
if img_path.exists():
|
| 124 |
return FileResponse(img_path)
|
| 125 |
raise HTTPException(status_code=404, detail="Thor image missing")
|
|
|
|
| 128 |
@app.get("/cap.png")
|
| 129 |
async def serve_cap() -> FileResponse:
|
| 130 |
"""Serve Captain America sprite image."""
|
| 131 |
+
img_path = config.BASE_DIR / "web_ui" / "cap.png"
|
| 132 |
if img_path.exists():
|
| 133 |
return FileResponse(img_path)
|
| 134 |
raise HTTPException(status_code=404, detail="Captain America image missing")
|
config.py
CHANGED
|
@@ -68,11 +68,11 @@ def get_language_info(lang_code: str) -> dict:
|
|
| 68 |
# 2. PATHS CONFIGURATION
|
| 69 |
# ==========================================
|
| 70 |
BASE_DIR = Path(__file__).resolve().parent
|
| 71 |
-
DATA_DIR = Path(os.getenv("DATA_DIR", BASE_DIR / "
|
| 72 |
RAW_DATA_DIR = DATA_DIR / "raw"
|
| 73 |
PROCESSED_DATA_DIR = DATA_DIR / "processed"
|
| 74 |
INDEX_DIR = DATA_DIR / "indexes"
|
| 75 |
-
BENCHMARK_RESULTS_DIR = BASE_DIR / "
|
| 76 |
|
| 77 |
for d in [DATA_DIR, RAW_DATA_DIR, PROCESSED_DATA_DIR, INDEX_DIR, BENCHMARK_RESULTS_DIR]:
|
| 78 |
d.mkdir(parents=True, exist_ok=True)
|
|
|
|
| 68 |
# 2. PATHS CONFIGURATION
|
| 69 |
# ==========================================
|
| 70 |
BASE_DIR = Path(__file__).resolve().parent
|
| 71 |
+
DATA_DIR = Path(os.getenv("DATA_DIR", BASE_DIR / "knowledge_base"))
|
| 72 |
RAW_DATA_DIR = DATA_DIR / "raw"
|
| 73 |
PROCESSED_DATA_DIR = DATA_DIR / "processed"
|
| 74 |
INDEX_DIR = DATA_DIR / "indexes"
|
| 75 |
+
BENCHMARK_RESULTS_DIR = BASE_DIR / "latency_benchmarks" / "results"
|
| 76 |
|
| 77 |
for d in [DATA_DIR, RAW_DATA_DIR, PROCESSED_DATA_DIR, INDEX_DIR, BENCHMARK_RESULTS_DIR]:
|
| 78 |
d.mkdir(parents=True, exist_ok=True)
|
{chunking β doc_chunking}/hybrid_merge.py
RENAMED
|
File without changes
|
{chunking β doc_chunking}/metadata.py
RENAMED
|
File without changes
|
{chunking β doc_chunking}/passage_native.py
RENAMED
|
@@ -6,7 +6,7 @@ Baseline, zero-loss index strategy preserving original passage boundaries and qu
|
|
| 6 |
"""
|
| 7 |
|
| 8 |
from typing import Any, Dict, List
|
| 9 |
-
from
|
| 10 |
|
| 11 |
|
| 12 |
def chunk_passage_native(passage_dict: Dict[str, Any]) -> Chunk:
|
|
|
|
| 6 |
"""
|
| 7 |
|
| 8 |
from typing import Any, Dict, List
|
| 9 |
+
from doc_chunking.metadata import Chunk, estimate_token_count
|
| 10 |
|
| 11 |
|
| 12 |
def chunk_passage_native(passage_dict: Dict[str, Any]) -> Chunk:
|
{chunking β doc_chunking}/semantic.py
RENAMED
|
@@ -11,7 +11,7 @@ For long documents:
|
|
| 11 |
from typing import Any, Dict, List, Optional
|
| 12 |
import numpy as np
|
| 13 |
import config
|
| 14 |
-
from
|
| 15 |
Chunk,
|
| 16 |
split_sentences_multilingual,
|
| 17 |
calculate_overlap_tokens,
|
|
|
|
| 11 |
from typing import Any, Dict, List, Optional
|
| 12 |
import numpy as np
|
| 13 |
import config
|
| 14 |
+
from doc_chunking.metadata import (
|
| 15 |
Chunk,
|
| 16 |
split_sentences_multilingual,
|
| 17 |
calculate_overlap_tokens,
|
{chunking β doc_chunking}/sentence_window.py
RENAMED
|
@@ -9,7 +9,7 @@ For long documents:
|
|
| 9 |
|
| 10 |
from typing import Any, Dict, List
|
| 11 |
import config
|
| 12 |
-
from
|
| 13 |
Chunk,
|
| 14 |
split_sentences_multilingual,
|
| 15 |
calculate_overlap_tokens,
|
|
|
|
| 9 |
|
| 10 |
from typing import Any, Dict, List
|
| 11 |
import config
|
| 12 |
+
from doc_chunking.metadata import (
|
| 13 |
Chunk,
|
| 14 |
split_sentences_multilingual,
|
| 15 |
calculate_overlap_tokens,
|
{data β knowledge_base}/augment_longdocs.py
RENAMED
|
File without changes
|
{data β knowledge_base}/build_all_15_corpora.py
RENAMED
|
File without changes
|
{data β knowledge_base}/build_corpus.py
RENAMED
|
@@ -79,7 +79,7 @@ def load_raw_dataset_for_lang(lang: str, max_queries: int = 6000) -> List[Dict[s
|
|
| 79 |
else:
|
| 80 |
# Fallback: Pull from Hugging Face
|
| 81 |
try:
|
| 82 |
-
from
|
| 83 |
logger.info(f"Downloading dataset for language '{lang}' from Hugging Face...")
|
| 84 |
if lang == "en":
|
| 85 |
try:
|
|
|
|
| 79 |
else:
|
| 80 |
# Fallback: Pull from Hugging Face
|
| 81 |
try:
|
| 82 |
+
from knowledge_base import load_dataset
|
| 83 |
logger.info(f"Downloading dataset for language '{lang}' from Hugging Face...")
|
| 84 |
if lang == "en":
|
| 85 |
try:
|
{data β knowledge_base}/indexes/centroids.json
RENAMED
|
File without changes
|
{data β knowledge_base}/indexes/index_manifest.json
RENAMED
|
File without changes
|
{data β knowledge_base}/indexes/passage_native.faiss
RENAMED
|
File without changes
|
{data β knowledge_base}/indexes/passage_native_meta.json
RENAMED
|
File without changes
|
{data β knowledge_base}/indexes/semantic_longdoc.faiss
RENAMED
|
File without changes
|
{data β knowledge_base}/indexes/semantic_longdoc_meta.json
RENAMED
|
File without changes
|
{data β knowledge_base}/movie_data.py
RENAMED
|
File without changes
|
{data β knowledge_base}/processed/en_corpus.jsonl
RENAMED
|
File without changes
|
{data β knowledge_base}/processed/en_longdocs.jsonl
RENAMED
|
File without changes
|
{data β knowledge_base}/processed/hi_corpus.jsonl
RENAMED
|
File without changes
|
{data β knowledge_base}/processed/hi_longdocs.jsonl
RENAMED
|
File without changes
|
{data β knowledge_base}/processed/mr_corpus.jsonl
RENAMED
|
File without changes
|
{data β knowledge_base}/processed/mr_longdocs.jsonl
RENAMED
|
File without changes
|
{data β knowledge_base}/tech_data.py
RENAMED
|
File without changes
|
{benchmark β latency_benchmarks}/quick_eval.py
RENAMED
|
@@ -8,8 +8,8 @@ if hasattr(sys.stdout, "reconfigure"):
|
|
| 8 |
sys.stdout.reconfigure(encoding="utf-8")
|
| 9 |
|
| 10 |
import config
|
| 11 |
-
from
|
| 12 |
-
from
|
| 13 |
|
| 14 |
async def main():
|
| 15 |
print(f"--- RAG Pipeline Latency Benchmark ---")
|
|
|
|
| 8 |
sys.stdout.reconfigure(encoding="utf-8")
|
| 9 |
|
| 10 |
import config
|
| 11 |
+
from rag_pipeline.orchestrator import get_orchestrator
|
| 12 |
+
from rag_pipeline.schemas import QueryRequest
|
| 13 |
|
| 14 |
async def main():
|
| 15 |
print(f"--- RAG Pipeline Latency Benchmark ---")
|
{benchmark β latency_benchmarks}/report.py
RENAMED
|
File without changes
|
{benchmark β latency_benchmarks}/results/cold_start_benchmark_results.json
RENAMED
|
File without changes
|
{benchmark β latency_benchmarks}/results/latency_report.md
RENAMED
|
File without changes
|
{benchmark β latency_benchmarks}/results/latency_results.csv
RENAMED
|
File without changes
|
{benchmark β latency_benchmarks}/results/latency_results.json
RENAMED
|
File without changes
|
{benchmark β latency_benchmarks}/results/retrieval_benchmark_report.md
RENAMED
|
File without changes
|
{benchmark β latency_benchmarks}/results/speed_bench_50_report.md
RENAMED
|
File without changes
|
{benchmark β latency_benchmarks}/results/speed_bench_50_results.json
RENAMED
|
File without changes
|
{benchmark β latency_benchmarks}/run_cold_start_bench.py
RENAMED
|
@@ -31,8 +31,8 @@ if sys.platform == "win32":
|
|
| 31 |
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
|
| 32 |
|
| 33 |
import config
|
| 34 |
-
from
|
| 35 |
-
from
|
| 36 |
|
| 37 |
logging.basicConfig(level=logging.INFO, format="%(asctime)s [%(levelname)s] %(message)s")
|
| 38 |
logger = logging.getLogger("cold_start_bench")
|
|
|
|
| 31 |
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
|
| 32 |
|
| 33 |
import config
|
| 34 |
+
from rag_pipeline.orchestrator import get_orchestrator
|
| 35 |
+
from rag_pipeline.schemas import QueryRequest
|
| 36 |
|
| 37 |
logging.basicConfig(level=logging.INFO, format="%(asctime)s [%(levelname)s] %(message)s")
|
| 38 |
logger = logging.getLogger("cold_start_bench")
|
{benchmark β latency_benchmarks}/run_latency_bench.py
RENAMED
|
@@ -26,8 +26,8 @@ import psutil
|
|
| 26 |
# Ensure project root is in sys.path
|
| 27 |
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
|
| 28 |
import config
|
| 29 |
-
from
|
| 30 |
-
from
|
| 31 |
|
| 32 |
logging.basicConfig(level=logging.INFO, format="%(asctime)s [%(levelname)s] %(message)s")
|
| 33 |
logger = logging.getLogger(__name__)
|
|
@@ -269,7 +269,7 @@ async def run_benchmark(iterations: int = 1) -> Dict[str, Any]:
|
|
| 269 |
logger.info(f"Benchmark results successfully saved to {json_path} and {csv_path}")
|
| 270 |
|
| 271 |
try:
|
| 272 |
-
from
|
| 273 |
generate_latency_report(json_path=json_path)
|
| 274 |
logger.info("Latency report successfully generated!")
|
| 275 |
except Exception as e:
|
|
|
|
| 26 |
# Ensure project root is in sys.path
|
| 27 |
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
|
| 28 |
import config
|
| 29 |
+
from rag_pipeline.orchestrator import get_orchestrator
|
| 30 |
+
from rag_pipeline.schemas import QueryRequest, QueryResponse
|
| 31 |
|
| 32 |
logging.basicConfig(level=logging.INFO, format="%(asctime)s [%(levelname)s] %(message)s")
|
| 33 |
logger = logging.getLogger(__name__)
|
|
|
|
| 269 |
logger.info(f"Benchmark results successfully saved to {json_path} and {csv_path}")
|
| 270 |
|
| 271 |
try:
|
| 272 |
+
from latency_benchmarks.report import generate_latency_report
|
| 273 |
generate_latency_report(json_path=json_path)
|
| 274 |
logger.info("Latency report successfully generated!")
|
| 275 |
except Exception as e:
|
{benchmark β latency_benchmarks}/run_speed_bench_50.py
RENAMED
|
@@ -23,8 +23,8 @@ import psutil
|
|
| 23 |
# Ensure project root is in sys.path
|
| 24 |
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
|
| 25 |
import config
|
| 26 |
-
from
|
| 27 |
-
from
|
| 28 |
|
| 29 |
logging.basicConfig(level=logging.INFO, format="%(asctime)s [%(levelname)s] %(message)s")
|
| 30 |
logger = logging.getLogger("speed_bench_50")
|
|
|
|
| 23 |
# Ensure project root is in sys.path
|
| 24 |
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
|
| 25 |
import config
|
| 26 |
+
from rag_pipeline.orchestrator import get_orchestrator
|
| 27 |
+
from rag_pipeline.schemas import QueryRequest, QueryResponse
|
| 28 |
|
| 29 |
logging.basicConfig(level=logging.INFO, format="%(asctime)s [%(levelname)s] %(message)s")
|
| 30 |
logger = logging.getLogger("speed_bench_50")
|
{generation β llm_synthesis}/answer_cache.py
RENAMED
|
File without changes
|
{generation β llm_synthesis}/extractive.py
RENAMED
|
@@ -9,8 +9,8 @@ from typing import Any, Dict, List, Optional
|
|
| 9 |
import numpy as np
|
| 10 |
import re
|
| 11 |
import config
|
| 12 |
-
from
|
| 13 |
-
from
|
| 14 |
|
| 15 |
|
| 16 |
def extract_answer_from_passage(
|
|
|
|
| 9 |
import numpy as np
|
| 10 |
import re
|
| 11 |
import config
|
| 12 |
+
from doc_chunking.metadata import split_sentences_multilingual
|
| 13 |
+
from llm_synthesis.answer_cache import get_answer_cache
|
| 14 |
|
| 15 |
|
| 16 |
def extract_answer_from_passage(
|
{generation β llm_synthesis}/llm_fallback.py
RENAMED
|
File without changes
|
{generation β llm_synthesis}/local_slm.py
RENAMED
|
File without changes
|
{training β model_training}/prepare_rag_sft_data.py
RENAMED
|
File without changes
|
{training β model_training}/train_colab.py
RENAMED
|
@@ -12,7 +12,7 @@ Usage in Google Colab:
|
|
| 12 |
import os
|
| 13 |
import json
|
| 14 |
import torch
|
| 15 |
-
from
|
| 16 |
from transformers import (
|
| 17 |
AutoModelForCausalLM,
|
| 18 |
AutoTokenizer,
|
|
|
|
| 12 |
import os
|
| 13 |
import json
|
| 14 |
import torch
|
| 15 |
+
from knowledge_base import load_dataset
|
| 16 |
from transformers import (
|
| 17 |
AutoModelForCausalLM,
|
| 18 |
AutoTokenizer,
|
{training β model_training}/train_qwen_rag_colab.ipynb
RENAMED
|
File without changes
|
{training β model_training}/train_qwen_unsloth_colab.ipynb
RENAMED
|
File without changes
|
{training β model_training}/upload_to_adaption.py
RENAMED
|
File without changes
|
{pipeline β rag_pipeline}/orchestrator.py
RENAMED
|
@@ -17,24 +17,24 @@ from typing import Any, Dict, List, Optional
|
|
| 17 |
import numpy as np
|
| 18 |
|
| 19 |
import config
|
| 20 |
-
from
|
| 21 |
GuardrailFlags,
|
| 22 |
QueryRequest,
|
| 23 |
QueryResponse,
|
| 24 |
RetrievedChunk,
|
| 25 |
StageTiming,
|
| 26 |
)
|
| 27 |
-
from
|
| 28 |
-
from
|
| 29 |
-
from
|
| 30 |
-
from
|
| 31 |
-
from
|
| 32 |
-
from
|
| 33 |
-
from
|
| 34 |
-
from
|
| 35 |
-
from
|
| 36 |
-
from
|
| 37 |
-
from
|
| 38 |
|
| 39 |
logger = logging.getLogger(__name__)
|
| 40 |
|
|
@@ -550,7 +550,7 @@ class RAGPipelineOrchestrator:
|
|
| 550 |
|
| 551 |
if config.ENABLE_LOCAL_SLM:
|
| 552 |
# High-speed local offline SLM generation on CPU (< 60 ms)
|
| 553 |
-
from
|
| 554 |
context_blocks = []
|
| 555 |
for i, c in enumerate(reranked_chunks[:3]):
|
| 556 |
lang_code = c.get("source_lang", "UNK").upper()
|
|
|
|
| 17 |
import numpy as np
|
| 18 |
|
| 19 |
import config
|
| 20 |
+
from rag_pipeline.schemas import (
|
| 21 |
GuardrailFlags,
|
| 22 |
QueryRequest,
|
| 23 |
QueryResponse,
|
| 24 |
RetrievedChunk,
|
| 25 |
StageTiming,
|
| 26 |
)
|
| 27 |
+
from vector_search.embed import get_embedder
|
| 28 |
+
from vector_search.index_faiss import get_index_manager
|
| 29 |
+
from vector_search.rerank import rerank_bm25_hybrid, rerank_cross_encoder, get_cross_encoder
|
| 30 |
+
from doc_chunking.hybrid_merge import merge_and_fuse_candidates
|
| 31 |
+
from safety_guardrails.pre_retrieval import check_unsafe_content, check_off_topic_query, check_query_intent, get_safety_telemetry
|
| 32 |
+
from safety_guardrails.prompt_guard import get_prompt_guard_detector
|
| 33 |
+
from safety_guardrails.post_generation import check_grounding, DECLINED_RESPONSE_TEMPLATE
|
| 34 |
+
from llm_synthesis.extractive import generate_extractive
|
| 35 |
+
from llm_synthesis.answer_cache import get_answer_cache
|
| 36 |
+
from llm_synthesis.llm_fallback import get_llm_adapter
|
| 37 |
+
from voice_stt.sarvam_client import get_stt_client
|
| 38 |
|
| 39 |
logger = logging.getLogger(__name__)
|
| 40 |
|
|
|
|
| 550 |
|
| 551 |
if config.ENABLE_LOCAL_SLM:
|
| 552 |
# High-speed local offline SLM generation on CPU (< 60 ms)
|
| 553 |
+
from llm_synthesis.local_slm import get_local_slm_adapter
|
| 554 |
context_blocks = []
|
| 555 |
for i, c in enumerate(reranked_chunks[:3]):
|
| 556 |
lang_code = c.get("source_lang", "UNK").upper()
|
{pipeline β rag_pipeline}/schemas.py
RENAMED
|
File without changes
|
{app β rag_service}/__init__.py
RENAMED
|
File without changes
|