Upload 10 files
Browse files- app.py +48 -0
- config.json +41 -0
- generation_config.json +6 -0
- model.safetensors +3 -0
- olympic_medals.csv +0 -0
- optimizer.pt +3 -0
- rng_state.pth +3 -0
- scheduler.pt +3 -0
- style.css +75 -0
- trainer_state.json +107 -0
app.py
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
2 |
+
import streamlit as st
|
3 |
+
import streamlit_antd_components as sac
|
4 |
+
|
5 |
+
st.set_page_config(layout="wide")
|
6 |
+
|
7 |
+
|
8 |
+
@st.cache_resource
|
9 |
+
class AppModel:
|
10 |
+
def __init__(self):
|
11 |
+
self.tokenizer = AutoTokenizer.from_pretrained("gpt2-medium")
|
12 |
+
self.tokenizer.pad_token = self.tokenizer.eos_token
|
13 |
+
self.model = AutoModelForCausalLM.from_pretrained("./output/model/checkpoint-1000/")
|
14 |
+
|
15 |
+
def generate_plot(self, prompt: str):
|
16 |
+
inputs = self.tokenizer(prompt, return_tensors="pt").to("cpu")
|
17 |
+
outputs = self.model.generate(
|
18 |
+
inputs.input_ids,
|
19 |
+
max_new_tokens=100,
|
20 |
+
do_sample=True,
|
21 |
+
top_k=5,
|
22 |
+
top_p=0.35,
|
23 |
+
temperature= 0.2,
|
24 |
+
num_return_sequences= 1,
|
25 |
+
)
|
26 |
+
output_string = self.tokenizer.batch_decode(outputs)
|
27 |
+
return output_string
|
28 |
+
|
29 |
+
model = AppModel()
|
30 |
+
|
31 |
+
st.title("Welcome to the GPT Olympics generator")
|
32 |
+
prompt = st.text_area("Enter the beginning of your plot...")
|
33 |
+
clicked = st.button("Generate my movie")
|
34 |
+
|
35 |
+
sac.divider(label='label', icon='house', align='center', size='md', color='yellow')
|
36 |
+
|
37 |
+
if clicked:
|
38 |
+
generated_plot = model.generate_plot(prompt)[0]
|
39 |
+
chat_message = st.chat_message("assistant")
|
40 |
+
chat_message.markdown(generated_plot)
|
41 |
+
|
42 |
+
with open('./style.css') as f:
|
43 |
+
css = f.read()
|
44 |
+
st.markdown(f'<style>{css}</style>', unsafe_allow_html=True)
|
45 |
+
|
46 |
+
|
47 |
+
|
48 |
+
|
config.json
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_name_or_path": "gpt2-medium",
|
3 |
+
"activation_function": "gelu_new",
|
4 |
+
"architectures": [
|
5 |
+
"GPT2LMHeadModel"
|
6 |
+
],
|
7 |
+
"attn_pdrop": 0.1,
|
8 |
+
"bos_token_id": 50256,
|
9 |
+
"embd_pdrop": 0.1,
|
10 |
+
"eos_token_id": 50256,
|
11 |
+
"initializer_range": 0.02,
|
12 |
+
"layer_norm_epsilon": 1e-05,
|
13 |
+
"model_type": "gpt2",
|
14 |
+
"n_ctx": 1024,
|
15 |
+
"n_embd": 1024,
|
16 |
+
"n_head": 16,
|
17 |
+
"n_inner": null,
|
18 |
+
"n_layer": 24,
|
19 |
+
"n_positions": 1024,
|
20 |
+
"n_special": 0,
|
21 |
+
"predict_special_tokens": true,
|
22 |
+
"reorder_and_upcast_attn": false,
|
23 |
+
"resid_pdrop": 0.1,
|
24 |
+
"scale_attn_by_inverse_layer_idx": false,
|
25 |
+
"scale_attn_weights": true,
|
26 |
+
"summary_activation": null,
|
27 |
+
"summary_first_dropout": 0.1,
|
28 |
+
"summary_proj_to_labels": true,
|
29 |
+
"summary_type": "cls_index",
|
30 |
+
"summary_use_proj": true,
|
31 |
+
"task_specific_params": {
|
32 |
+
"text-generation": {
|
33 |
+
"do_sample": true,
|
34 |
+
"max_length": 50
|
35 |
+
}
|
36 |
+
},
|
37 |
+
"torch_dtype": "float32",
|
38 |
+
"transformers_version": "4.39.2",
|
39 |
+
"use_cache": true,
|
40 |
+
"vocab_size": 50257
|
41 |
+
}
|
generation_config.json
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_from_model_config": true,
|
3 |
+
"bos_token_id": 50256,
|
4 |
+
"eos_token_id": 50256,
|
5 |
+
"transformers_version": "4.39.2"
|
6 |
+
}
|
model.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d407ab13e27f9da55942399863fc413394ba277e2b1bf30326463059b88335fd
|
3 |
+
size 1419322880
|
olympic_medals.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
optimizer.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:b7e3881f2ece43162ab2569dc81775a14350c423cc46233e67bfa0fd6a094914
|
3 |
+
size 2838821114
|
rng_state.pth
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:da1db5c227c2000e391e1d225e13a38eda71746be2164bab198c44af9ae0882b
|
3 |
+
size 13990
|
scheduler.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:74b67834aacf6f555d713cdb4b053a4620bd2b12a56cc8d1be6b42a81da28112
|
3 |
+
size 1064
|
style.css
ADDED
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
section[data-testid='stSidebar'] {
|
2 |
+
background-color: #d81e1e;
|
3 |
+
flex-shrink: unset !important;
|
4 |
+
}
|
5 |
+
|
6 |
+
@media(hover:hover) and (min-width: 600px) and (max-width: 769px){
|
7 |
+
|
8 |
+
header[data-testid="stHeader"] {
|
9 |
+
display:none;
|
10 |
+
}
|
11 |
+
|
12 |
+
section[data-testid='stSidebar'] {
|
13 |
+
height: 100%;
|
14 |
+
min-width:95px !important;
|
15 |
+
width: 95px !important;
|
16 |
+
margin-left: 305px;
|
17 |
+
position: relative;
|
18 |
+
z-index: 1;
|
19 |
+
top: 0;
|
20 |
+
left: 0;
|
21 |
+
background-color: #111;
|
22 |
+
overflow-x: hidden;
|
23 |
+
transition: 0.5s ease;
|
24 |
+
padding-top: 60px;
|
25 |
+
white-space: nowrap;
|
26 |
+
}
|
27 |
+
|
28 |
+
section[data-testid='stSidebar']:hover{
|
29 |
+
min-width: 330px !important;
|
30 |
+
}
|
31 |
+
|
32 |
+
button[kind="header"] {
|
33 |
+
display: none;
|
34 |
+
}
|
35 |
+
|
36 |
+
div[data-testid="collapsedControl"]{
|
37 |
+
display: none;
|
38 |
+
}
|
39 |
+
|
40 |
+
}
|
41 |
+
|
42 |
+
@media(hover: hover) and (min-width: 769px){
|
43 |
+
|
44 |
+
header[data-testid="stHeader"] {
|
45 |
+
display:none;
|
46 |
+
}
|
47 |
+
|
48 |
+
section[data-testid='stSidebar'] {
|
49 |
+
height: 100%;
|
50 |
+
min-width:95px !important;
|
51 |
+
width: 95px !important;
|
52 |
+
transform:translateX(0px);
|
53 |
+
position: relative;
|
54 |
+
z-index: 1;
|
55 |
+
top: 0;
|
56 |
+
left: 0;
|
57 |
+
background-color: #111;
|
58 |
+
overflow-x: hidden;
|
59 |
+
transition: 0.5s ease;
|
60 |
+
padding-top: 60px;
|
61 |
+
white-space: nowrap;
|
62 |
+
}
|
63 |
+
|
64 |
+
section[data-testid='stSidebar']:hover{
|
65 |
+
min-width: 330px !important;
|
66 |
+
}
|
67 |
+
|
68 |
+
button[kind="header"] {
|
69 |
+
display: none;
|
70 |
+
}
|
71 |
+
|
72 |
+
div[data-testid="collapsedControl"]{
|
73 |
+
display: none;
|
74 |
+
}
|
75 |
+
}
|
trainer_state.json
ADDED
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"best_metric": null,
|
3 |
+
"best_model_checkpoint": null,
|
4 |
+
"epoch": 10.0,
|
5 |
+
"eval_steps": 500,
|
6 |
+
"global_step": 1000,
|
7 |
+
"is_hyper_param_search": false,
|
8 |
+
"is_local_process_zero": true,
|
9 |
+
"is_world_process_zero": true,
|
10 |
+
"log_history": [
|
11 |
+
{
|
12 |
+
"epoch": 1.0,
|
13 |
+
"eval_loss": 2.4529900550842285,
|
14 |
+
"eval_runtime": 3.9942,
|
15 |
+
"eval_samples_per_second": 50.073,
|
16 |
+
"eval_steps_per_second": 6.259,
|
17 |
+
"step": 100
|
18 |
+
},
|
19 |
+
{
|
20 |
+
"epoch": 2.0,
|
21 |
+
"eval_loss": 2.183900833129883,
|
22 |
+
"eval_runtime": 4.5703,
|
23 |
+
"eval_samples_per_second": 43.761,
|
24 |
+
"eval_steps_per_second": 5.47,
|
25 |
+
"step": 200
|
26 |
+
},
|
27 |
+
{
|
28 |
+
"epoch": 3.0,
|
29 |
+
"eval_loss": 2.071335554122925,
|
30 |
+
"eval_runtime": 3.8996,
|
31 |
+
"eval_samples_per_second": 51.287,
|
32 |
+
"eval_steps_per_second": 6.411,
|
33 |
+
"step": 300
|
34 |
+
},
|
35 |
+
{
|
36 |
+
"epoch": 4.0,
|
37 |
+
"eval_loss": 2.011983871459961,
|
38 |
+
"eval_runtime": 6.9041,
|
39 |
+
"eval_samples_per_second": 28.968,
|
40 |
+
"eval_steps_per_second": 3.621,
|
41 |
+
"step": 400
|
42 |
+
},
|
43 |
+
{
|
44 |
+
"epoch": 5.0,
|
45 |
+
"grad_norm": 28.10818099975586,
|
46 |
+
"learning_rate": 1e-05,
|
47 |
+
"loss": 2.123,
|
48 |
+
"step": 500
|
49 |
+
},
|
50 |
+
{
|
51 |
+
"epoch": 5.0,
|
52 |
+
"eval_loss": 1.9926012754440308,
|
53 |
+
"eval_runtime": 10.0553,
|
54 |
+
"eval_samples_per_second": 19.89,
|
55 |
+
"eval_steps_per_second": 2.486,
|
56 |
+
"step": 500
|
57 |
+
},
|
58 |
+
{
|
59 |
+
"epoch": 6.0,
|
60 |
+
"eval_loss": 1.9686007499694824,
|
61 |
+
"eval_runtime": 4.4521,
|
62 |
+
"eval_samples_per_second": 44.922,
|
63 |
+
"eval_steps_per_second": 5.615,
|
64 |
+
"step": 600
|
65 |
+
},
|
66 |
+
{
|
67 |
+
"epoch": 7.0,
|
68 |
+
"eval_loss": 1.9791488647460938,
|
69 |
+
"eval_runtime": 2.9406,
|
70 |
+
"eval_samples_per_second": 68.014,
|
71 |
+
"eval_steps_per_second": 8.502,
|
72 |
+
"step": 700
|
73 |
+
},
|
74 |
+
{
|
75 |
+
"epoch": 8.0,
|
76 |
+
"eval_loss": 1.9794409275054932,
|
77 |
+
"eval_runtime": 2.4017,
|
78 |
+
"eval_samples_per_second": 83.276,
|
79 |
+
"eval_steps_per_second": 10.409,
|
80 |
+
"step": 800
|
81 |
+
},
|
82 |
+
{
|
83 |
+
"epoch": 9.0,
|
84 |
+
"eval_loss": 2.0054731369018555,
|
85 |
+
"eval_runtime": 9.7036,
|
86 |
+
"eval_samples_per_second": 20.611,
|
87 |
+
"eval_steps_per_second": 2.576,
|
88 |
+
"step": 900
|
89 |
+
},
|
90 |
+
{
|
91 |
+
"epoch": 10.0,
|
92 |
+
"grad_norm": 27.559810638427734,
|
93 |
+
"learning_rate": 0.0,
|
94 |
+
"loss": 1.2718,
|
95 |
+
"step": 1000
|
96 |
+
}
|
97 |
+
],
|
98 |
+
"logging_steps": 500,
|
99 |
+
"max_steps": 1000,
|
100 |
+
"num_input_tokens_seen": 0,
|
101 |
+
"num_train_epochs": 10,
|
102 |
+
"save_steps": 500,
|
103 |
+
"total_flos": 248093683974144.0,
|
104 |
+
"train_batch_size": 8,
|
105 |
+
"trial_name": null,
|
106 |
+
"trial_params": null
|
107 |
+
}
|