anirudhagedam27 commited on
Commit
df009c9
·
verified ·
1 Parent(s): 4168606

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -0
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()