Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -13,7 +13,7 @@ st_model_load = st.text('Loading wikipedia embedding...')
|
|
13 |
def load_embedding():
|
14 |
print("Loading embedding...")
|
15 |
hf_hub_download(repo_id="abokbot/wikipedia-embedding", filename="simple_wikipedia_embedding.pt")
|
16 |
-
wikipedia_embedding = torch.load("
|
17 |
print("Embedding loaded!")
|
18 |
return wikipedia_embedding
|
19 |
|
@@ -21,6 +21,25 @@ wikipedia_embedding = load_embedding()
|
|
21 |
st.success('Embedding loaded!')
|
22 |
st_model_load.text("")
|
23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
"""
|
25 |
|
26 |
|
|
|
13 |
def load_embedding():
|
14 |
print("Loading embedding...")
|
15 |
hf_hub_download(repo_id="abokbot/wikipedia-embedding", filename="simple_wikipedia_embedding.pt")
|
16 |
+
wikipedia_embedding = torch.load("simple_wikipedia_embedding.pt")
|
17 |
print("Embedding loaded!")
|
18 |
return wikipedia_embedding
|
19 |
|
|
|
21 |
st.success('Embedding loaded!')
|
22 |
st_model_load.text("")
|
23 |
|
24 |
+
def load_encoders():
|
25 |
+
print("Loading encoders...")
|
26 |
+
bi_encoder = SentenceTransformer('msmarco-MiniLM-L-6-v3')
|
27 |
+
bi_encoder.max_seq_length = 256 #Truncate long passages to 256 tokens
|
28 |
+
top_k = 32
|
29 |
+
cross_encoder = CrossEncoder('cross-encoder/ms-marco-TinyBERT-L-2-v2')
|
30 |
+
return bi_encoder, cross_encoder
|
31 |
+
|
32 |
+
bi_encoder, cross_encoder = load_encoders()
|
33 |
+
st.success('Encoders loaded!')
|
34 |
+
st_model_load.text("")
|
35 |
+
|
36 |
+
if 'text' not in st.session_state:
|
37 |
+
st.session_state.text = ""
|
38 |
+
st_text_area = st.text_area(
|
39 |
+
'Enter query (e.g. What is the capital city of Kenya? or Number of deputees in French parliement)',
|
40 |
+
value=st.session_state.text,
|
41 |
+
height=100
|
42 |
+
)
|
43 |
"""
|
44 |
|
45 |
|