npc0 commited on
Commit
e9be370
·
1 Parent(s): 2f72203

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -52,19 +52,21 @@ def sum_chain_l1(text, p_bar):
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, p_bar):
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
 
@@ -76,6 +78,7 @@ def greet(text, progress=gr.Progress()):
76
  for doc in sum_chain_l1(text, progress.tqdm):
77
  yield '# drafting summary', doc
78
  # yield 'stage 1 finished', '\n===== summarized parts =====\n'.join(doc)
 
79
  progress(0, desc="Refinement")
80
  for ans in sum_chain_l2_deprecated(doc, progress.tqdm):
81
  yield '# refining summary', ans
 
52
  top_k=top_k,
53
  top_p=top_p,
54
  temperature=temperature):
55
+ yield f"{'='*8} {i+1}/{len(text)//2000+1} {'='*8}\n{answer}"
56
  docs.append(answer)
57
  return docs
58
 
59
  def sum_chain_l2_deprecated(docs, p_bar):
60
  hist = docs[0]
61
+ i = 0
62
  for doc in p_bar(docs[1:]):
63
+ i += 1
64
  for answer in model.generate_iterate(prompt+"\n"+hist+"\n"+doc,
65
  max_generated_tokens=max_tokens,
66
  top_k=top_k,
67
  top_p=top_p,
68
  temperature=temperature):
69
+ yield f"{'='*8} {i}/{len(docs)} {'='*8}\n{answer}"
70
  hist = answer
71
  return hist
72
 
 
78
  for doc in sum_chain_l1(text, progress.tqdm):
79
  yield '# drafting summary', doc
80
  # yield 'stage 1 finished', '\n===== summarized parts =====\n'.join(doc)
81
+ print('stage 1 finished\n'+'\n===== summarized parts =====\n'.join(doc))
82
  progress(0, desc="Refinement")
83
  for ans in sum_chain_l2_deprecated(doc, progress.tqdm):
84
  yield '# refining summary', ans