Spaces:
Runtime error
Runtime error
reshinthadithyan
commited on
Commit
·
226c1ac
1
Parent(s):
991236b
adding app.py
Browse files
app.py
CHANGED
|
@@ -11,6 +11,19 @@ def load_model_and_tokenizer(model_name):
|
|
| 11 |
|
| 12 |
tokenizer,model = load_model_and_tokenizer(MODEL_NAME)
|
| 13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
st.set_page_config(
|
| 15 |
page_title= "Code Representation Learning",
|
| 16 |
initial_sidebar_state= "expanded"
|
|
@@ -19,18 +32,8 @@ st.sidebar.title("Code Representation Learning")
|
|
| 19 |
workflow = st.sidebar.selectbox('select a task', ['Bash Synthesis'])
|
| 20 |
if workflow == "Bash Synthesis":
|
| 21 |
st.title("Program Synthesis for Bash")
|
| 22 |
-
|
| 23 |
-
output_diction = {}
|
| 24 |
button = st.button("synthesize")
|
| 25 |
if button:
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
# Abstract
|
| 29 |
-
with st.beta_expander("Abstract"):
|
| 30 |
-
st.write(output_diction["abstract"])
|
| 31 |
-
with st.beta_expander("Influencing Citations"):
|
| 32 |
-
st.write(output_diction["influenital_citations"])
|
| 33 |
-
with st.beta_expander("Citation Graph"):
|
| 34 |
-
print("")
|
| 35 |
-
elif workflow == "Rebuttal Analysis":
|
| 36 |
-
st.title("Rebuttal Analysis")
|
|
|
|
| 11 |
|
| 12 |
tokenizer,model = load_model_and_tokenizer(MODEL_NAME)
|
| 13 |
|
| 14 |
+
MAX_TOKS = 128
|
| 15 |
+
MAX_NEW_TOKS = 128
|
| 16 |
+
def generate_text(prompt):
|
| 17 |
+
inputs = tokenizer(prompt, truncation=True, return_tensors="pt")
|
| 18 |
+
output_seq = model.generate(
|
| 19 |
+
input_ids=inputs.input_ids, max_length=MAX_TOKS,
|
| 20 |
+
max_new_tokens=MAX_NEW_TOKS,
|
| 21 |
+
do_sample=True, temperature=0.8,
|
| 22 |
+
num_return_sequences=1
|
| 23 |
+
)
|
| 24 |
+
|
| 25 |
+
outputs = tokenizer.batch_decode(output_seq, skip_special_tokens=False)
|
| 26 |
+
return outputs
|
| 27 |
st.set_page_config(
|
| 28 |
page_title= "Code Representation Learning",
|
| 29 |
initial_sidebar_state= "expanded"
|
|
|
|
| 32 |
workflow = st.sidebar.selectbox('select a task', ['Bash Synthesis'])
|
| 33 |
if workflow == "Bash Synthesis":
|
| 34 |
st.title("Program Synthesis for Bash")
|
| 35 |
+
prompt = st.text_input("Natural Language prompt ","list all the files in the directory 'data\' ")
|
|
|
|
| 36 |
button = st.button("synthesize")
|
| 37 |
if button:
|
| 38 |
+
generated_text = generate_text(prompt)
|
| 39 |
+
st.write(generated_text)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|