File size: 2,634 Bytes
a87d429
 
4417d96
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a87d429
 
 
 
 
 
 
 
c41f655
 
a87d429
 
 
 
 
 
6faa33e
a87d429
 
 
 
6faa33e
c41f655
a87d429
 
6faa33e
b40a379
a87d429
6faa33e
 
 
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59

ascii_art = r"""
.
                                             _..--------.._
   ________________________              _.-e        ||    e-._
 /'                    \ ||``\         /'    \\  |      |  |   `\
|:    ===               -||:  )      /'   \   _.--eeee--._     / `\
 \.____________________/_||../     /'  \    /e            e\ /  /  `\
    |       |                     ||    \ /'     \||  |/    `\       \
    |    || `\     ___-----------/e\  \  /    \           /   \  /    \
     \    \\  \.-ee   \  |  /   /|  | - |   \   .-eeee-.    /  \     - ;
     |           \  \     |  _/' |O |  |e\ __./'        `\   _  | - _  |
     |O    /____________..--e [] |__|- | [] ..   .---._   |  -  | _   _|
     |   ===____________ --|]=====__|  | [] ..  ( D>   )  |  _  |  _  =|
     |O    \  /    /    ee--. [] |  | -| []__    `---'e   |  _  |  -  e|
     |           /   /    |  `\  |O |  |_/   `\          /      | -    |
     /    //  .-.__   / |   \  `\|  | _ |   /  `-.____.-'   \  /    \  ;
    |    ||  /     eee------------\_/     \   /            \   /      /
   _|_______|______________       || /    \      /|  | |\    /  \    /
   _|_______|______________       || /    \      /|  | |\    /  \    /
 /'                    \ ||``\     \   / / `\_             /'  \    /
|:   ===                -||:  )     `\        e-__    __.-e \  \  /'
 \.____________________/_||../        `\  /   /   eeee |        /'
                                        `-._     |  ||    \ _.-'
                                            e-..________..-e

This ASCII pic can be found at
https://asciiart.website/index.php?art=television/star%20trek
"""

from model import LLM
import streamlit as st
import streamlit_scrollable_textbox as stx

st.text(ascii_art)

# with st.spinner("Please wait... loading model"):
llm = LLM()

demo_text = """DATA: The ship has gone into warp, sir.
RIKER: Who gave the command?
DATA: Apparently no one. Helm and navigation controls are not functioning. Our speed is now warp seven-point-three and holding.
PICARD: Picard to Engineering. Mister La Forge, what's going on down there?
"""
text = st.text_area("First few lines of the script:", demo_text, height=300)

col1, col2 = st.columns(2)

with col1:
    temp = st.slider('Temperature', 0.0, 1.0, 1.0, 0.1)
    max_len = st.number_input('Max new tokens', min_value=1, max_value=2048, value=128)

with col2:
    top_p = st.slider('p', 0.0, 1.0, 0.95, 0.1)
    top_k = st.slider('k', 1, 100, 2, 5)

if st.button("Generate"):
    with st.spinner("Generating text..."):
        stx.scrollableTextbox(llm.generate(text, max_len, temp, top_k, top_p), height=400)