peter2000's picture
Update apps/intro.py
4258e95
raw
history blame
1.2 kB
import plotly.express as px
import streamlit as st
from sentence_transformers import SentenceTransformer
from huggingface_hub import hf_hub_url, cached_download
import umap.umap_ as umap
import pandas as pd
import os
import joblib
def app():
with st.container():
question = st.text_input("Please enter your text here and we will embed it for you.",
value="Woman",)
if st.button("Embed"):
with st.spinner("👑 load language model (sentence transformer)"):
model_name = 'sentence-transformers/all-MiniLM-L6-v2'
model = SentenceTransformer(model_name)
REPO_ID = "peter2000/umap_embed_3d_all-MiniLM-L6-v2"
FILENAME = "umap_embed_3d_all-MiniLM-L6-v2.sav"
st.write("load umap")
model_umap = joblib.load(cached_download(hf_hub_url(REPO_ID, FILENAME)))
st.write("embed umap")
examples_embeddings = model.encode(question)
st.write("umap")
examples_umap = umap_model.transform(examples_embeddings)
st.write(examples_umap.shape)