Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,24 @@
|
|
1 |
-
|
2 |
|
3 |
-
|
4 |
-
|
|
|
|
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from llmlingua import PromptCompressor
|
2 |
|
3 |
+
compressor = PromptCompressor(
|
4 |
+
model_name="microsoft/llmlingua-2-bert-base-multilingual-cased-meetingbank",
|
5 |
+
use_llmlingua2=True
|
6 |
+
)
|
7 |
|
8 |
+
original_prompt = """John: So, um, I've been thinking about the project, you know, and I believe we need to, uh, make some changes. I mean, we want the project to succeed, right? So, like, I think we should consider maybe revising the timeline.
|
9 |
+
|
10 |
+
Sarah: I totally agree, John. I mean, we have to be realistic, you know. The timeline is, like, too tight. You know what I mean? We should definitely extend it.
|
11 |
+
|
12 |
+
"""
|
13 |
+
|
14 |
+
results = compressor.compress_prompt_llmlingua2(
|
15 |
+
original_prompt,
|
16 |
+
rate=0.6,
|
17 |
+
force_tokens=['\n', '.', '!', '?', ','],
|
18 |
+
chunk_end_tokens=['.', '\n'],
|
19 |
+
return_word_label=True,
|
20 |
+
drop_consecutive=True
|
21 |
+
)
|
22 |
+
|
23 |
+
print(results.keys())
|
24 |
+
print(f"Compressed prompt: {results['compressed_prompt']}")
|