Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,3 @@
|
|
| 1 |
-
|
| 2 |
import pandas as pd
|
| 3 |
import numpy as np
|
| 4 |
import pickle
|
|
@@ -12,10 +11,15 @@ from transformers import AutoTokenizer, AutoModel, pipeline, AutoModelForQuestio
|
|
| 12 |
from sentence_transformers import models, SentenceTransformer
|
| 13 |
import torch
|
| 14 |
import spacy
|
|
|
|
| 15 |
import streamlit as st
|
| 16 |
from utils import *
|
| 17 |
|
| 18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
@st.cache(allow_output_mutation=True)
|
| 20 |
def load_prep_data():
|
| 21 |
with open('listfile_3.data', 'rb') as filehandle:
|
|
@@ -65,10 +69,12 @@ def load_comprehension_model():
|
|
| 65 |
def main():
|
| 66 |
|
| 67 |
nltk.download('punkt')
|
|
|
|
|
|
|
|
|
|
| 68 |
spacy_nlp = spacy.load('en_core_web_sm')
|
| 69 |
|
| 70 |
-
device = torch.device('cuda:0' if torch.cuda.is_available()
|
| 71 |
-
else 'cpu')
|
| 72 |
|
| 73 |
embeddings = load_prep_data()
|
| 74 |
|
|
@@ -79,7 +85,7 @@ def main():
|
|
| 79 |
|
| 80 |
comprehension_model = load_comprehension_model()
|
| 81 |
|
| 82 |
-
query = st.text_input("Enter Query",'example query ',key="query")
|
| 83 |
|
| 84 |
query_embedding, results1 = fetch_stage1(query, model, list_of_articles)
|
| 85 |
|
|
|
|
|
|
|
| 1 |
import pandas as pd
|
| 2 |
import numpy as np
|
| 3 |
import pickle
|
|
|
|
| 11 |
from sentence_transformers import models, SentenceTransformer
|
| 12 |
import torch
|
| 13 |
import spacy
|
| 14 |
+
import subprocess
|
| 15 |
import streamlit as st
|
| 16 |
from utils import *
|
| 17 |
|
| 18 |
|
| 19 |
+
@st.cache(allow_output_mutation=True)
|
| 20 |
+
def load_spacy_model():
|
| 21 |
+
subprocess.call(['python', '-m','spacy', 'download', 'en_core_web_sm'])
|
| 22 |
+
|
| 23 |
@st.cache(allow_output_mutation=True)
|
| 24 |
def load_prep_data():
|
| 25 |
with open('listfile_3.data', 'rb') as filehandle:
|
|
|
|
| 69 |
def main():
|
| 70 |
|
| 71 |
nltk.download('punkt')
|
| 72 |
+
|
| 73 |
+
load_spacy_model()
|
| 74 |
+
|
| 75 |
spacy_nlp = spacy.load('en_core_web_sm')
|
| 76 |
|
| 77 |
+
device = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')
|
|
|
|
| 78 |
|
| 79 |
embeddings = load_prep_data()
|
| 80 |
|
|
|
|
| 85 |
|
| 86 |
comprehension_model = load_comprehension_model()
|
| 87 |
|
| 88 |
+
query = st.text_input("Enter Query",'example query ', key="query")
|
| 89 |
|
| 90 |
query_embedding, results1 = fetch_stage1(query, model, list_of_articles)
|
| 91 |
|