Spaces:
Running
on
T4
Running
on
T4
Daniel Fried
commited on
Commit
•
b72509b
1
Parent(s):
bcb63b8
style
Browse files- modules/app.py +4 -2
- static/frame.html +1 -0
- static/index.html +107 -115
- static/style.css +39 -0
modules/app.py
CHANGED
@@ -9,8 +9,10 @@ if os.path.exists('use_normal_tokenizers'):
|
|
9 |
CUDA = False
|
10 |
else:
|
11 |
import tokenizers_patch
|
12 |
-
BIG_MODEL = True
|
13 |
-
CUDA = True
|
|
|
|
|
14 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
15 |
import json
|
16 |
|
|
|
9 |
CUDA = False
|
10 |
else:
|
11 |
import tokenizers_patch
|
12 |
+
# BIG_MODEL = True
|
13 |
+
# CUDA = True
|
14 |
+
BIG_MODEL = False
|
15 |
+
CUDA = False
|
16 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
17 |
import json
|
18 |
|
static/frame.html
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
<iframe src="index.html"></iframe>
|
static/index.html
CHANGED
@@ -1,6 +1,9 @@
|
|
|
|
1 |
<html>
|
2 |
<head>
|
3 |
-
<
|
|
|
|
|
4 |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
|
5 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.14/ace.min.js"></script>
|
6 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.14/mode-plain_text.min.js"></script>
|
@@ -24,13 +27,14 @@
|
|
24 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.14/mode-sh.min.js"></script>
|
25 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.14/mode-swift.min.js"></script>
|
26 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.14/mode-typescript.min.js"></script>
|
|
|
27 |
</head>
|
28 |
<style type="text/css">
|
29 |
-
body {
|
30 |
font-family: sans-serif;
|
31 |
-
}
|
32 |
-
.leftside {
|
33 |
-
}
|
34 |
.rightside {
|
35 |
width: 30em;
|
36 |
}
|
@@ -85,7 +89,7 @@ label {
|
|
85 |
display: inline-block;
|
86 |
width: 10em;
|
87 |
text-align: right;
|
88 |
-
font-size:
|
89 |
}
|
90 |
#loader_holder_super {
|
91 |
}
|
@@ -115,123 +119,111 @@ label {
|
|
115 |
}
|
116 |
</style>
|
117 |
<body>
|
118 |
-
<div class="
|
119 |
-
|
120 |
-
|
121 |
-
<
|
122 |
-
<p>
|
123 |
-
<p id="examples">
|
124 |
-
<span style="font-weight: bold">Infill Examples:</span>
|
125 |
-
<span><a href='javascript:select_example("class");'>Class generation</a></span>
|
126 |
-
<span><a href='javascript:select_example("type-pred");'>Type prediction</a></span>
|
127 |
-
<span><a href='javascript:select_example("docstring");'>Function to docstring</a></span>
|
128 |
-
<span><a href='javascript:select_example("python-infill2");'>Docstring to function</a></span>
|
129 |
-
<br>
|
130 |
-
<span style="font-weight: bold">Extend Examples:</span>
|
131 |
-
<span><a href='javascript:select_example("javascript");'>JavaScript</a></span>
|
132 |
-
<span><a href='javascript:select_example("javascript");'>JavaScript</a></span>
|
133 |
-
<span><a href='javascript:select_example("jupyter");'>Jupyter</a></span>
|
134 |
-
<span><a href='javascript:select_example("stackoverflow");'>StackOverflow</a></span>
|
135 |
-
<span><a href='javascript:select_example("metadata-conditioning");'>Metadata Conditioning</a></span>
|
136 |
-
<span><a href='javascript:select_example("metadata-prediction");'>Metadata Prediction</a></span>
|
137 |
-
<!-- <span><a href='javascript:select_example("humaneval");'>Docstring->Code</a></span> -->
|
138 |
-
</div>
|
139 |
-
</div>
|
140 |
-
<div class="request">
|
141 |
-
<form id="generate-form">
|
142 |
-
<div class="leftside">
|
143 |
-
<div>
|
144 |
-
<label>Response Length:</label>
|
145 |
-
<input type="range" value="64" min="16" max="256" step="16" class="slider"
|
146 |
-
oninput="this.nextElementSibling.value = this.value" name="length"
|
147 |
-
id='length_slider'>
|
148 |
-
<output class='a' id="length_slider_output">64</output>
|
149 |
-
<div>
|
150 |
-
<label>Temperature:</label>
|
151 |
-
<input type="range" value="0.6" min="0.1" max="1.0" step="0.10" class="slider"
|
152 |
-
oninput="this.nextElementSibling.value = this.value" name="temp"
|
153 |
-
id='temp_slider'
|
154 |
-
>
|
155 |
-
<output class='a' id="temp_slider_output">0.6</output>
|
156 |
</div>
|
157 |
-
<div>
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
<
|
167 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
168 |
</div>
|
|
|
|
|
169 |
<div>
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
<div>
|
176 |
-
|
177 |
-
|
178 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
179 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
180 |
</div>
|
181 |
-
|
182 |
-
</
|
183 |
-
|
184 |
-
<
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
<option value="haskell">Haskell</option>
|
192 |
-
<option value="java">Java</option>
|
193 |
-
<option value="javascript">JavaScript</option>
|
194 |
-
<option value="lua">Lua</option>
|
195 |
-
<option value="objectivec">Objective C</option>
|
196 |
-
<option value="perl">Perl</option>
|
197 |
-
<option value="php">PHP</option>
|
198 |
-
<option value="python">Python</option>
|
199 |
-
<option value="ruby">Ruby</option>
|
200 |
-
<option value="rust">Rust</option>
|
201 |
-
<option value="scala">Scala</option>
|
202 |
-
<option value="sh">Shell</option>
|
203 |
-
<option value="swift">Swift</option>
|
204 |
-
<option value="typescript">Typescript</option>
|
205 |
-
</select>
|
206 |
</div>
|
207 |
-
|
208 |
-
</
|
209 |
-
<
|
210 |
-
<
|
211 |
-
|
212 |
-
|
213 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
214 |
</div>
|
215 |
-
</div>
|
216 |
-
</div>
|
217 |
-
<div id="error"></div>
|
218 |
-
<div id="warning"></div>
|
219 |
-
|
220 |
-
<h3 id="debug-info">More Info</h3>
|
221 |
-
<p>
|
222 |
-
This is a demo interface for <a href="https://github.com/dpfried/incoder/blob/main/paper/InCoder-4-12-22.pdf">InCoder: A Generative Model for Code In-Filling and Synthesis</a>.
|
223 |
-
</p>
|
224 |
-
<p>
|
225 |
-
See <a href="https://sites.google.com/view/incoder-code-models">our project site</a> for more information on these models, including a paper and examples.
|
226 |
-
</p>
|
227 |
-
|
228 |
-
<p>
|
229 |
-
For instructions on setting up and using the models yourself, see <a href="https://github.com/dpfried/incoder/blob/main/README.md">our readme</a>.
|
230 |
-
</p>
|
231 |
-
|
232 |
-
<h3 id="debug-info">Credits</h3>
|
233 |
-
<p>Model development: Daniel Fried*, Armen Aghajanyan*, Jessy Lin, Sida Wang, Eric Wallace, Freda Shi, Ruiqi Zhong, Wen-tau Yih, Luke Zettlemoyer, and Mike Lewis</p>
|
234 |
-
<p>Thanks to Naman Goyal and Stephen Roller for writing the code this was based on. Extensions by Daniel Fried and Sida Wang.</p>
|
235 |
<script type="text/javascript">
|
236 |
// these constants are only used for providing user expectations.
|
237 |
var OVERHEAD = 3;
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
<html>
|
3 |
<head>
|
4 |
+
<meta charset="utf-8"/>
|
5 |
+
<meta name="viewport" contents="width=device-width" />
|
6 |
+
<title>InCoder</title>
|
7 |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
|
8 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.14/ace.min.js"></script>
|
9 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.14/mode-plain_text.min.js"></script>
|
|
|
27 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.14/mode-sh.min.js"></script>
|
28 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.14/mode-swift.min.js"></script>
|
29 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.14/mode-typescript.min.js"></script>
|
30 |
+
<link rel="stylesheet" href="static/style.css">
|
31 |
</head>
|
32 |
<style type="text/css">
|
33 |
+
/* body {
|
34 |
font-family: sans-serif;
|
35 |
+
} */
|
36 |
+
/* .leftside {
|
37 |
+
} */
|
38 |
.rightside {
|
39 |
width: 30em;
|
40 |
}
|
|
|
89 |
display: inline-block;
|
90 |
width: 10em;
|
91 |
text-align: right;
|
92 |
+
font-size: 80%;
|
93 |
}
|
94 |
#loader_holder_super {
|
95 |
}
|
|
|
119 |
}
|
120 |
</style>
|
121 |
<body>
|
122 |
+
<div class="card" id="about">
|
123 |
+
<div class="header"> <h1>InCoder: A Generative Model for Code Infilling and Synthesis</h1> </div>
|
124 |
+
<p>Demo of the 6.7B parameter version of InCoder: a decoder-only Transformer model that can both extend and insert/infill code.</p>
|
125 |
+
<p>Select one of the examples below, or input your own code into the editor. You can type <infill> to mark a location you want the model to insert code at.</p>
|
126 |
+
<p>Click "Extend" to append text at the end of the editor. Click "Infill" to replace all <infill> masks. (Click "Add <infill> mask" to add a mask at the cursor or replace the current selection.) </p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
</div>
|
128 |
+
<div class="card" id="examples">
|
129 |
+
<div id="examples-infill">
|
130 |
+
<span class="softspan">Infill Examples:</span>
|
131 |
+
<br>
|
132 |
+
<span class="softspan"><a href='javascript:select_example("class");'>Class generation</a></span>
|
133 |
+
<span class="softspan"><a href='javascript:select_example("type-pred");'>Type prediction</a></span>
|
134 |
+
<span class="softspan"><a href='javascript:select_example("docstring");'>Function to docstring</a></span>
|
135 |
+
<span class="softspan"><a href='javascript:select_example("python-infill2");'>Docstring to function</a></span>
|
136 |
+
</div>
|
137 |
+
<div id="examples-extend">
|
138 |
+
<span class="softspan">Extend Examples:</span>
|
139 |
+
<br>
|
140 |
+
<span class="softspan"><a href='javascript:select_example("python");'>Python</a></span>
|
141 |
+
<span class="softspan"><a href='javascript:select_example("javascript");'>JavaScript</a></span>
|
142 |
+
<span class="softspan"><a href='javascript:select_example("jupyter");'>Jupyter</a></span>
|
143 |
+
<span class="softspan"><a href='javascript:select_example("stackoverflow");'>StackOverflow</a></span>
|
144 |
+
<span class="softspan"><a href='javascript:select_example("metadata-conditioning");'>Metadata Conditioning</a></span>
|
145 |
+
<span class="softspan"><a href='javascript:select_example("metadata-prediction");'>Metadata Prediction</a></span>
|
146 |
</div>
|
147 |
+
</div>
|
148 |
+
<div class="card" id="controls">
|
149 |
<div>
|
150 |
+
<label>Response Length:</label>
|
151 |
+
<input type="range" value="64" min="16" max="256" step="16" class="slider"
|
152 |
+
oninput="this.nextElementSibling.value = this.value" name="length" id='length_slider'>
|
153 |
+
<output class='a' id="length_slider_output">64</output>
|
154 |
+
</div>
|
155 |
<div>
|
156 |
+
<label>Temperature:</label>
|
157 |
+
<input type="range" value="0.6" min="0.1" max="1.0" step="0.10" class="slider"
|
158 |
+
oninput="this.nextElementSibling.value = this.value" name="temp" id='temp_slider'>
|
159 |
+
<output class='a' id="temp_slider_output">0.6</output>
|
160 |
+
</div>
|
161 |
+
<div id="buttons">
|
162 |
+
<input type="button" value="Extend" id="extend-form-button" />
|
163 |
+
<span style='margin-left:1em'>
|
164 |
+
<input type="button" value="Add <infill> mask" id="insert-mask-button"
|
165 |
+
title="add the infill marker at cursor or selection" />
|
166 |
+
<input type="button" value="Infill" id="infill-form-button" />
|
167 |
+
</span>
|
168 |
+
</div>
|
169 |
</div>
|
170 |
+
<div id="edit-container" class="card">
|
171 |
+
<div id="syntax">
|
172 |
+
<span class="softspan">Syntax:</span>
|
173 |
+
<select name="mode" id="mode">
|
174 |
+
<option value="text">Text</option>
|
175 |
+
<option value="c_cpp">C/C++</option>
|
176 |
+
<option value="csharp">C#</option>
|
177 |
+
<option value="clojure">Clojure</option>
|
178 |
+
<option value="coffee">CoffeeScript</option>
|
179 |
+
<option value="golang">Go</option>
|
180 |
+
<option value="haskell">Haskell</option>
|
181 |
+
<option value="java">Java</option>
|
182 |
+
<option value="javascript">JavaScript</option>
|
183 |
+
<option value="lua">Lua</option>
|
184 |
+
<option value="objectivec">Objective C</option>
|
185 |
+
<option value="perl">Perl</option>
|
186 |
+
<option value="php">PHP</option>
|
187 |
+
<option value="python">Python</option>
|
188 |
+
<option value="ruby">Ruby</option>
|
189 |
+
<option value="rust">Rust</option>
|
190 |
+
<option value="scala">Scala</option>
|
191 |
+
<option value="sh">Shell</option>
|
192 |
+
<option value="swift">Swift</option>
|
193 |
+
<option value="typescript">Typescript</option>
|
194 |
+
</select>
|
195 |
+
</div>
|
196 |
+
<div id="editor"></div>
|
197 |
</div>
|
198 |
+
<div id="loader_holder_super" class="card">
|
199 |
+
<h1>Messages</h1>
|
200 |
+
<div id="loader_holder">
|
201 |
+
<div class="loader"></div>
|
202 |
+
<div>
|
203 |
+
Generation queued, please wait...
|
204 |
+
</div>
|
205 |
+
</div>
|
206 |
+
<div id="error"></div>
|
207 |
+
<div id="warning"></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
208 |
</div>
|
209 |
+
<div id="info" class="card">
|
210 |
+
<h1 id="debug-info">More Info</h3>
|
211 |
+
<p>
|
212 |
+
See <a href="https://sites.google.com/view/incoder-code-models">our project site</a> for more information on
|
213 |
+
these models, including a paper and examples.
|
214 |
+
</p>
|
215 |
+
|
216 |
+
<p>
|
217 |
+
For instructions on setting up and using the models (via HuggingFace transformers), see <a
|
218 |
+
href="https://github.com/dpfried/incoder/blob/main/README.md">our readme</a>.
|
219 |
+
</p>
|
220 |
+
|
221 |
+
<h1 id="debug-info">Credits</h3>
|
222 |
+
<p>Model developed at Facebook AI Research by Daniel Fried*, Armen Aghajanyan*, Jessy Lin, Sida Wang, Eric Wallace, Freda Shi, Ruiqi Zhong,
|
223 |
+
Wen-tau Yih, Luke Zettlemoyer, and Mike Lewis</p>
|
224 |
+
<p>Thanks to Naman Goyal and Stephen Roller for writing the code this was based on. Extensions by Daniel Fried and
|
225 |
+
Sida Wang.</p>
|
226 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
227 |
<script type="text/javascript">
|
228 |
// these constants are only used for providing user expectations.
|
229 |
var OVERHEAD = 3;
|
static/style.css
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
body {
|
2 |
+
padding: 2rem;
|
3 |
+
font-family: -apple-system, BlinkMacSystemFont, "Arial", sans-serif;
|
4 |
+
}
|
5 |
+
|
6 |
+
h1 {
|
7 |
+
font-size: 16px;
|
8 |
+
margin-top: 0;
|
9 |
+
}
|
10 |
+
|
11 |
+
p {
|
12 |
+
color: rgb(107, 114, 128);
|
13 |
+
font-size: 15px;
|
14 |
+
margin-bottom: 10px;
|
15 |
+
margin-top: 5px;
|
16 |
+
}
|
17 |
+
|
18 |
+
button {
|
19 |
+
font-size: 15px;
|
20 |
+
}
|
21 |
+
|
22 |
+
.softspan {
|
23 |
+
color: rgb(127, 134, 148);
|
24 |
+
font-size: 15px;
|
25 |
+
margin-bottom: 10px;
|
26 |
+
margin-top: 5px;
|
27 |
+
}
|
28 |
+
|
29 |
+
.card {
|
30 |
+
max-width: 800px;
|
31 |
+
margin: 0 auto;
|
32 |
+
padding: 16px;
|
33 |
+
border: 1px solid lightgray;
|
34 |
+
border-radius: 16px;
|
35 |
+
}
|
36 |
+
|
37 |
+
.card p:last-child {
|
38 |
+
margin-bottom: 0;
|
39 |
+
}
|