Spaces:
Runtime error
Runtime error
File size: 680 Bytes
422fadf e8a902a 422fadf f7e0fea bd94b19 f003591 f7e0fea 422fadf f003591 4e0b8ed e48d20b 8b7fa33 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
import streamlit as st
from tokenizers.tools import EncodingVisualizer
from transformers import AutoTokenizer
st.set_page_config(page_title="BigScience Tokenizer", page_icon='👩💻', layout="wide")
tokenizer = AutoTokenizer.from_pretrained('bigscience/tokenizer', use_auth_token=st.secrets["AUTH_TOKEN"])
visualizer = EncodingVisualizer(tokenizer=tokenizer._tokenizer, default_to_notebook=False)
text = st.text_area(label="", placeholder="Text to tokenize")
button_clicked = st.button("Tokenize")
if text or button_clicked:
st.write(f"The input was split into {len(tokenizer.tokenize(text))} tokens.")
st.components.v1.html(visualizer(text), height=1500)
|