Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
3 |
+
|
4 |
+
# Load the LLaMA 3 model and tokenizer
|
5 |
+
model_name = "kshabana/GOAT-llama3.1-v0.1" # Replace with the actual model path if different
|
6 |
+
model = AutoModelForCausalLM.from_pretrained(GOAT-llama3.1-v0.1-Q4_K_M.gguf)
|
7 |
+
tokenizer = AutoTokenizer.from_pretrained(tokenizer.json)
|
8 |
+
|
9 |
+
def generate_response(user_input):
|
10 |
+
inputs = tokenizer.encode(user_input, return_tensors="pt")
|
11 |
+
outputs = model.generate(inputs, max_length=50, num_return_sequences=1)
|
12 |
+
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
13 |
+
return response
|
14 |
+
|
15 |
+
interface = gr.Interface(fn=generate_response, inputs="text", outputs="text")
|
16 |
+
interface.launch()
|