noisemarseille commited on
Commit ·
56f6815
1
Parent(s): 7adb5c2
category retrieval
Browse files
utils/annotation_retrieval.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
"""Nearest-neighbor annotation lookup against a FAISS index + parquet table
|
| 2 |
mounted from the HF bucket (via hfmount) -- reference_min.index /
|
| 3 |
reference_min.parquet, row i of the parquet matching vector i of the index.
|
| 4 |
-
Table
|
| 5 |
import os
|
| 6 |
|
| 7 |
import faiss
|
|
@@ -42,7 +42,10 @@ class AnnotationRetriever:
|
|
| 42 |
|
| 43 |
def _as_dict(self, score, idx):
|
| 44 |
row = self.df.iloc[idx]
|
| 45 |
-
return {
|
|
|
|
|
|
|
|
|
|
| 46 |
|
| 47 |
def _summarize(self, scores, indices):
|
| 48 |
valid = [(float(s), int(i)) for s, i in zip(scores, indices) if i >= 0]
|
|
|
|
| 1 |
"""Nearest-neighbor annotation lookup against a FAISS index + parquet table
|
| 2 |
mounted from the HF bucket (via hfmount) -- reference_min.index /
|
| 3 |
reference_min.parquet, row i of the parquet matching vector i of the index.
|
| 4 |
+
Table columns: id, source (swissprot / acr / phrog), annotation, category."""
|
| 5 |
import os
|
| 6 |
|
| 7 |
import faiss
|
|
|
|
| 42 |
|
| 43 |
def _as_dict(self, score, idx):
|
| 44 |
row = self.df.iloc[idx]
|
| 45 |
+
return {
|
| 46 |
+
"id": row["id"], "source": row["source"], "annotation": row["annotation"],
|
| 47 |
+
"category": row["category"], "score": float(score),
|
| 48 |
+
}
|
| 49 |
|
| 50 |
def _summarize(self, scores, indices):
|
| 51 |
valid = [(float(s), int(i)) for s, i in zip(scores, indices) if i >= 0]
|