davila7 commited on
Commit
a1c50cf
1 Parent(s): 59b54fb

semantic search chart

Browse files
Files changed (1) hide show
  1. app.py +11 -10
app.py CHANGED
@@ -67,24 +67,25 @@ tab1, tab2 = st.tabs(["Intro", "Semantic Search"])
67
  with tab1:
68
  st.markdown("### Semantic Search with cosine similarity")
69
  st.write("Cosine similarity is a technique used to measure the similarity between two vectors. In the context of OpenAI's embedding API, cosine similarity is used to compare the similarity between two pieces of text based on their underlying vector representations.")
70
- st.write("Here's how it works:")
71
- st.write("1.First, the embedding API converts each piece of text into a vector representation using a pre-trained language model. This vector represents the meaning and context of the text.")
72
- st.write("2.The cosine similarity function then takes these two vectors and calculates the cosine of the angle between them. The cosine similarity score ranges from -1 to 1, where 1 indicates that the two vectors are identical, 0 indicates that they are completely dissimilar, and -1 indicates that they are exact opposites.")
73
- st.write("3.This cosine similarity score is then used to determine the similarity between the two pieces of text. For example, if the cosine similarity score is close to 1, the two pieces of text are likely very similar in meaning, while a score close to 0 suggests that they are completely different.")
 
74
  st.write("Overall, cosine similarity is a powerful tool for comparing the semantic similarity between two pieces of text, and OpenAI's embedding API makes it easy to implement this technique in your own projects.")
75
  st.markdown("""---""")
76
  st.markdown("## Semantic Search was written with the following tools:")
77
  st.markdown("#### Code GPT")
78
- st.write("All code was written with the help of Code GPT. Visit [codegpt.co]('https://codegpt.co') to get the extension.")
79
  st.markdown("#### Streamlit")
80
- st.write("The design was written with [Streamlit]('https://streamlit.io/').")
81
  st.markdown("#### LangChain")
82
- st.write('[Embedding]("https://platform.openai.com/docs/guides/embeddings") is done via the OpenAI API with "text-embedding-ada-002" and LangChain.')
 
83
  st.markdown("""---""")
84
- st.write('Author: [Daniel Ávila](https://www.linkedin.com/in/daniel-avila-arias/)')
85
- st.write('Repo: [Github](https://github.com/davila7/semantic-search)')
86
  st.write("This software was developed with Code GPT, for more information visit: https://codegpt.co")
87
-
88
  with tab2:
89
  st.write('To obtain an API Key you must create an OpenAI account at the following link: https://openai.com/api/')
90
  query = st.text_area("Ask a question about the document", on_change=clear_submit)
 
67
  with tab1:
68
  st.markdown("### Semantic Search with cosine similarity")
69
  st.write("Cosine similarity is a technique used to measure the similarity between two vectors. In the context of OpenAI's embedding API, cosine similarity is used to compare the similarity between two pieces of text based on their underlying vector representations.")
70
+ st.markdown('<img width="701" alt="Captura de Pantalla 2023-02-25 a la(s) 2 28 38 p  m" src="https://user-images.githubusercontent.com/6216945/221375969-ba8b2349-fbc4-4070-abb7-92a21ed2b265.png">', unsafe_allow_html=True)
71
+ st.write("### Here's how it works:")
72
+ st.write("1. First, the embedding API converts each piece of text into a vector representation using a pre-trained language model. This vector represents the meaning and context of the text.")
73
+ st.write("2. The cosine similarity function then takes these two vectors and calculates the cosine of the angle between them. The cosine similarity score ranges from -1 to 1, where 1 indicates that the two vectors are identical, 0 indicates that they are completely dissimilar, and -1 indicates that they are exact opposites.")
74
+ st.write("3. This cosine similarity score is then used to determine the similarity between the two pieces of text. For example, if the cosine similarity score is close to 1, the two pieces of text are likely very similar in meaning, while a score close to 0 suggests that they are completely different.")
75
  st.write("Overall, cosine similarity is a powerful tool for comparing the semantic similarity between two pieces of text, and OpenAI's embedding API makes it easy to implement this technique in your own projects.")
76
  st.markdown("""---""")
77
  st.markdown("## Semantic Search was written with the following tools:")
78
  st.markdown("#### Code GPT")
79
+ st.write("All code was written with the help of Code GPT. Visit <a href='https://codegpt.co'>https://codegpt.co</a> to get the extension.", unsafe_allow_html=True)
80
  st.markdown("#### Streamlit")
81
+ st.write("The design was written with <a href='https://streamlit.io/' target='_blank'>Streamlit</a>.", unsafe_allow_html=True)
82
  st.markdown("#### LangChain")
83
+ st.markdown('<a href="https://platform.openai.com/docs/guides/embeddings">Embeddings</a> is done via the OpenAI API with "text-embedding-ada-002" and LangChain.', unsafe_allow_html=True)
84
+ st.markdown("<a href='https://github.com/facebookresearch/faiss'>FAISS</a> Facebook AI Similarity Search is a library for efficient similarity search and clustering of dense vectors.", unsafe_allow_html=True)
85
  st.markdown("""---""")
86
+ st.write('Author: <a href="https://www.linkedin.com/in/daniel-avila-arias/">Daniel Avila</a>', unsafe_allow_html=True)
87
+ st.write('Repo: <a href="https://github.com/davila7/semantic-search">Github</a>', unsafe_allow_html=True)
88
  st.write("This software was developed with Code GPT, for more information visit: https://codegpt.co")
 
89
  with tab2:
90
  st.write('To obtain an API Key you must create an OpenAI account at the following link: https://openai.com/api/')
91
  query = st.text_area("Ask a question about the document", on_change=clear_submit)