Spaces:
Running
Running
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
model_id = "deepseek-ai/deepseek-coder-1.3b-base" # change to your choice
|
5 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
6 |
+
model = AutoModelForCausalLM.from_pretrained(
|
7 |
+
model_id,
|
8 |
+
device_map="auto",
|
9 |
+
torch_dtype="auto"
|
10 |
+
)
|
11 |
+
|
12 |
+
pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
|
13 |
+
|
14 |
+
def chat(prompt):
|
15 |
+
result = pipe(prompt, max_new_tokens=256, do_sample=True, temperature=0.2)
|
16 |
+
return result[0]['generated_text']
|
17 |
+
|
18 |
+
iface = gr.Interface(fn=chat, inputs="text", outputs="text")
|
19 |
+
iface.launch()
|