uumerrr684 commited on
Commit
22e3caf
Β·
verified Β·
1 Parent(s): 82a1c83

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +71 -13
README.md CHANGED
@@ -1,20 +1,78 @@
1
  ---
2
- title: Cosine Similarity Explainer
3
- emoji: πŸš€
4
- colorFrom: red
5
- colorTo: red
6
- sdk: docker
7
- app_port: 8501
8
- tags:
9
- - streamlit
10
  pinned: false
11
- short_description: AI explains sentence similarity.
12
  license: mit
13
  ---
14
 
15
- # Welcome to Streamlit!
16
 
17
- Edit `/src/streamlit_app.py` to customize this app to your heart's desire. :heart:
18
 
19
- If you have any questions, checkout our [documentation](https://docs.streamlit.io) and [community
20
- forums](https://discuss.streamlit.io).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ title: Semantic Similarity Explainer
3
+ emoji: πŸ”
4
+ colorFrom: blue
5
+ colorTo: purple
6
+ sdk: streamlit
7
+ sdk_version: 1.28.0
8
+ app_file: app.py
 
9
  pinned: false
 
10
  license: mit
11
  ---
12
 
13
+ # πŸ” Semantic Similarity Explainer with AI
14
 
15
+ This Streamlit app calculates the **semantic similarity** between two sentences using transformer-based embeddings (all-MiniLM-L6-v2) and uses AI to explain why that specific score makes sense.
16
 
17
+ ## Features
18
+
19
+ - **Semantic Similarity Calculation**: Uses the `all-MiniLM-L6-v2` transformer model to generate 384-dimensional embeddings
20
+ - **AI-Powered Explanations**: Leverages OpenRouter API to explain similarity scores in detail
21
+ - **Technical Details**: Shows embedding dimensions, cosine similarity calculations, and vector statistics
22
+ - **Interactive Interface**: Easy-to-use Streamlit interface with real-time calculations
23
+ - **History Tracking**: Keeps track of previous calculations during the session
24
+
25
+ ## How It Works
26
+
27
+ 1. **Input**: Enter two sentences you want to compare
28
+ 2. **Embedding Generation**: The app uses the `all-MiniLM-L6-v2` model to convert sentences into dense vector representations
29
+ 3. **Similarity Calculation**: Computes cosine similarity between the embeddings
30
+ 4. **AI Explanation**: Uses GPT-3.5-turbo via OpenRouter to explain the similarity score
31
+ 5. **Technical Details**: Shows detailed information about the embeddings and calculations
32
+
33
+ ## Usage
34
+
35
+ ### Without API Key
36
+ - You can use the similarity calculation feature without an API key
37
+ - The app will show similarity scores and technical details
38
+ - AI explanations will be skipped
39
+
40
+ ### With OpenRouter API Key
41
+ - Get your API key from [OpenRouter](https://openrouter.ai/keys)
42
+ - Enter it in the sidebar to enable AI explanations
43
+ - The app will provide detailed explanations of why sentences have specific similarity scores
44
+
45
+ ## Examples
46
+
47
+ - **High Similarity**: "The car is fast" vs "The automobile is quick" β†’ ~0.90
48
+ - **Moderate Similarity**: "I love dogs" vs "I hate dogs" β†’ ~0.60 (same topic, opposite sentiment)
49
+ - **Low Similarity**: "The cat sat on the mat" vs "Python is a programming language" β†’ ~0.10
50
+
51
+ ## Technical Details
52
+
53
+ - **Model**: sentence-transformers/all-MiniLM-L6-v2
54
+ - **Embedding Dimensions**: 384
55
+ - **Similarity Metric**: Cosine similarity
56
+ - **AI Model**: GPT-3.5-turbo (via OpenRouter)
57
+
58
+ ## Installation & Local Development
59
+
60
+ ```bash
61
+ # Clone the repository
62
+ git clone <your-repo-url>
63
+ cd semantic-similarity-explainer
64
+
65
+ # Install dependencies
66
+ pip install -r requirements.txt
67
+
68
+ # Run the app
69
+ streamlit run app.py
70
+ ```
71
+
72
+ ## Environment Variables
73
+
74
+ - `OPENROUTER_API_KEY`: Your OpenRouter API key (optional, can also be entered in the UI)
75
+
76
+ ## License
77
+
78
+ MIT License - see LICENSE file for details.