Spaces:
Sleeping
Sleeping
Update course_search.py
Browse files- course_search.py +10 -5
course_search.py
CHANGED
|
@@ -5,12 +5,17 @@ from typing import List, Dict, Tuple
|
|
| 5 |
import re
|
| 6 |
|
| 7 |
class CourseSearchSystem:
|
|
|
|
| 8 |
def __init__(self):
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
def preprocess_text(self, text: str) -> str:
|
| 15 |
"""Clean and standardize text data"""
|
| 16 |
if pd.isna(text):
|
|
|
|
| 5 |
import re
|
| 6 |
|
| 7 |
class CourseSearchSystem:
|
| 8 |
+
# Modify the initialization in CourseSearchSystem class
|
| 9 |
def __init__(self):
|
| 10 |
+
try:
|
| 11 |
+
# Try loading from the cache first
|
| 12 |
+
self.model = SentenceTransformer('all-MiniLM-L6-v2')
|
| 13 |
+
except Exception as e:
|
| 14 |
+
# If that fails, try loading with transformers directly
|
| 15 |
+
from transformers import AutoModel, AutoTokenizer
|
| 16 |
+
self.tokenizer = AutoTokenizer.from_pretrained('sentence-transformers/all-MiniLM-L6-v2')
|
| 17 |
+
self.model = AutoModel.from_pretrained('sentence-transformers/all-MiniLM-L6-v2')
|
| 18 |
+
|
| 19 |
def preprocess_text(self, text: str) -> str:
|
| 20 |
"""Clean and standardize text data"""
|
| 21 |
if pd.isna(text):
|