kumar1907 commited on
Commit
aa085f1
·
verified ·
1 Parent(s): 3b50a65

Initial app.py with LLaMA 3.1 assistant

Browse files
Files changed (1) hide show
  1. app.py +15 -0
app.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # app.py
2
+ import gradio as gr
3
+ from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
4
+
5
+ model_id = "meta-llama/Llama-3.1-8B-Instruct"
6
+
7
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
8
+ model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto")
9
+ pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
10
+
11
+ def chat_with_llama(prompt):
12
+ result = pipe(prompt, max_new_tokens=256, do_sample=True, temperature=0.7)
13
+ return result[0]['generated_text']
14
+
15
+ gr.Interface(fn=chat_with_llama, inputs="text", outputs="text", title="Venkat Assistant").launch()