Spaces:
Runtime error
Runtime error
Daniel Fried
commited on
Commit
·
78ec172
1
Parent(s):
44efa8c
add TF docstring example
Browse files- static/index.html +28 -2
static/index.html
CHANGED
|
@@ -134,9 +134,11 @@ label {
|
|
| 134 |
<span class="softspan">Infill Examples:</span>
|
| 135 |
<br>
|
| 136 |
<span class="softspan"><a href='javascript:select_example("type-pred");'>Type prediction</a></span>
|
| 137 |
-
<span class="softspan"><a href='javascript:select_example("multi-region");'>
|
| 138 |
-
<span class="softspan"><a href='javascript:select_example("docstring");'>Function to docstring</a></span>
|
|
|
|
| 139 |
<span class="softspan"><a href='javascript:select_example("python-infill2");'>Docstring to function</a></span>
|
|
|
|
| 140 |
<span class="softspan"><a href='javascript:select_example("class");'>Class generation</a></span>
|
| 141 |
</div>
|
| 142 |
<div id="examples-extend">
|
|
@@ -282,6 +284,30 @@ def <infill>
|
|
| 282 |
"temperature": 0.2,
|
| 283 |
"mode": "python"
|
| 284 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 285 |
"docstring": {
|
| 286 |
"prompt":
|
| 287 |
`<| file ext=.py |>
|
|
|
|
| 134 |
<span class="softspan">Infill Examples:</span>
|
| 135 |
<br>
|
| 136 |
<span class="softspan"><a href='javascript:select_example("type-pred");'>Type prediction</a></span>
|
| 137 |
+
<span class="softspan"><a href='javascript:select_example("multi-region");'>Docstring to function</a></span>
|
| 138 |
+
<span class="softspan"><a href='javascript:select_example("docstring-2");'>Function to docstring</a></span>
|
| 139 |
+
<!--
|
| 140 |
<span class="softspan"><a href='javascript:select_example("python-infill2");'>Docstring to function</a></span>
|
| 141 |
+
-->
|
| 142 |
<span class="softspan"><a href='javascript:select_example("class");'>Class generation</a></span>
|
| 143 |
</div>
|
| 144 |
<div id="examples-extend">
|
|
|
|
| 284 |
"temperature": 0.2,
|
| 285 |
"mode": "python"
|
| 286 |
},
|
| 287 |
+
"docstring-2": {
|
| 288 |
+
"prompt":
|
| 289 |
+
`def _minimize_in_graph(build_loss_fn, num_steps=200, optimizer=None):
|
| 290 |
+
"""
|
| 291 |
+
<infill>
|
| 292 |
+
"""
|
| 293 |
+
optimizer = tf.compat.v1.train.AdamOptimizer(
|
| 294 |
+
0.1) if optimizer is None else optimizer
|
| 295 |
+
|
| 296 |
+
def train_loop_body(step):
|
| 297 |
+
train_op = optimizer.minimize(
|
| 298 |
+
build_loss_fn if tf.executing_eagerly() else build_loss_fn())
|
| 299 |
+
return tf.tuple(tensors=[tf.add(step, 1)], control_inputs=[train_op])
|
| 300 |
+
|
| 301 |
+
minimize_op = tf.compat.v1.while_loop(
|
| 302 |
+
cond=lambda step: step < num_steps,
|
| 303 |
+
body=train_loop_body,
|
| 304 |
+
loop_vars=[tf.constant(0)],
|
| 305 |
+
return_same_structure=True)[0]
|
| 306 |
+
return minimize_op`,
|
| 307 |
+
"length": 64,
|
| 308 |
+
"temperature": 0.3,
|
| 309 |
+
"mode": "python",
|
| 310 |
+
},
|
| 311 |
"docstring": {
|
| 312 |
"prompt":
|
| 313 |
`<| file ext=.py |>
|