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를 기반으로 합니다.