Spaces:
Runtime error
Runtime error
fixed type issues
Browse files
rag_pipeline/eval_ragas/metrics.py
CHANGED
|
@@ -105,7 +105,7 @@ def run_grounded_eval(
|
|
| 105 |
Returns:
|
| 106 |
metrics dict (keys → list of per-query scores).
|
| 107 |
"""
|
| 108 |
-
metrics = defaultdict(list)
|
| 109 |
failed = []
|
| 110 |
|
| 111 |
for item in benchmark:
|
|
|
|
| 105 |
Returns:
|
| 106 |
metrics dict (keys → list of per-query scores).
|
| 107 |
"""
|
| 108 |
+
metrics: defaultdict[str, list[float]] = defaultdict(list) #fixed type issues
|
| 109 |
failed = []
|
| 110 |
|
| 111 |
for item in benchmark:
|
rag_pipeline/reranking/rerank.py
CHANGED
|
@@ -1,7 +1,8 @@
|
|
| 1 |
#/rag_pipeline/reranking/rerank.py
|
| 2 |
import numpy as np
|
| 3 |
from sentence_transformers import CrossEncoder
|
| 4 |
-
|
|
|
|
| 5 |
from rag_pipeline.config import (
|
| 6 |
CROSS_ENCODER_MODEL,
|
| 7 |
TOP_N_RERANK,
|
|
@@ -76,7 +77,7 @@ def retrieve_and_grade(
|
|
| 76 |
from rag_pipeline.config import get_groq_client
|
| 77 |
groq_client = get_groq_client()
|
| 78 |
|
| 79 |
-
raw = hybrid_search_expanded(query, top_k=fetch_k)
|
| 80 |
pre_confidence, _ = confidence_score(raw[:top_k])
|
| 81 |
|
| 82 |
if pre_confidence >= confidence_threshold:
|
|
|
|
| 1 |
#/rag_pipeline/reranking/rerank.py
|
| 2 |
import numpy as np
|
| 3 |
from sentence_transformers import CrossEncoder
|
| 4 |
+
import rag_pipeline.retrieval.bm25 as _bm25
|
| 5 |
+
import rag_pipeline.retrieval.semantic as _sem
|
| 6 |
from rag_pipeline.config import (
|
| 7 |
CROSS_ENCODER_MODEL,
|
| 8 |
TOP_N_RERANK,
|
|
|
|
| 77 |
from rag_pipeline.config import get_groq_client
|
| 78 |
groq_client = get_groq_client()
|
| 79 |
|
| 80 |
+
raw = hybrid_search_expanded(query,retriever=_bm25._retriever,client=_sem._qdrant,bi_encoder=_sem._bi_encoder,all_chunks=_bm25._all_chunks, top_k=fetch_k)
|
| 81 |
pre_confidence, _ = confidence_score(raw[:top_k])
|
| 82 |
|
| 83 |
if pre_confidence >= confidence_threshold:
|
rag_pipeline/retrieval/bm25.py
CHANGED
|
@@ -3,6 +3,9 @@
|
|
| 3 |
import bm25s
|
| 4 |
from rag_pipeline.config import BM25_INDEX_PATH, TOP_K_RETRIEVE
|
| 5 |
|
|
|
|
|
|
|
|
|
|
| 6 |
def create_bm25(all_chunks: list[dict]) -> None:
|
| 7 |
corpus_texts = [c["text"] for c in all_chunks]
|
| 8 |
retriever = bm25s.BM25()
|
|
|
|
| 3 |
import bm25s
|
| 4 |
from rag_pipeline.config import BM25_INDEX_PATH, TOP_K_RETRIEVE
|
| 5 |
|
| 6 |
+
from typing import Optional
|
| 7 |
+
_retriever = None
|
| 8 |
+
_all_chunks: list[dict] =[]
|
| 9 |
def create_bm25(all_chunks: list[dict]) -> None:
|
| 10 |
corpus_texts = [c["text"] for c in all_chunks]
|
| 11 |
retriever = bm25s.BM25()
|
rag_pipeline/retrieval/semantic.py
CHANGED
|
@@ -6,6 +6,9 @@ from qdrant_client.models import VectorParams, Distance, PointStruct
|
|
| 6 |
from sentence_transformers import SentenceTransformer
|
| 7 |
from rag_pipeline.config import BI_ENCODER_MODEL,TOP_K_RETRIEVE,COLLECTION_NAME,VECTOR_SIZE
|
| 8 |
|
|
|
|
|
|
|
|
|
|
| 9 |
def load_qdrant() -> QdrantClient:
|
| 10 |
client = QdrantClient(host="localhost",port=6333)
|
| 11 |
print("[INFO] Qdrant loaded")
|
|
|
|
| 6 |
from sentence_transformers import SentenceTransformer
|
| 7 |
from rag_pipeline.config import BI_ENCODER_MODEL,TOP_K_RETRIEVE,COLLECTION_NAME,VECTOR_SIZE
|
| 8 |
|
| 9 |
+
_bi_encoder = None
|
| 10 |
+
_qdrant = None
|
| 11 |
+
_all_chunks:list[dict]=[]
|
| 12 |
def load_qdrant() -> QdrantClient:
|
| 13 |
client = QdrantClient(host="localhost",port=6333)
|
| 14 |
print("[INFO] Qdrant loaded")
|