remiai3 commited on
Commit
164f469
·
verified ·
1 Parent(s): 70fa492

Upload 2 files

Browse files
Files changed (2) hide show
  1. README.md +53 -0
  2. requirements.txt +6 -0
README.md ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Text Embedding Visualizer
2
+
3
+ This project generates embeddings for short sentences and visualizes them in 2D using PCA and t-SNE.
4
+ It works on **both CPU and GPU laptops** with the same dependencies.
5
+
6
+ ## Install
7
+ ```bash
8
+ ## create a virtual environment
9
+ python -m venv venv
10
+ ## activate the venv
11
+ source ./venv/bin/activate # Windows: ./venv/Scripts/activate
12
+
13
+ pip install -r requirements.txt
14
+
15
+ ***How it Works***
16
+ ## Loads a small dataset of sentences.
17
+ ## Generates embeddings with all-MiniLM-L6-v2.
18
+ ## Reduces dimensions using PCA and t-SNE.
19
+ ## Visualizes them on a 2D plot.
20
+
21
+
22
+ ## Example Output
23
+
24
+ When running the script, you will see:
25
+ followed by **two interactive plots**:
26
+
27
+ 1. **PCA Visualization**
28
+ - Each dot represents a sentence.
29
+ - Sentences with similar meaning appear closer together.
30
+ - Example:
31
+ - "The Eiffel Tower is in France"
32
+ and "The capital of France is Paris"
33
+ are positioned near each other.
34
+
35
+ 2. **t-SNE Visualization**
36
+ - Another dimensionality reduction method that shows natural clusters.
37
+ - Example:
38
+ - "Cats are amazing pets" and "Dogs are loyal companions"
39
+ appear together in one cluster, away from unrelated topics.
40
+
41
+ The plots help you **see how AI models understand meaning** in text.
42
+
43
+ ---
44
+
45
+ ## Sample Sentences Used
46
+ - Artificial intelligence is transforming the world.
47
+ - Cats are amazing pets.
48
+ - The capital of France is Paris.
49
+ - The Eiffel Tower is in France.
50
+ - Deep learning enables image recognition.
51
+ - Dogs are loyal companions.
52
+ - The sun rises in the east.
53
+ - The moon orbits the Earth.
requirements.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ torch==2.2.2
2
+ transformers==4.41.2
3
+ sentence-transformers==3.0.1
4
+ scikit-learn==1.5.0
5
+ matplotlib==3.9.0
6
+ numpy==1.26.4