-
Notifications
You must be signed in to change notification settings - Fork 374
Add Embedding Atlas to dataset library integrations #1870
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
bb48da1
Add Embedding Atlas to dataset library integrations
davanstrien a5c162b
Remove visualization image from Embedding Atlas documentation
davanstrien 70f6e9f
Update docs/hub/datasets-embedding-atlas.md
davanstrien 1554a48
Update docs/hub/datasets-embedding-atlas.md
davanstrien 67a46fa
simplify examples
davanstrien File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,164 @@ | ||
| # Embedding Atlas | ||
|
|
||
| [Embedding Atlas](https://apple.github.io/embedding-atlas/) is an interactive visualization tool for exploring large embedding spaces. It enables you to visualize, cross-filter, and search embeddings alongside associated metadata, helping you understand patterns and relationships in high-dimensional data. All computation happens in your computer, ensuring your data remains private and secure. | ||
|
|
||
| ## Key Features | ||
|
|
||
| - **Interactive exploration**: Navigate through millions of embeddings with smooth, responsive visualization | ||
| - **Browser-based computation**: Compute embeddings and projections locally without sending data to external servers | ||
| - **Cross-filtering**: Link and filter data across multiple metadata columns | ||
| - **Search capabilities**: Find similar data points to a given query or existing item | ||
| - **Multiple integration options**: Use via command line, Jupyter widgets, or web interface | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| First, install Embedding Atlas: | ||
|
|
||
| ```bash | ||
| pip install embedding-atlas | ||
| ``` | ||
|
|
||
| If you plan to load private datasets from the Hugging Face Hub, you'll also need to [login with your Hugging Face account](/docs/huggingface_hub/quick-start#login): | ||
|
|
||
| ```bash | ||
| hf auth login | ||
| ``` | ||
|
|
||
| ## Loading Datasets from the Hub | ||
|
|
||
| Embedding Atlas provides seamless integration with the Hugging Face Hub, allowing you to visualize embeddings from any dataset directly. | ||
|
|
||
| ### Using the Command Line | ||
|
|
||
| The simplest way to visualize a Hugging Face dataset is through the command line interface. Try it with the IMDB dataset: | ||
|
|
||
| ```bash | ||
| # Load the IMDB dataset from the Hub | ||
| embedding-atlas stanfordnlp/imdb | ||
|
|
||
| # Specify the text column for embedding computation | ||
| embedding-atlas stanfordnlp/imdb --text "text" | ||
|
|
||
| # Load only a sample for faster exploration | ||
| embedding-atlas stanfordnlp/imdb --text "text" --sample 5000 | ||
| ``` | ||
|
|
||
| For your own datasets, use the same pattern: | ||
|
|
||
| ```bash | ||
| # Load your dataset from the Hub | ||
| embedding-atlas username/dataset-name | ||
|
|
||
| # Load multiple splits | ||
| embedding-atlas username/dataset-name --split train --split test | ||
|
|
||
| # Specify custom text column | ||
| embedding-atlas username/dataset-name --text "content" | ||
| ``` | ||
|
|
||
| ### Using Python and Jupyter | ||
|
|
||
| You can also use Embedding Atlas in Jupyter notebooks for interactive exploration: | ||
|
|
||
| ```python | ||
| from embedding_atlas.widget import EmbeddingAtlasWidget | ||
| from datasets import load_dataset | ||
| import pandas as pd | ||
|
|
||
| # Load the IMDB dataset from Hugging Face Hub | ||
| dataset = load_dataset("stanfordnlp/imdb", split="train[:5000]") | ||
|
|
||
| # Convert to pandas DataFrame | ||
| df = dataset.to_pandas() | ||
|
|
||
| # Create interactive widget | ||
| widget = EmbeddingAtlasWidget(df) | ||
| widget | ||
davanstrien marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ``` | ||
|
|
||
| For your own datasets: | ||
|
|
||
| ```python | ||
| from embedding_atlas.widget import EmbeddingAtlasWidget | ||
| from datasets import load_dataset | ||
| import pandas as pd | ||
|
|
||
| # Load your dataset from the Hub | ||
| dataset = load_dataset("username/dataset-name", split="train") | ||
| df = dataset.to_pandas() | ||
|
|
||
| # Create interactive widget | ||
| widget = EmbeddingAtlasWidget(df) | ||
| widget | ||
| ``` | ||
|
|
||
| ### Working with Pre-computed Embeddings | ||
|
|
||
| If you have datasets with pre-computed embeddings, you can load them directly: | ||
|
|
||
| ```bash | ||
| # Load dataset with pre-computed coordinates | ||
| embedding-atlas username/dataset-name \ | ||
| --x "embedding_x" \ | ||
| --y "embedding_y" | ||
|
|
||
| # Load with pre-computed nearest neighbors | ||
| embedding-atlas username/dataset-name \ | ||
| --neighbors "neighbors_column" | ||
| ``` | ||
|
|
||
| ## Customizing Embeddings | ||
|
|
||
| Embedding Atlas uses [SentenceTransformers](https://huggingface.co/sentence-transformers) by default but supports custom embedding models: | ||
|
|
||
| ```bash | ||
| # Use a specific embedding model | ||
| embedding-atlas stanfordnlp/imdb \ | ||
| --text "text" \ | ||
| --model "sentence-transformers/all-MiniLM-L6-v2" | ||
|
|
||
| # For models requiring remote code execution | ||
| embedding-atlas username/dataset-name \ | ||
| --model "custom/model" \ | ||
| --trust-remote-code | ||
| ``` | ||
|
|
||
| ### UMAP Projection Parameters | ||
|
|
||
| Fine-tune the dimensionality reduction for your specific use case: | ||
|
|
||
| ```bash | ||
| embedding-atlas stanfordnlp/imdb \ | ||
| --text "text" \ | ||
| --umap-n-neighbors 30 \ | ||
| --umap-min-dist 0.1 \ | ||
| --umap-metric "cosine" | ||
| ``` | ||
|
|
||
| ## Use Cases | ||
|
|
||
| ### Exploring Text Datasets | ||
|
|
||
| Visualize and explore text corpora to identify clusters, outliers, and patterns: | ||
|
|
||
| ```python | ||
| from embedding_atlas.widget import EmbeddingAtlasWidget | ||
| from datasets import load_dataset | ||
| import pandas as pd | ||
|
|
||
| # Load a text classification dataset | ||
| dataset = load_dataset("stanfordnlp/imdb", split="train[:5000]") | ||
| df = dataset.to_pandas() | ||
|
|
||
| # Visualize with metadata | ||
| widget = EmbeddingAtlasWidget(df) | ||
| widget | ||
| ``` | ||
|
|
||
|
|
||
| ## Additional Resources | ||
|
|
||
| - [Embedding Atlas GitHub Repository](https://github.com/apple/embedding-atlas) | ||
| - [Official Documentation](https://apple.github.io/embedding-atlas/) | ||
| - [Interactive Demo](https://apple.github.io/embedding-atlas/upload/) | ||
davanstrien marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| - [Command Line Reference](https://apple.github.io/embedding-atlas/tool.html) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.