Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,8 +8,13 @@ import numpy as np
|
|
| 8 |
|
| 9 |
# Load the pre-trained SentenceTransformer model
|
| 10 |
#pipeline = pipeline(task="Sentence Similarity", model="all-MiniLM-L6-v2")
|
| 11 |
-
model = SentenceTransformer('
|
| 12 |
-
sentence_embed = pd.read_csv('Reference_file.csv')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
import streamlit as st
|
| 15 |
|
|
@@ -17,12 +22,12 @@ import streamlit as st
|
|
| 17 |
def mapping_code(user_input):
|
| 18 |
emb1 = model.encode(user_input.lower())
|
| 19 |
similarities = []
|
| 20 |
-
for sentence in
|
| 21 |
similarity = util.cos_sim(sentence, emb1)
|
| 22 |
similarities.append(similarity)
|
| 23 |
|
| 24 |
# Combine similarity scores with 'code' and 'description'
|
| 25 |
-
result = list(zip(
|
| 26 |
|
| 27 |
# Sort results by similarity scores
|
| 28 |
result.sort(key=lambda x: x[2], reverse=True)
|
|
|
|
| 8 |
|
| 9 |
# Load the pre-trained SentenceTransformer model
|
| 10 |
#pipeline = pipeline(task="Sentence Similarity", model="all-MiniLM-L6-v2")
|
| 11 |
+
model = SentenceTransformer('neuml/pubmedbert-base-embeddings')
|
| 12 |
+
#sentence_embed = pd.read_csv('Reference_file.csv')
|
| 13 |
+
with open("embeddings.pkl", "rb") as fIn:
|
| 14 |
+
stored_data = pickle.load(fIn)
|
| 15 |
+
stored_code = stored_data["SBS_code"]
|
| 16 |
+
stored_sentences = stored_data["sentences"]
|
| 17 |
+
stored_embeddings = stored_data["embeddings"]
|
| 18 |
|
| 19 |
import streamlit as st
|
| 20 |
|
|
|
|
| 22 |
def mapping_code(user_input):
|
| 23 |
emb1 = model.encode(user_input.lower())
|
| 24 |
similarities = []
|
| 25 |
+
for sentence in stored_embeddings:
|
| 26 |
similarity = util.cos_sim(sentence, emb1)
|
| 27 |
similarities.append(similarity)
|
| 28 |
|
| 29 |
# Combine similarity scores with 'code' and 'description'
|
| 30 |
+
result = list(zip(stored_data["SBS_code"],stored_data["sentences"], similarities))
|
| 31 |
|
| 32 |
# Sort results by similarity scores
|
| 33 |
result.sort(key=lambda x: x[2], reverse=True)
|