tokviz
1.0.0
tokviz /
├── assets/
│ ├── example-deberta-v3-small.png
│ └── example-gpt2.png
├── tokviz /
│ ├── __init__.py
│ └── visualization.py
├── README.md
├── LICENSE
├── setup.py
└── pyproject.toml
tokviz
是一個 Python 函式庫,用於視覺化跨不同語言模型的標記化模式。該程式庫為研究人員、資料科學家和 NLP 愛好者提供了一個綜合平台,幫助他們深入了解不同語言模型如何處理和標記文字。
模型比較:視覺化工具可讓使用者比較多種語言模型的標記化模式,包括 GPT-2、DistilGPT-2 和 DeBERTa-v3-small 等流行模型。透過並排顯示顏色編碼的標記,使用者可以輕鬆識別標記化行為的差異和相似之處。
靈活的輸入:使用者可以輸入自己選擇的任何文本,從而可以跨不同的文本輸入動態探索標記化模式。無論是分析短句子、段落或整個文檔,視覺化工具都會適應使用者的輸入以進行全面分析。
顏色編碼視覺化:令牌根據其屬性和索引進行顏色編碼,提供令牌化模式的視覺直觀表示。這使用戶能夠快速識別文本中的各個標記和模式,從而促進更深入的分析和解釋。
您可以透過 pip 安裝tokviz :
pip install tokviz
from tokviz import token_visualizer
# Define input text
text = "In this example, the get_color function would need to be adjusted based on the specific properties of your model's tokenizer.
You might want to inspect the special tokens, check if a token is part of a special group,
or use any other relevant information provided by the tokenizer.
Keep in mind that the color logic may vary depending on the model,
so you need to tailor it to your specific use case."
# Compare tokenization across different language models
token_visualizer ( text , models = [ 'microsoft/deberta-v3-small' , 'openai-community/gpt2' ])
這將使用指定的語言模型來視覺化輸入文字的標記化模式。您可以將模型名稱或識別碼清單傳遞給 models 參數。預設情況下,它將標記化與 GPT-2 模型進行比較。
該程式庫基於筆記本LLM Tokenizer Visualizer