Spaces:
Runtime error
Runtime error
add example+limitation
Browse files
app.py
CHANGED
@@ -6,9 +6,10 @@ title = "🎅 Santa Explains Code"
|
|
6 |
description = "This space converts Python code into English text that explains its function using [SantaCoder-Code-To-Text](https://huggingface.co/loubnabnl/santacoder-code-to-text),\
|
7 |
a code generation model that was fine-tuned on the [github-jupyter-code-to-text](https://huggingface.co/datasets/codeparrot/github-jupyter-code-to-text) dataset.\
|
8 |
This dataset includes Python code accompanied by docstrings that explain it. The data was sourced from Jupyter notebooks.\n\n\
|
9 |
-
Limitations: The model was fine-tuned on a small dataset from Jupyter Notebooks, so it can only explain simple
|
10 |
-
common functions that are found in these notebooks, in a similar fashion to the text in markdown cells."
|
11 |
|
|
|
12 |
EXAMPLE_1 = "from sklearn import model_selection\nX_train, X_test, Y_train, Y_test = model_selection.train_test_split(X, Y, test_size=0.2)"
|
13 |
EXAMPLE_2 = "def load_text(file)\n with open(filename, 'r') as f:\n text = f.read()\n return text"
|
14 |
EXAMPLE_3 = "net.zero_grad()\nloss.backward()"
|
@@ -16,7 +17,8 @@ EXAMPLE_4 = "net.zero_grad()\nloss.backward()\n\nnoptimizer.step()"
|
|
16 |
EXAMPLE_5 = "def sort_function(arr):\n n = len(arr)\n \n # Traverse through all array elements\n for i in range(n):\n \n # Last i elements are already in place\n for j in range(0, n-i-1):\n \n # traverse the array from 0 to n-i-1\n # Swap if the element found is greater\n # than the next element\n if arr[j] > arr[j+1]:\n arr[j], arr[j+1] = arr[j+1], arr[j]"
|
17 |
|
18 |
example = [
|
19 |
-
[
|
|
|
20 |
[EXAMPLE_2, 11, 0.6, 42],
|
21 |
[EXAMPLE_3, 30, 0.6, 42],
|
22 |
[EXAMPLE_4, 46, 0.6, 42],
|
|
|
6 |
description = "This space converts Python code into English text that explains its function using [SantaCoder-Code-To-Text](https://huggingface.co/loubnabnl/santacoder-code-to-text),\
|
7 |
a code generation model that was fine-tuned on the [github-jupyter-code-to-text](https://huggingface.co/datasets/codeparrot/github-jupyter-code-to-text) dataset.\
|
8 |
This dataset includes Python code accompanied by docstrings that explain it. The data was sourced from Jupyter notebooks.\n\n\
|
9 |
+
Limitations: The model was fine-tuned on a small dataset from Jupyter Notebooks, so it can only explain simple, \
|
10 |
+
common functions that are found in these notebooks, in a similar fashion to the text in markdown cells. It might also be sensitive to function names and comments."
|
11 |
|
12 |
+
EXAMPLE_0 = "def function(sequence):\n return [x for x in sequence if x % 2 == 0]"
|
13 |
EXAMPLE_1 = "from sklearn import model_selection\nX_train, X_test, Y_train, Y_test = model_selection.train_test_split(X, Y, test_size=0.2)"
|
14 |
EXAMPLE_2 = "def load_text(file)\n with open(filename, 'r') as f:\n text = f.read()\n return text"
|
15 |
EXAMPLE_3 = "net.zero_grad()\nloss.backward()"
|
|
|
17 |
EXAMPLE_5 = "def sort_function(arr):\n n = len(arr)\n \n # Traverse through all array elements\n for i in range(n):\n \n # Last i elements are already in place\n for j in range(0, n-i-1):\n \n # traverse the array from 0 to n-i-1\n # Swap if the element found is greater\n # than the next element\n if arr[j] > arr[j+1]:\n arr[j], arr[j+1] = arr[j+1], arr[j]"
|
18 |
|
19 |
example = [
|
20 |
+
[EXAMPLE_0, 32, 0.6, 42],
|
21 |
+
[EXAMPLE_1, 34, 0.4, 42],
|
22 |
[EXAMPLE_2, 11, 0.6, 42],
|
23 |
[EXAMPLE_3, 30, 0.6, 42],
|
24 |
[EXAMPLE_4, 46, 0.6, 42],
|