Spaces:
Running
Running
File size: 901 Bytes
98985f3 b5dfd52 98985f3 b5dfd52 60a0592 b5dfd52 60a0592 b5dfd52 98985f3 b5dfd52 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
from transformers import AutoTokenizer
import gradio as gr
gpt2_tokenizer = AutoTokenizer.from_pretrained("gpt2")
gptj_tokenizer = AutoTokenizer.from_pretrained("EleutherAI/gpt-j-6b")
gpt_neox_tokenizer = AutoTokenizer.from_pretrained("EleutherAI/gpt-neox-20b")
llama_tokenizer = AutoTokenizer.from_pretrained("hf-internal-testing/llama-tokenizer")
def tokenize(input_text):
gpt2_tokens = gpt2_tokenizer(input_text)["input_ids"]
gptj_tokens = gptj_tokenizer(input_text)["input_ids"]
gpt_neox_tokens = gpt_neox_tokenizer(input_text)["input_ids"]
llama_tokens = llama_tokenizer(input_text)["input_ids"]
return f"""Number of tokens.
GPT-2: {len(gpt2_tokens)}
GPT-J: {len(gptj_tokens)}
GPT-NeoX: {len(gpt_neox_tokens)}
LLaMa: {len(llama_tokens)}
"""
iface = gr.Interface(fn=tokenize, inputs=gr.inputs.Textbox(lines=7), outputs="text")
iface.launch() |