Spaces:
Paused
Paused
nroggendorff
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1,26 +1,14 @@
|
|
1 |
import gradio as gr
|
2 |
-
from
|
3 |
|
4 |
-
|
5 |
-
|
6 |
-
'stabilityai/stablelm-2-zephyr-1_6b',
|
7 |
-
device_map="auto"
|
8 |
-
)
|
9 |
|
10 |
def pipe(text: str):
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
do_sample=True
|
16 |
-
)
|
17 |
-
|
18 |
-
inputs = tokenizer.apply_chat_template(
|
19 |
-
text,
|
20 |
-
add_generation_prompt=True,
|
21 |
-
return_tensors='pt'
|
22 |
-
)
|
23 |
-
return tokenizer.decode(tokens[0], skip_special_tokens=False)
|
24 |
|
25 |
if __name__ == "__main__":
|
26 |
interface = gr.Interface(pipe, gr.Textbox(label="Prompt"), gr.Textbox(label="Response"), title="Text Completion")
|
|
|
1 |
import gradio as gr
|
2 |
+
from vllm import LLM, SamplingParams
|
3 |
|
4 |
+
llm = LLM(model="meta-llama/Llama-2-7B-Chat-hf")
|
5 |
+
sampling_params = SamplingParams(temperature=0.8, top_p=0.95)
|
|
|
|
|
|
|
6 |
|
7 |
def pipe(text: str):
|
8 |
+
prompt = [text]
|
9 |
+
tokens = llm.generate(prompt, sampling_params)
|
10 |
+
output = (output.outputs[0].text for output in tokens)
|
11 |
+
return output[0]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
if __name__ == "__main__":
|
14 |
interface = gr.Interface(pipe, gr.Textbox(label="Prompt"), gr.Textbox(label="Response"), title="Text Completion")
|