You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
colbert_config (ColBERTConfig, optional): colbert config for building and searching. Defaults to None.
82
84
load_only (bool, optional): whether to load the index or build and then load. Defaults to False.
83
85
"""
84
-
assertcolbert_configisnotNone, "Please pass a valid colbert_config, which you can import from colbert.infra.config import ColBERTConfig and modify it"
86
+
assert (
87
+
colbert_configisnotNone
88
+
), "Please pass a valid colbert_config, which you can import from colbert.infra.config import ColBERTConfig and modify it"
85
89
self.colbert_config=colbert_config
86
90
87
-
assertself.colbert_config.checkpointisnotNone, "Please pass a valid checkpoint like colbert-ir/colbertv2.0, which you can modify in the ColBERTConfig with attribute name checkpoint"
91
+
assert (
92
+
self.colbert_config.checkpointisnotNone
93
+
), "Please pass a valid checkpoint like colbert-ir/colbertv2.0, which you can modify in the ColBERTConfig with attribute name checkpoint"
88
94
self.passages=passages
89
-
90
-
assertself.colbert_config.index_nameisnotNone, "Please pass a valid index_name, which you can modify in the ColBERTConfig with attribute name index_name"
95
+
96
+
assert (
97
+
self.colbert_config.index_nameisnotNone
98
+
), "Please pass a valid index_name, which you can modify in the ColBERTConfig with attribute name index_name"
91
99
self.passages=passages
92
100
93
101
ifnotload_only:
94
-
print(f"Building the index for experiment {self.colbert_config.experiment} with index name {self.colbert_config.index_name}")
102
+
print(
103
+
f"Building the index for experiment {self.colbert_config.experiment} with index name "
104
+
f"{self.colbert_config.index_name}"
105
+
)
95
106
self.build_index()
96
-
97
-
print(f"Loading the index for experiment {self.colbert_config.experiment} with index name {self.colbert_config.index_name}")
107
+
108
+
print(
109
+
f"Loading the index for experiment {self.colbert_config.experiment} with index name "
110
+
f"{self.colbert_config.index_name}"
111
+
)
98
112
self.searcher=self.get_index()
99
113
100
114
defbuild_index(self):
101
-
102
115
try:
103
-
importcolbert# noqa: F401
116
+
importcolbert# noqa: F401
104
117
exceptImportError:
105
-
print("Colbert not found. Please check your installation or install the module using pip install colbert-ai[faiss-gpu,torch].")
118
+
print(
119
+
"Colbert not found. Please check your installation or install the module using pip install "
0 commit comments