Spaces:
Configuration error
Configuration error
Delete app.py
Browse files
app.py
DELETED
|
@@ -1,28 +0,0 @@
|
|
| 1 |
-
import torch
|
| 2 |
-
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
|
| 3 |
-
import gradio as gr
|
| 4 |
-
|
| 5 |
-
model_name = "NousResearch/Nous-Hermes-llama2-13b"
|
| 6 |
-
tokenizer = AutoTokenizer.from_pretrained(model_name, use_fast=True)
|
| 7 |
-
model = AutoModelForCausalLM.from_pretrained(
|
| 8 |
-
model_name,
|
| 9 |
-
torch_dtype=torch.float16,
|
| 10 |
-
device_map="auto",
|
| 11 |
-
trust_remote_code=True
|
| 12 |
-
)
|
| 13 |
-
|
| 14 |
-
generator = pipeline("text-generation", model=model, tokenizer=tokenizer)
|
| 15 |
-
|
| 16 |
-
def chat(prompt):
|
| 17 |
-
output = generator(
|
| 18 |
-
prompt,
|
| 19 |
-
max_new_tokens=512,
|
| 20 |
-
do_sample=True,
|
| 21 |
-
temperature=0.8,
|
| 22 |
-
top_k=60,
|
| 23 |
-
top_p=0.95
|
| 24 |
-
)
|
| 25 |
-
return output[0]["generated_text"]
|
| 26 |
-
|
| 27 |
-
demo = gr.Interface(fn=chat, inputs="text", outputs="text")
|
| 28 |
-
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|