Improve the UI tokenizer

This commit is contained in:
oobabooga 2023-09-15 19:30:44 -07:00
parent c3e4c9fdc2
commit ef04138bc0
4 changed files with 21 additions and 6 deletions

View file

@ -3,8 +3,8 @@ import gradio as gr
from modules import logits, shared, ui, utils
from modules.prompts import count_tokens, load_prompt
from modules.text_generation import (
encode,
generate_reply_wrapper,
get_token_ids,
stop_everything_event
)
from modules.utils import gradio
@ -57,7 +57,7 @@ def create_ui():
with gr.Tab('Tokens'):
shared.gradio['get_tokens-default'] = gr.Button('Get token IDs for the input')
shared.gradio['tokens-default'] = gr.Textbox(lines=23, label='Tokens', elem_classes=['textbox_logits', 'add_scrollbar'])
shared.gradio['tokens-default'] = gr.Textbox(lines=23, label='Tokens', elem_classes=['textbox_logits', 'add_scrollbar', 'monospace'])
def create_event_handlers():
@ -100,4 +100,4 @@ def create_event_handlers():
ui.gather_interface_values, gradio(shared.input_elements), gradio('interface_state')).then(
logits.get_next_logits, gradio('textbox-default', 'interface_state', 'use_samplers-default', 'logits-default'), gradio('logits-default', 'logits-default-previous'), show_progress=False)
shared.gradio['get_tokens-default'].click(lambda x : str(encode(x)[0].tolist()), gradio('textbox-default'), gradio('tokens-default'), show_progress=False)
shared.gradio['get_tokens-default'].click(get_token_ids, gradio('textbox-default'), gradio('tokens-default'), show_progress=False)