Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,26 +2,30 @@ from transformers import AutoTokenizer
|
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
|
| 5 |
-
def load_tokenizers()
|
|
|
|
|
|
|
|
|
|
| 6 |
gpt2_tokenizer = AutoTokenizer.from_pretrained("gpt2")
|
| 7 |
gpt_neox_tokenizer = AutoTokenizer.from_pretrained("EleutherAI/gpt-neox-20b")
|
| 8 |
-
llama_tokenizer = AutoTokenizer.from_pretrained("hf-internal-testing/llama-tokenizer")
|
| 9 |
falcon_tokenizer = AutoTokenizer.from_pretrained("tiiuae/falcon-7b")
|
| 10 |
phi2_tokenizer = AutoTokenizer.from_pretrained("microsoft/phi-2")
|
| 11 |
t5_tokenizer = AutoTokenizer.from_pretrained("google/flan-t5-xxl")
|
| 12 |
-
|
| 13 |
|
| 14 |
|
| 15 |
def tokenize(input_text):
|
|
|
|
|
|
|
|
|
|
| 16 |
gpt2_tokens = gpt2_tokenizer(input_text, add_special_tokens=True)["input_ids"]
|
| 17 |
gpt_neox_tokens = gpt_neox_tokenizer(input_text, add_special_tokens=True)["input_ids"]
|
| 18 |
-
llama_tokens = llama_tokenizer(input_text, add_special_tokens=True)["input_ids"]
|
| 19 |
falcon_tokens = falcon_tokenizer(input_text, add_special_tokens=True)["input_ids"]
|
| 20 |
phi2_tokens = phi2_tokenizer(input_text, add_special_tokens=True)["input_ids"]
|
| 21 |
t5_tokens = t5_tokenizer(input_text, add_special_tokens=True)["input_ids"]
|
| 22 |
-
|
| 23 |
|
| 24 |
-
return f"GPT-2/GPT-J: {len(gpt2_tokens)}\nGPT-NeoX: {len(gpt_neox_tokens)}\
|
| 25 |
|
| 26 |
|
| 27 |
if __name__ == "__main__":
|
|
|
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
|
| 5 |
+
def load_tokenizers():
|
| 6 |
+
llama1_tokenizer = AutoTokenizer.from_pretrained("huggyllama/llama-7b")
|
| 7 |
+
llama2_tokenizer = AutoTokenizer.from_pretrained("TheBloke/Llama-2-7B-fp16")
|
| 8 |
+
mistral_tokenizer = AutoTokenizer.from_pretrained("mistralai/Mistral-7B-v0.1")
|
| 9 |
gpt2_tokenizer = AutoTokenizer.from_pretrained("gpt2")
|
| 10 |
gpt_neox_tokenizer = AutoTokenizer.from_pretrained("EleutherAI/gpt-neox-20b")
|
|
|
|
| 11 |
falcon_tokenizer = AutoTokenizer.from_pretrained("tiiuae/falcon-7b")
|
| 12 |
phi2_tokenizer = AutoTokenizer.from_pretrained("microsoft/phi-2")
|
| 13 |
t5_tokenizer = AutoTokenizer.from_pretrained("google/flan-t5-xxl")
|
| 14 |
+
|
| 15 |
|
| 16 |
|
| 17 |
def tokenize(input_text):
|
| 18 |
+
llama1_tokens = llama1_tokenizer(input_text, add_special_tokens=True)["input_ids"]
|
| 19 |
+
llama2_tokens = llama2_tokenizer(input_text, add_special_tokens=True)["input_ids"]
|
| 20 |
+
mistral_tokens = mistral_tokenizer(input_text, add_special_tokens=True)["input_ids"]
|
| 21 |
gpt2_tokens = gpt2_tokenizer(input_text, add_special_tokens=True)["input_ids"]
|
| 22 |
gpt_neox_tokens = gpt_neox_tokenizer(input_text, add_special_tokens=True)["input_ids"]
|
|
|
|
| 23 |
falcon_tokens = falcon_tokenizer(input_text, add_special_tokens=True)["input_ids"]
|
| 24 |
phi2_tokens = phi2_tokenizer(input_text, add_special_tokens=True)["input_ids"]
|
| 25 |
t5_tokens = t5_tokenizer(input_text, add_special_tokens=True)["input_ids"]
|
| 26 |
+
|
| 27 |
|
| 28 |
+
return f"LLaMa-1: {len(llama1_tokens)}\nLLaMa-2: {len(llama2_tokens)}\nMistral: {len(mistral_tokens)}GPT-2/GPT-J: {len(gpt2_tokens)}\nGPT-NeoX: {len(gpt_neox_tokens)}\nFalcon: {len(falcon_tokens)}\nPhi-2: {len(phi2_tokens)}\nT5: {len(t5_tokens)}"
|
| 29 |
|
| 30 |
|
| 31 |
if __name__ == "__main__":
|