wilmerags commited on
Commit
d548156
1 Parent(s): 33108e8

feat: Add lang selection and load model function

Browse files
Files changed (1) hide show
  1. app.py +15 -0
app.py CHANGED
@@ -2,7 +2,17 @@ import streamlit as st
2
  import tweepy
3
 
4
 
 
 
 
 
 
 
5
  client = tweepy.Client(bearer_token=st.secrets["tw_bearer_token"])
 
 
 
 
6
 
7
  st.title("Tweet-SNEst")
8
  st.write("Visualize tweets embeddings in 2D using colors for topics labels.")
@@ -12,6 +22,11 @@ with col1:
12
  with col2:
13
  sample = st.number_input("Maximum number of tweets to use", 1, 300, 100, 10)
14
 
 
 
 
 
 
15
  usr = client.get_user(username=tw_user)
16
 
17
  st.write(usr.data.id)
 
2
  import tweepy
3
 
4
 
5
+ @st.cache(show_spinner=False, allow_output_mutation=True)
6
+ def load_model(model_name: str) -> SentenceTransformer:
7
+ embedder = model_name
8
+ return SentenceTransformer(embedder)
9
+
10
+
11
  client = tweepy.Client(bearer_token=st.secrets["tw_bearer_token"])
12
+ model_to_use = {
13
+ "English": "all-MiniLM-L12-v2",
14
+ "Use all the ones you know (~15 lang)": "paraphrase-multilingual-MiniLM-L12-v2"
15
+ }
16
 
17
  st.title("Tweet-SNEst")
18
  st.write("Visualize tweets embeddings in 2D using colors for topics labels.")
 
22
  with col2:
23
  sample = st.number_input("Maximum number of tweets to use", 1, 300, 100, 10)
24
 
25
+ expected_lang = st.radio(
26
+ "What language should be assumed to be found?",
27
+ ('English', 'Use all the ones you know (~15 lang)'))
28
+
29
+
30
  usr = client.get_user(username=tw_user)
31
 
32
  st.write(usr.data.id)