update
Browse files
app.py
CHANGED
@@ -59,6 +59,7 @@ st.markdown(text)
|
|
59 |
st.title("2 - Model architecture")
|
60 |
st.markdown("Most code generation models use GPT style architectures trained on code. Some use encoder-decoder architectures such as AlphaCode.")
|
61 |
st.header("Model")
|
|
|
62 |
with col1:
|
63 |
selected_model = st.selectbox(
|
64 |
"Select a code generation model", MODELS, key=2
|
@@ -77,51 +78,53 @@ st.markdown(intro)
|
|
77 |
|
78 |
# Code generation
|
79 |
st.title("4 - Code generation 💻")
|
80 |
-
st.
|
81 |
with col1:
|
|
|
82 |
selected_models = st.multiselect(
|
83 |
"Select code generation models to compare", MODELS, default=["CodeParrot"], key=3
|
84 |
)
|
85 |
-
st.
|
86 |
-
examples = load_examples()
|
87 |
-
example_names = [example["name"] for example in examples]
|
88 |
-
name2id = dict([(name, i) for i, name in enumerate(example_names)])
|
89 |
-
selected_example = st.selectbox(
|
90 |
-
|
91 |
-
)
|
92 |
-
example_text = examples[name2id[selected_example]]["value"]
|
93 |
-
default_length = examples[name2id[selected_example]]["length"]
|
94 |
-
st.
|
95 |
-
temperature = st.slider(
|
96 |
-
|
97 |
-
)
|
98 |
-
max_new_tokens = st.slider(
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
)
|
105 |
-
seed = st.slider(
|
106 |
-
|
107 |
-
)
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
|
|
|
59 |
st.title("2 - Model architecture")
|
60 |
st.markdown("Most code generation models use GPT style architectures trained on code. Some use encoder-decoder architectures such as AlphaCode.")
|
61 |
st.header("Model")
|
62 |
+
col1, col2= st.columns([1,2])
|
63 |
with col1:
|
64 |
selected_model = st.selectbox(
|
65 |
"Select a code generation model", MODELS, key=2
|
|
|
78 |
|
79 |
# Code generation
|
80 |
st.title("4 - Code generation 💻")
|
81 |
+
col1, col2 = st.columns(2)
|
82 |
with col1:
|
83 |
+
st.subheader("Models")
|
84 |
selected_models = st.multiselect(
|
85 |
"Select code generation models to compare", MODELS, default=["CodeParrot"], key=3
|
86 |
)
|
87 |
+
st.subheader("Examples")
|
88 |
+
examples = load_examples()
|
89 |
+
example_names = [example["name"] for example in examples]
|
90 |
+
name2id = dict([(name, i) for i, name in enumerate(example_names)])
|
91 |
+
selected_example = st.selectbox(
|
92 |
+
"Select one of the following examples or implement yours", example_names
|
93 |
+
)
|
94 |
+
example_text = examples[name2id[selected_example]]["value"]
|
95 |
+
default_length = examples[name2id[selected_example]]["length"]
|
96 |
+
st.subheader("Generation settings")
|
97 |
+
temperature = st.slider(
|
98 |
+
"Temperature:", value=0.2, min_value=0.0, step=0.1, max_value=2.0
|
99 |
+
)
|
100 |
+
max_new_tokens = st.slider(
|
101 |
+
"Number of tokens to generate:",
|
102 |
+
value=default_length,
|
103 |
+
min_value=8,
|
104 |
+
step=8,
|
105 |
+
max_value=256,
|
106 |
+
)
|
107 |
+
seed = st.slider(
|
108 |
+
"Random seed:", value=42, min_value=0, step=1, max_value=1000
|
109 |
+
)
|
110 |
+
with col2:
|
111 |
+
gen_prompt = st.text_area(
|
112 |
+
"Generate code with prompt:",
|
113 |
+
value=example_text,
|
114 |
+
height=220,
|
115 |
+
).strip()
|
116 |
+
if st.button("Generate code!"):
|
117 |
+
with st.spinner("Generating code..."):
|
118 |
+
# Create a multiprocessing Pool
|
119 |
+
pool = Pool()
|
120 |
+
generate_parallel = partial(
|
121 |
+
generate_code,
|
122 |
+
gen_prompt=gen_prompt,
|
123 |
+
max_new_tokens=max_new_tokens,
|
124 |
+
temperature=temperature,
|
125 |
+
seed=seed,
|
126 |
+
)
|
127 |
+
output = pool.map(generate_parallel, selected_models)
|
128 |
+
for i in range(len(output)):
|
129 |
+
st.markdown(f"**{selected_models[i]}**")
|
130 |
+
st.code(output[i])
|