File size: 571 Bytes
be331b6
a0ba8b5
be331b6
 
a0ba8b5
 
 
 
 
be331b6
 
 
 
a0ba8b5
be331b6
 
 
 
 
 
a0ba8b5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import gradio as gr
import pandas as pd

def topn_tokens(sequence, n):
    chars = list(sequence)
    n_column = [n] * len(chars)  # Create a column with the chosen integer repeated
    df = pd.DataFrame({'Character': chars, 'N': n_column})  # Create the DataFrame
    return df

demo = gr.Interface(
    topn_tokens,
    [
        "text",
        gr.Dropdown([int(i) for i in range(1, 21)]),  # Dropdown with numbers from 1 to 20
    ],
    "dataframe",
    description="Choose a number between 1-20 to display n tokens",
)

if __name__ == "__main__":
    demo.launch()