Spaces:
Sleeping
Sleeping
Ajaykanth Maddi commited on
Commit ·
18fda48
1
Parent(s): 90d2855
Code Changes - Optimized code to check for HF repo
Browse files- constants.py +2 -0
- ragbench.py +4 -4
constants.py
CHANGED
|
@@ -32,6 +32,8 @@ EMBEDDING_MODELS = [
|
|
| 32 |
"all-MiniLM-L6-v2"
|
| 33 |
]
|
| 34 |
|
|
|
|
|
|
|
| 35 |
default_json = {
|
| 36 |
"relevance_explanation": "Documents 1 and 4 contain useful information for answering the question. Document 1 mentions 'Signal Information' and 'Self Diagnosis', which are relevant to finding signal information. Document 4 provides additional context about signal information, such as it being only available for digital channels.",
|
| 37 |
"all_relevant_sentence_keys": [
|
|
|
|
| 32 |
"all-MiniLM-L6-v2"
|
| 33 |
]
|
| 34 |
|
| 35 |
+
GLOBAL_HUGGINGFACE_REPO_EXISTS = False
|
| 36 |
+
|
| 37 |
default_json = {
|
| 38 |
"relevance_explanation": "Documents 1 and 4 contain useful information for answering the question. Document 1 mentions 'Signal Information' and 'Self Diagnosis', which are relevant to finding signal information. Document 4 provides additional context about signal information, such as it being only available for digital channels.",
|
| 39 |
"all_relevant_sentence_keys": [
|
ragbench.py
CHANGED
|
@@ -36,7 +36,8 @@ from utils import (
|
|
| 36 |
|
| 37 |
from constants import (
|
| 38 |
HF_DATASET_REPO_NAME,
|
| 39 |
-
HF_REPO_TYPE
|
|
|
|
| 40 |
)
|
| 41 |
|
| 42 |
# Define document structure
|
|
@@ -86,7 +87,6 @@ class RAGSystem:
|
|
| 86 |
self.embedder = None
|
| 87 |
self.hybrid_retriever = None
|
| 88 |
self.generator_client = None
|
| 89 |
-
self.huggingface_repo_exists = False
|
| 90 |
|
| 91 |
# Set up API-based generator
|
| 92 |
self._init_generator_api()
|
|
@@ -115,7 +115,7 @@ class RAGSystem:
|
|
| 115 |
|
| 116 |
def _check_huggingface_repo(self):
|
| 117 |
|
| 118 |
-
if
|
| 119 |
print(f"Repository {HF_DATASET_REPO_NAME} already exists, skipping check.")
|
| 120 |
return True
|
| 121 |
|
|
@@ -136,7 +136,7 @@ class RAGSystem:
|
|
| 136 |
repo_type=HF_REPO_TYPE,
|
| 137 |
)
|
| 138 |
|
| 139 |
-
|
| 140 |
print(f"Repository {HF_DATASET_REPO_NAME} is accessible. Files:")
|
| 141 |
for index, item in enumerate(repo_files):
|
| 142 |
print(f"Index, {index}, File: {item}")
|
|
|
|
| 36 |
|
| 37 |
from constants import (
|
| 38 |
HF_DATASET_REPO_NAME,
|
| 39 |
+
HF_REPO_TYPE,
|
| 40 |
+
GLOBAL_HUGGINGFACE_REPO_EXISTS
|
| 41 |
)
|
| 42 |
|
| 43 |
# Define document structure
|
|
|
|
| 87 |
self.embedder = None
|
| 88 |
self.hybrid_retriever = None
|
| 89 |
self.generator_client = None
|
|
|
|
| 90 |
|
| 91 |
# Set up API-based generator
|
| 92 |
self._init_generator_api()
|
|
|
|
| 115 |
|
| 116 |
def _check_huggingface_repo(self):
|
| 117 |
|
| 118 |
+
if GLOBAL_HUGGINGFACE_REPO_EXISTS:
|
| 119 |
print(f"Repository {HF_DATASET_REPO_NAME} already exists, skipping check.")
|
| 120 |
return True
|
| 121 |
|
|
|
|
| 136 |
repo_type=HF_REPO_TYPE,
|
| 137 |
)
|
| 138 |
|
| 139 |
+
GLOBAL_HUGGINGFACE_REPO_EXISTS = True
|
| 140 |
print(f"Repository {HF_DATASET_REPO_NAME} is accessible. Files:")
|
| 141 |
for index, item in enumerate(repo_files):
|
| 142 |
print(f"Index, {index}, File: {item}")
|