Spaces:
Sleeping
Sleeping
better display
Browse files
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 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
|
65 |
import gradio as gr
|
66 |
|
67 |
-
def greet(
|
68 |
-
progress(0, desc="
|
69 |
docs = []
|
70 |
-
for doc in sum_chain_l1(
|
71 |
yield doc
|
72 |
-
|
|
|
|
|
|
|
|
|
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,
|