app.py
CHANGED
@@ -122,6 +122,12 @@ def show_avg(base_fn, model_name, patent_claim_num, show_pick=False):
|
|
122 |
lst = result['output']
|
123 |
result = ''
|
124 |
sum_all = {}
|
|
|
|
|
|
|
|
|
|
|
|
|
125 |
for i, tk in enumerate(lst):
|
126 |
token_text = handle_char_return(tk['actual_next_token_text'])
|
127 |
if token_text == '<|end_of_claim|>':
|
@@ -133,12 +139,6 @@ def show_avg(base_fn, model_name, patent_claim_num, show_pick=False):
|
|
133 |
pick = int(tk['actual_next_token_top_seq'])
|
134 |
prob = float(tk['actual_next_token_top_prob'])
|
135 |
|
136 |
-
colors = [
|
137 |
-
['00ff00', '000000', '1'],
|
138 |
-
['008800', 'ffffff', '2-10'],
|
139 |
-
['ff0000', 'ffffff', 'out of top 10'],
|
140 |
-
]
|
141 |
-
|
142 |
for i, item in enumerate(colors):
|
143 |
sum_all[item[2]] = 0
|
144 |
|
@@ -159,21 +159,20 @@ def show_avg(base_fn, model_name, patent_claim_num, show_pick=False):
|
|
159 |
tag = colors[2][2]
|
160 |
sum_all[tag] += 1
|
161 |
|
162 |
-
|
163 |
-
pick = '[%s]' % pick
|
164 |
-
else:
|
165 |
-
pick = ''
|
166 |
|
167 |
-
|
168 |
|
169 |
color_msg = ''
|
170 |
for i, v in enumerate(colors):
|
171 |
color_msg += "<span style=background-color:#%s;color:#%s;border-radius:5px;> %s </span> " % (v[0], v[1], v[2])
|
172 |
|
|
|
173 |
# sum_pick as top 1~10
|
174 |
keys_with_auto = (sum_pick+sum_outscope_len)
|
175 |
keys_without_auto = len(full_text)
|
176 |
saved_ratio = float(keys_without_auto-keys_with_auto)/keys_without_auto * 100
|
|
|
177 |
s = 'model: %s\n' \
|
178 |
'Autocomplete Effectiveness: %.1f%% (keystrokes saved)\n' \
|
179 |
'Total keystrokes: %s (with autocomplete), %s (without autocomplete)\n' \
|
@@ -248,8 +247,8 @@ def main():
|
|
248 |
page_title="Patent-GPT-J demo", # String or None. Strings get appended with "• Streamlit".
|
249 |
page_icon=None, # String, anything supported by st.image, or None.
|
250 |
)
|
251 |
-
st.subheader("PatentGPT-J Demo
|
252 |
-
st.text("Data coverage:
|
253 |
|
254 |
num_set = set()
|
255 |
fn_lst = glob.glob(os.path.join(folder, '*'))
|
@@ -283,28 +282,11 @@ def main():
|
|
283 |
select_lst.append(num)
|
284 |
select_lst.sort()
|
285 |
|
286 |
-
if len(select_lst) == 0:
|
287 |
-
st.text('select_lst is empty')
|
288 |
-
return
|
289 |
-
|
290 |
-
if enable_summary_button:
|
291 |
-
if st.button('Show Summary'):
|
292 |
-
st.text('len(select_lst) = %s' % len(select_lst))
|
293 |
-
show_overall_summary(prefix_lst, select_lst)
|
294 |
-
|
295 |
show_patent_lst = [ s.replace('_', ' (claim ') + ')' for s in select_lst]
|
296 |
-
|
297 |
-
#pick = 0
|
298 |
pick = random.randrange(len(select_lst))
|
299 |
-
|
300 |
-
pick = random.randrange(len(select_lst))
|
301 |
-
num = select_lst[pick]
|
302 |
-
#num = random.choice(select_lst)
|
303 |
-
|
304 |
-
selected = st.selectbox("Choose a patent claim", show_patent_lst, index=pick)
|
305 |
-
num = selected.replace(')', '').replace(' (claim ', '_')
|
306 |
|
307 |
-
|
308 |
|
309 |
avgs = []
|
310 |
for prefix in prefix_lst:
|
|
|
122 |
lst = result['output']
|
123 |
result = ''
|
124 |
sum_all = {}
|
125 |
+
colors = [
|
126 |
+
['00ff00', '000000', '1'],
|
127 |
+
['008800', 'ffffff', '2-10'],
|
128 |
+
['ff0000', 'ffffff', 'out of top 10'],
|
129 |
+
]
|
130 |
+
|
131 |
for i, tk in enumerate(lst):
|
132 |
token_text = handle_char_return(tk['actual_next_token_text'])
|
133 |
if token_text == '<|end_of_claim|>':
|
|
|
139 |
pick = int(tk['actual_next_token_top_seq'])
|
140 |
prob = float(tk['actual_next_token_top_prob'])
|
141 |
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
for i, item in enumerate(colors):
|
143 |
sum_all[item[2]] = 0
|
144 |
|
|
|
159 |
tag = colors[2][2]
|
160 |
sum_all[tag] += 1
|
161 |
|
162 |
+
result += "<span style=background-color:#%s;color:#%s;border-radius:5px;>%s%s</span> " % (bg_color, fg_color, token_text, pick)
|
|
|
|
|
|
|
163 |
|
164 |
+
st.text('debug 2')
|
165 |
|
166 |
color_msg = ''
|
167 |
for i, v in enumerate(colors):
|
168 |
color_msg += "<span style=background-color:#%s;color:#%s;border-radius:5px;> %s </span> " % (v[0], v[1], v[2])
|
169 |
|
170 |
+
|
171 |
# sum_pick as top 1~10
|
172 |
keys_with_auto = (sum_pick+sum_outscope_len)
|
173 |
keys_without_auto = len(full_text)
|
174 |
saved_ratio = float(keys_without_auto-keys_with_auto)/keys_without_auto * 100
|
175 |
+
|
176 |
s = 'model: %s\n' \
|
177 |
'Autocomplete Effectiveness: %.1f%% (keystrokes saved)\n' \
|
178 |
'Total keystrokes: %s (with autocomplete), %s (without autocomplete)\n' \
|
|
|
247 |
page_title="Patent-GPT-J demo", # String or None. Strings get appended with "• Streamlit".
|
248 |
page_icon=None, # String, anything supported by st.image, or None.
|
249 |
)
|
250 |
+
st.subheader("PatentGPT-J Demo 3 (Autocomplete Effectiveness)")
|
251 |
+
st.text("Data coverage: unicorn text")
|
252 |
|
253 |
num_set = set()
|
254 |
fn_lst = glob.glob(os.path.join(folder, '*'))
|
|
|
282 |
select_lst.append(num)
|
283 |
select_lst.sort()
|
284 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
285 |
show_patent_lst = [ s.replace('_', ' (claim ') + ')' for s in select_lst]
|
|
|
|
|
286 |
pick = random.randrange(len(select_lst))
|
287 |
+
num = select_lst[pick]
|
|
|
|
|
|
|
|
|
|
|
|
|
288 |
|
289 |
+
st.text('debug')
|
290 |
|
291 |
avgs = []
|
292 |
for prefix in prefix_lst:
|