File size: 3,008 Bytes
62497e0
 
 
 
 
 
 
 
 
 
 
 
 
4a588d1
62497e0
933f883
62497e0
283bb39
62497e0
 
 
 
 
 
 
933f883
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
019d607
62497e0
 
283bb39
62497e0
 
 
 
 
 
 
 
 
 
 
 
4a588d1
 
 
 
 
 
 
62497e0
 
ba43f0f
62497e0
4a588d1
62497e0
 
 
 
 
 
 
 
 
 
4a588d1
62497e0
 
 
 
 
019d607
62497e0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
import streamlit as st
import datasets
from datasets import load_dataset
import pandas as pd
from streamlit.components.v1 import html
from streamlit import markdown
import re
import os
import time

import json


st.title('StackOverflow Question Demo')

library = st.radio('Select a library', ('numpy', 'tensorflow+ pytorch', 'scipy', 'scikit-learn', 'pandas'))

question_path = './{}.txt'.format(library)
# loading stackoverflow questions.
# using huggingface load_dataset function.
# not done yet
#@st.cache
#def load_data(path):
#    return load_dataset('text', data_files = path, cache_dir = './data')

intro = {'numpy': '''
#### Setup
temperature = 0.7, topP = 0.95, turns = 10

#### Prompt:

Problem:
……

A:

<code>
……
###BEGIN SOLUTION
[insert]
###END SOLUTION

</code>


A0: change example

A1: change logits(decimal places, array, etc)

A2: change output type (array -> dict, etc)

A3: analogy

A4: dimension(index) involved

A5: inverted operation

A6: order

A7: ±condition/operation

combinations involved, only show the highest level.

''',
'scipy':
'''
Setup
temperature = 0.7, topP = 0.95, 10 attempts.

Prompt:

Problem:
……

A:

<code>
……
###BEGIN SOLUTION
[insert]
###END SOLUTION

</code>

Origin: original question from stackoverflow(might be specified or simplified)

Function: Let model fill in a function.

A1: paraphrasing, seems not effective to Codex.

A2: change example

A3: analogy(min->max, column->row, etc)

A6: result type constraint.

A7: ±condition/operation

'''
}

hyper_links = {'numpy':'https://docs.google.com/document/d/1WjMXfe-zV5VvKfbUnyxauTBciPB1Bp82baaIrG3XffM/edit#',
'scipy': 'https://docs.google.com/document/d/1u_rGiLrLbH9Ac_OueTbmDFyLlWOtB0U56Ertp8ggW1Q/edit'}

st.write(intro[library])

st.write('If the demo seems a little confusing, feel free to check the document.', hyper_links[library])

dataset = []
#dataset = load_data(question_path)
with open(question_path) as f:
    lines = f.readlines()
    question = ''
    temp = {}
    tag = ''
    for line in lines:
        if line == 'Origin:\n' or line == 'Function:\n' or re.match(r'A\d:\n', line):
            if not tag:
                tag = line[:-2]
            else:
                temp[tag] = question
                question = ''
                tag = line[:-2]
        elif re.match(r'\d*\.\n', line):
            if tag:
                temp[tag] = question
                dataset.append(temp)
                question = ''
                tag = ''
                temp = {}
        else:
            if tag:
                question += line + '\n'

temp[tag] = question
dataset.append(temp)

# Select index
number = st.number_input("Insert a index: range from", 
    min_value = 0, max_value = len(dataset) - 1)
st.write('The current index is ', number)
data_index = int(number)

# Selece modification
options = tuple(dataset[data_index].keys())
modification = st.radio('Modification:',
            options = options
)


st.write(dataset[data_index][modification])