Oluwatoni commited on
Commit
0265fe2
1 Parent(s): fa2f965

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -5
app.py CHANGED
@@ -1,7 +1,24 @@
1
- import gradio as gr
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
 
 
5
 
6
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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']}")