Hub documentation
Embedding Atlas
Embedding Atlas
Embedding Atlas์ ๋๊ท๋ชจ ์๋ฒ ๋ฉ ๊ณต๊ฐ์ ํ์ํ๊ธฐ ์ํ ์ธํฐ๋ํฐ๋ธ ์๊ฐํ ๋๊ตฌ์ ๋๋ค. ์๋ฒ ๋ฉ๊ณผ ๊ด๋ จ ๋ฉํ๋ฐ์ดํฐ๋ฅผ ํจ๊ป ์๊ฐํํ๊ณ ํฌ๋ก์ค ํํฐ๋ง ๋ฐ ๊ฒ์ํ ์ ์์ด, ๊ณ ์ฐจ์ ๋ฐ์ดํฐ์ ํจํด๊ณผ ๊ด๊ณ๋ฅผ ์ดํดํ๋ ๋ฐ ๋์์ด ๋ฉ๋๋ค. ๋ชจ๋ ๊ณ์ฐ์ ์ฌ์ฉ์์ ์ปดํจํฐ์์ ์ํ๋๋ฏ๋ก ๋ฐ์ดํฐ์ ํ๋ผ์ด๋ฒ์์ ๋ณด์์ ๋ณด์ฅํฉ๋๋ค.
Static Space๋ก ํธ์คํ ๋ MegaScience ๋ฐ์ดํฐ์ ์ ๋ํ ์์ ์ํ๋ผ์ค๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค:
์ฃผ์ ๊ธฐ๋ฅ
- ์ธํฐ๋ํฐ๋ธ ํ์: ์๋ฐฑ๋ง ๊ฐ์ ์๋ฒ ๋ฉ์ ๋งค๋๋ฝ๊ณ ๋ฐ์์ฑ์ด ์ข์ ์๊ฐํ๋ก ํ์
- ๋ธ๋ผ์ฐ์ ๊ธฐ๋ฐ ๊ณ์ฐ: ๋ฐ์ดํฐ๋ฅผ ์ธ๋ถ ์๋ฒ๋ก ์ ์กํ์ง ์๊ณ ๋ก์ปฌ์์ ์๋ฒ ๋ฉ๊ณผ ํ๋ก์ ์ ์ ๊ณ์ฐํฉ๋๋ค
- ํฌ๋ก์ค ํํฐ๋ง: ์ฌ๋ฌ ๋ฉํ๋ฐ์ดํฐ ์ด์ ๊ฑธ์ณ ๋ฐ์ดํฐ๋ฅผ ์ฐ๊ฒฐํ๊ณ ํํฐ๋ง
- ๊ฒ์ ๊ธฐ๋ฅ: ์ฃผ์ด์ง ์ฟผ๋ฆฌ ๋๋ ๊ธฐ์กด ํญ๋ชฉ๊ณผ ์ ์ฌํ ๋ฐ์ดํฐ ํฌ์ธํธ๋ฅผ ์ฐพ์ต๋๋ค
- ๋ค์ํ ํตํฉ ์ต์ : ๋ช ๋ น์ค, Jupyter ์์ ฏ ๋๋ ์น ์ธํฐํ์ด์ค๋ฅผ ํตํด ์ฌ์ฉ
ํ์ ์กฐ๊ฑด
๋จผ์ , Embedding Atlas๋ฅผ ์ค์นํฉ๋๋ค:
pip install embedding-atlas
Hugging Face Hub์์ ๋น๊ณต๊ฐ ๋ฐ์ดํฐ์ ์ ๋ก๋ํ ๊ณํ์ด๋ผ๋ฉด Hugging Face ๊ณ์ ์ผ๋ก ๋ก๊ทธ์ธํด์ผ ํฉ๋๋ค:
hf auth login
Hub์์ ๋ฐ์ดํฐ์ ๋ก๋
Embedding Atlas์ Hugging Face Hub์ ์ํํ๊ฒ ํตํฉ๋์ด, ๋ชจ๋ ๋ฐ์ดํฐ์ ์ ์๋ฒ ๋ฉ์ ์ง์ ์๊ฐํํ ์ ์์ต๋๋ค.
๋ช ๋ น์ค ์ฌ์ฉ
Hugging Face ๋ฐ์ดํฐ์ ์ ์๊ฐํํ๋ ๊ฐ์ฅ ๊ฐ๋จํ ๋ฐฉ๋ฒ์ ์ปค๋งจ๋ ๋ผ์ธ ์ธํฐํ์ด์ค๋ฅผ ์ฌ์ฉํ๋ ๊ฒ์ ๋๋ค. IMDB ๋ฐ์ดํฐ์ ์ผ๋ก ์๋ํด ๋ณด์ธ์:
# 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์์ฒด ๋ฐ์ดํฐ์ ์ ๊ฒฝ์ฐ ๋์ผํ ํจํด์ ์ฌ์ฉํ์ธ์:
# 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"Python๊ณผ Jupyter ์ฌ์ฉ
Jupyter ๋ ธํธ๋ถ์์ Embedding Atlas๋ฅผ ์ฌ์ฉํ์ฌ ์ธํฐ๋ํฐ๋ธ ํ์์ ์ํํ ์๋ ์์ต๋๋ค:
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์์ฒด ๋ฐ์ดํฐ์ ์ ๊ฒฝ์ฐ:
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์ฌ์ ๊ณ์ฐ๋ ์๋ฒ ๋ฉ ์์ ํ๊ธฐ
pre-computed ์๋ฒ ๋ฉ์ด ํฌํจ๋ ๋ฐ์ดํฐ์ ์ด ์๋ ๊ฒฝ์ฐ, ์ด๋ฅผ ์ง์ ๋ก๋ํ ์ ์์ต๋๋ค:
# 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"์๋ฒ ๋ฉ ์ฌ์ฉ์ ์ ์
Embedding Atlas์ ๊ธฐ๋ณธ์ ์ผ๋ก SentenceTransformers๋ฅผ ์ฌ์ฉํ์ง๋ง ์ฌ์ฉ์ ์ ์ ์๋ฒ ๋ฉ ๋ชจ๋ธ์ ์ง์ํฉ๋๋ค:
# 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-codeUMAP ํฌ์ ๋งค๊ฐ๋ณ์
ํน์ ์ฌ์ฉ ์ฌ๋ก์ ๋ง๊ฒ ์ฐจ์ ์ถ์๋ฅผ ๋ฏธ์ธ ์กฐ์ ํ์ธ์:
embedding-atlas stanfordnlp/imdb \
--text "text" \
--umap-n-neighbors 30 \
--umap-min-dist 0.1 \
--umap-metric "cosine"์ฌ์ฉ ์ฌ๋ก
ํ ์คํธ ๋ฐ์ดํฐ์ ํ์
ํด๋ฌ์คํฐ, ์ด์์น, ํจํด์ ์๋ณํ๊ธฐ ์ํด ํ ์คํธ ์ฝํผ์ค๋ฅผ ์๊ฐํํ๊ณ ํ์ํฉ๋๋ค:
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