| # Text Embedding Visualizer | |
| This project generates embeddings for short sentences and visualizes them in 2D using PCA and t-SNE. | |
| It works on **both CPU and GPU laptops** with the same dependencies. | |
| ## Install | |
| ```bash | |
| ## create a virtual environment | |
| python -m venv venv | |
| ## activate the venv | |
| source ./venv/bin/activate # Windows: ./venv/Scripts/activate | |
| pip install -r requirements.txt | |
| ***How it Works*** | |
| ## Loads a small dataset of sentences. | |
| ## Generates embeddings with all-MiniLM-L6-v2. | |
| ## Reduces dimensions using PCA and t-SNE. | |
| ## Visualizes them on a 2D plot. | |
| ## Example Output | |
| When running the script, you will see: | |
| followed by **two interactive plots**: | |
| 1. **PCA Visualization** | |
| - Each dot represents a sentence. | |
| - Sentences with similar meaning appear closer together. | |
| - Example: | |
| - "The Eiffel Tower is in France" | |
| and "The capital of France is Paris" | |
| are positioned near each other. | |
| 2. **t-SNE Visualization** | |
| - Another dimensionality reduction method that shows natural clusters. | |
| - Example: | |
| - "Cats are amazing pets" and "Dogs are loyal companions" | |
| appear together in one cluster, away from unrelated topics. | |
| The plots help you **see how AI models understand meaning** in text. | |
| --- | |
| ## Sample Sentences Used | |
| - Artificial intelligence is transforming the world. | |
| - Cats are amazing pets. | |
| - The capital of France is Paris. | |
| - The Eiffel Tower is in France. | |
| - Deep learning enables image recognition. | |
| - Dogs are loyal companions. | |
| - The sun rises in the east. | |
| - The moon orbits the Earth. |