npc0 commited on
Commit
5320c21
·
1 Parent(s): 798de62

better display

Browse files
Files changed (1) hide show
  1. app.py +20 -10
app.py CHANGED
@@ -52,24 +52,34 @@ def sum_chain_l1(text, p_bar):
52
  top_k=top_k,
53
  top_p=top_p,
54
  temperature=temperature):
55
- yield answer
56
  docs.append(answer)
57
  return docs
58
 
59
- def sum_chain_l2_deprecated(docs):
60
- hist = ''
61
- for doc in tqdm(docs):
62
- hist = model.response(prompt+"\n"+hist+"\n"+doc)
63
- return hist
 
 
 
 
 
 
64
 
65
  import gradio as gr
66
 
67
- def greet(x, progress=gr.Progress()):
68
- progress(0, desc="Starting...")
69
  docs = []
70
- for doc in sum_chain_l1(x, progress.tqdm):
71
  yield doc
72
- return '===== summarized parts ====='.join(doc)
 
 
 
 
73
 
74
  iface = gr.Interface(fn=greet,
75
  inputs=gr.Textbox(lines=20,
 
52
  top_k=top_k,
53
  top_p=top_p,
54
  temperature=temperature):
55
+ yield f"{'='*8} {i}/{len(text)//2000+1} {'='*8}\n{answer}"
56
  docs.append(answer)
57
  return docs
58
 
59
+ def sum_chain_l2_deprecated(docs, pbar):
60
+ hist = docs[0]
61
+ for doc in p_bar(docs[1:]):
62
+ for answer in model.generate_iterate(prompt+"\n"+hist+"\n"+doc,
63
+ max_generated_tokens=max_tokens,
64
+ top_k=top_k,
65
+ top_p=top_p,
66
+ temperature=temperature):
67
+ yield answer
68
+ hist = answer
69
+ return hist
70
 
71
  import gradio as gr
72
 
73
+ def greet(text, progress=gr.Progress()):
74
+ progress(0, desc="Reading")
75
  docs = []
76
+ for doc in sum_chain_l1(text, progress.tqdm):
77
  yield doc
78
+ # yield '\n===== summarized parts =====\n'.join(doc)
79
+ progress(0, desc="Refinement")
80
+ for ans in sum_chain_l2_deprecated(doc, progress.tqdm):
81
+ yield '# drafting and refining summary =\n' + ans
82
+ return ans
83
 
84
  iface = gr.Interface(fn=greet,
85
  inputs=gr.Textbox(lines=20,