Spaces:
Running
Running
Feature(LLMLingua): add examples
Browse files
app.py
CHANGED
@@ -50,6 +50,27 @@ custom_css = """
|
|
50 |
}
|
51 |
"""
|
52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
def compress_prompt(context, instruction, question, ratio, target_token):
|
54 |
context, instruction, question = context.replace("\\n", "\n"), instruction.replace("\\n", "\n"), question.replace("\\n", "\n")
|
55 |
compressed_prompt = llm_lingua.compress_prompt(context.split("\n\n"), instruction, question, float(ratio), float(target_token))
|
@@ -114,10 +135,10 @@ with gr.Blocks(css=custom_css) as iface:
|
|
114 |
)
|
115 |
|
116 |
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
|
122 |
gen_button.click(
|
123 |
fn=compress_prompt,
|
|
|
50 |
}
|
51 |
"""
|
52 |
|
53 |
+
EXAMPLES = [
|
54 |
+
[
|
55 |
+
"vicgalle/gpt2-alpaca",
|
56 |
+
"Question: can buy 4 1melon for You bought 36 fruits evenly split between of 1 $. does cost if bill $\n's think step\nIf between 3 then I 363 = 12 of fruit 1 orange then oranges506If I oranges I $66 $60 on the 2 fruit\n the of is, and that price and is 1W4AIf we know we bought 12 and 12W\n thatW can the 12 = 48\n of apple (60/The 1\n: Sam a dozen boxes with 30ighter pens each Heanged into six3 the separately of three. much in\n's boxes $120 12 =Sam then took 5 boxes × 6 highlighters/box = 30 highlighters.\nHe sold these boxes for 5 * $3 = $15\nAfter selling these 5 boxes there were 360 - 30 = 330 highlighters remaining.\nThese form 330 / 3 = 110 groups of three pens.\nHe sold each of these groups for $2 each, so made 110 * 2 = $220 from them.\nIn total, then, he earned $220 + $15 = $235.\nSince his original cost was $120, he earned $235 - $120 = $115 in profit.\nThe answer is 115",
|
57 |
+
"8.7x",
|
58 |
+
"",
|
59 |
+
],
|
60 |
+
[
|
61 |
+
"vicgalle/alpaca-7b",
|
62 |
+
"Question: Sam bought a dozen boxes, each 30 highl pens inside, $10 each. He reanged five of boxes into of sixlters each sold $3. He sold the theters separately at the of three $2. How much did make in total, in\nLets think step\nSam bought boxes x0 = $10 oflters.\nHe 2 300ters in\nSam then 5 boxes 6ters0ters\nHe sold these boxes for 55\nAfterelling these boxes there300lters remaining\nThese form 330 310 of three pens\nHe sold each of these groups for2 each, so made 0 *0 from\nIn total, he $ $155\nSince his original $1, he earned $20 = $115 in profit.\nThe answer is 115\n\n",
|
63 |
+
"13.8x",
|
64 |
+
"78.32",
|
65 |
+
],
|
66 |
+
[
|
67 |
+
"vicgalle/alpaca-7b",
|
68 |
+
"Question: Sam bought a dozen boxes, each with 30 highl pens inside, for $10 each.\nHe reanged five of boxes into of sixlters each sold them $3 per package.\nHe sold the rest of thelters separately at the of three pens for $2.\nHow much profit did make in total, in dollars\nLet's think step by step\nSam then took 5 boxes × 6lighters/box = 30 highlighters.\nThese form 330 / 3 = 110 groups of three pens.\nThe answer is 115\n\n",
|
69 |
+
"20.2x",
|
70 |
+
"77.94",
|
71 |
+
],
|
72 |
+
]
|
73 |
+
|
74 |
def compress_prompt(context, instruction, question, ratio, target_token):
|
75 |
context, instruction, question = context.replace("\\n", "\n"), instruction.replace("\\n", "\n"), question.replace("\\n", "\n")
|
76 |
compressed_prompt = llm_lingua.compress_prompt(context.split("\n\n"), instruction, question, float(ratio), float(target_token))
|
|
|
135 |
)
|
136 |
|
137 |
|
138 |
+
gr.Examples(
|
139 |
+
examples=EXAMPLES,
|
140 |
+
# inputs=[image_upload, positive_prompt, negative_prompt],
|
141 |
+
)
|
142 |
|
143 |
gen_button.click(
|
144 |
fn=compress_prompt,
|