loubnabnl HF staff commited on
Commit
b8a51c0
β€’
1 Parent(s): 99db140
Files changed (1) hide show
  1. app.py +76 -1
app.py CHANGED
@@ -53,4 +53,79 @@ if selected_task == " ":
53
  st.title("Code Generation Models")
54
  with open("utils/intro.txt", "r") as f:
55
  intro = f.read()
56
- st.markdown(intro)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
  st.title("Code Generation Models")
54
  with open("utils/intro.txt", "r") as f:
55
  intro = f.read()
56
+ st.markdown(intro)
57
+
58
+ elif selected_task == "Pretraining datasets":
59
+ st.title("Pretraining datasets πŸ“š")
60
+ st.markdown(
61
+ f"Preview of some code files from Github repositories in [Github-code dataset]({GITHUB_CODE}):"
62
+ )
63
+ df = pd.read_csv("utils/data_preview.csv")
64
+ st.dataframe(df)
65
+ for model in selected_models:
66
+ with open(f"datasets/{model.lower()}.txt", "r") as f:
67
+ text = f.read()
68
+ st.markdown(f"### {model}")
69
+ st.markdown(text)
70
+
71
+ elif selected_task == "Model architecture":
72
+ st.title("Model architecture")
73
+ for model in selected_models:
74
+ with open(f"architectures/{model.lower()}.txt", "r") as f:
75
+ text = f.read()
76
+ st.markdown(f"## {model}")
77
+ st.markdown(text)
78
+ if model == "InCoder":
79
+ st.image(INCODER_IMG, caption="Figure 1: InCoder training", width=700)
80
+
81
+ elif selected_task == "Model evaluation":
82
+ st.title("Code models evaluation πŸ“Š")
83
+ with open("evaluation/intro.txt", "r") as f:
84
+ intro = f.read()
85
+ st.markdown(intro)
86
+
87
+ elif selected_task == "Code generation":
88
+ st.title("Code generation πŸ’»")
89
+ st.sidebar.header("Examples")
90
+ examples = load_examples()
91
+ example_names = [example["name"] for example in examples]
92
+ name2id = dict([(name, i) for i, name in enumerate(example_names)])
93
+ selected_example = st.sidebar.selectbox(
94
+ "Select one of the following examples or implement yours", example_names
95
+ )
96
+ example_text = examples[name2id[selected_example]]["value"]
97
+ default_length = examples[name2id[selected_example]]["length"]
98
+ st.sidebar.header("Generation settings")
99
+ temperature = st.sidebar.slider(
100
+ "Temperature:", value=0.2, min_value=0.0, step=0.1, max_value=2.0
101
+ )
102
+ max_new_tokens = st.sidebar.slider(
103
+ "Number of tokens to generate:",
104
+ value=default_length,
105
+ min_value=8,
106
+ step=8,
107
+ max_value=256,
108
+ )
109
+ seed = st.sidebar.slider(
110
+ "Random seed:", value=42, min_value=0, step=1, max_value=1000
111
+ )
112
+ gen_prompt = st.text_area(
113
+ "Generate code with prompt:",
114
+ value=example_text,
115
+ height=220,
116
+ ).strip()
117
+ if st.button("Generate code!"):
118
+ with st.spinner("Generating code..."):
119
+ # Create a multiprocessing Pool
120
+ pool = Pool()
121
+ generate_parallel = partial(
122
+ generate_code,
123
+ gen_prompt=gen_prompt,
124
+ max_new_tokens=max_new_tokens,
125
+ temperature=temperature,
126
+ seed=seed,
127
+ )
128
+ output = pool.map(generate_parallel, selected_models)
129
+ for i in range(len(output)):
130
+ st.markdown(f"**{selected_models[i]}**")
131
+ st.code(output[i])