update app
Browse files
app.py
CHANGED
|
@@ -8,6 +8,18 @@ from sklearn.metrics import average_precision_score
|
|
| 8 |
import matplotlib.pyplot as plt
|
| 9 |
import torch
|
| 10 |
import spaces
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
# Check for GPU support and configure appropriately
|
| 13 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
@@ -34,8 +46,8 @@ def ndcg_at_k(relevance_labels, scores, k=10):
|
|
| 34 |
|
| 35 |
# Load datasets
|
| 36 |
datasets = {
|
| 37 |
-
"Relevance_Labels_Dataset": load_dataset("
|
| 38 |
-
"Positive_Negatives_Dataset": load_dataset("
|
| 39 |
}
|
| 40 |
|
| 41 |
@spaces.GPU
|
|
|
|
| 8 |
import matplotlib.pyplot as plt
|
| 9 |
import torch
|
| 10 |
import spaces
|
| 11 |
+
import os
|
| 12 |
+
from huggingface_hub import HfApi
|
| 13 |
+
|
| 14 |
+
# Load Hugging Face token from the environment variable
|
| 15 |
+
HF_TOKEN = os.getenv("HF_TOKEN")
|
| 16 |
+
if HF_TOKEN is None:
|
| 17 |
+
raise ValueError("HF_TOKEN environment variable is not set. Please set it before running the script.")
|
| 18 |
+
|
| 19 |
+
# Authenticate with Hugging Face
|
| 20 |
+
api = HfApi()
|
| 21 |
+
api.set_access_token(HF_TOKEN)
|
| 22 |
+
|
| 23 |
|
| 24 |
# Check for GPU support and configure appropriately
|
| 25 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
|
|
| 46 |
|
| 47 |
# Load datasets
|
| 48 |
datasets = {
|
| 49 |
+
"Relevance_Labels_Dataset": load_dataset("Omartificial-Intelligence-Space/re-ar-test-triplet" , token =HF_TOKEN )["train"],
|
| 50 |
+
"Positive_Negatives_Dataset": load_dataset("Omartificial-Intelligence-Space/re-ar-query-candidate" , token =HF_TOKEN )["train"]
|
| 51 |
}
|
| 52 |
|
| 53 |
@spaces.GPU
|