Spaces:
Runtime error
Runtime error
requirements.txt
Browse filestransformers
torch
gradio
app.py
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
|
3 |
+
|
4 |
+
model_name = "m-a-p/MegaBeam-Mistral-7B"
|
5 |
+
|
6 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
7 |
+
model = AutoModelForCausalLM.from_pretrained(
|
8 |
+
model_name,
|
9 |
+
trust_remote_code=True,
|
10 |
+
device_map="auto"
|
11 |
+
)
|
12 |
+
|
13 |
+
pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
|
14 |
+
|
15 |
+
def chat(prompt):
|
16 |
+
output = pipe(prompt, max_new_tokens=512, temperature=0.7)
|
17 |
+
return output[0]['generated_text']
|
18 |
+
|
19 |
+
iface = gr.Interface(fn=chat, inputs="text", outputs="text", title="MegaBeam Chat 512K")
|
20 |
+
iface.launch()
|