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