Farha00 commited on
Commit
a5609a7
1 Parent(s): f0e94c3

initial commit

Browse files
Files changed (2) hide show
  1. app.py +17 -0
  2. requirements.txt +2 -0
app.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import AutoModelForCausalLM, AutoTokenizer
3
+
4
+ # Load the model and tokenizer
5
+ model_name = "hiieu/Meta-Llama-3-8B-Instruct-function-calling-json-mode"
6
+ model = AutoModelForCausalLM.from_pretrained(model_name)
7
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
8
+
9
+ def generate_text(prompt):
10
+ inputs = tokenizer(prompt, return_tensors="pt")
11
+ outputs = model.generate(**inputs)
12
+ return tokenizer.decode(outputs[0], skip_special_tokens=True)
13
+
14
+ # Create a Gradio interface
15
+ iface = gr.Interface(fn=generate_text, inputs="text", outputs="text", title="Meta-Llama-3-8B Text Generation")
16
+
17
+ iface.launch()
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ transformers
2
+ gradio