Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,9 +1,6 @@
|
|
| 1 |
-
# Install dependencies
|
| 2 |
-
!pip install transformers sentence-transformers gradio scikit-learn
|
| 3 |
-
|
| 4 |
import pandas as pd
|
| 5 |
from sentence_transformers import SentenceTransformer
|
| 6 |
-
from sklearn.metrics.pairwise import cosine_similarity
|
| 7 |
import gradio as gr
|
| 8 |
|
| 9 |
# Load the dataset
|
|
@@ -26,7 +23,7 @@ def search_courses(user_query):
|
|
| 26 |
course_embeddings.cpu().detach().numpy()
|
| 27 |
)
|
| 28 |
|
| 29 |
-
# Get indices of top matching courses (
|
| 30 |
top_matches = similarities.argsort()[0][-5:][::-1]
|
| 31 |
|
| 32 |
# Retrieve top matching courses
|
|
@@ -48,4 +45,4 @@ iface = gr.Interface(
|
|
| 48 |
)
|
| 49 |
|
| 50 |
# Launch the app (for local testing or deploying in Hugging Face Spaces)
|
| 51 |
-
iface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import pandas as pd
|
| 2 |
from sentence_transformers import SentenceTransformer
|
| 3 |
+
from sklearn.metrics.pairwise import cosine_similarity # Ensure scikit-learn is installed
|
| 4 |
import gradio as gr
|
| 5 |
|
| 6 |
# Load the dataset
|
|
|
|
| 23 |
course_embeddings.cpu().detach().numpy()
|
| 24 |
)
|
| 25 |
|
| 26 |
+
# Get indices of top matching courses (top 5 results)
|
| 27 |
top_matches = similarities.argsort()[0][-5:][::-1]
|
| 28 |
|
| 29 |
# Retrieve top matching courses
|
|
|
|
| 45 |
)
|
| 46 |
|
| 47 |
# Launch the app (for local testing or deploying in Hugging Face Spaces)
|
| 48 |
+
iface.launch()
|