Update app.py
Browse files
app.py
CHANGED
|
@@ -5,3 +5,31 @@ def greet(name):
|
|
| 5 |
|
| 6 |
demo = gr.Interface(fn=greet, inputs="text", outputs="text")
|
| 7 |
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
demo = gr.Interface(fn=greet, inputs="text", outputs="text")
|
| 7 |
demo.launch()
|
| 8 |
+
import gradio as gr
|
| 9 |
+
from llama_cpp import Llama
|
| 10 |
+
|
| 11 |
+
# Percorso al tuo modello GGUF ospitato su HuggingFace
|
| 12 |
+
MODEL_REPO = "kikalore/iris"
|
| 13 |
+
MODEL_FILE = "model-3b-Q4_K_M.gguf" # assicurati che il nome sia corretto nel repo model!
|
| 14 |
+
|
| 15 |
+
llm = Llama.from_pretrained(
|
| 16 |
+
repo_id=MODEL_REPO,
|
| 17 |
+
filename=MODEL_FILE,
|
| 18 |
+
n_ctx=4096,
|
| 19 |
+
n_threads=4
|
| 20 |
+
)
|
| 21 |
+
|
| 22 |
+
def chat(message, history):
|
| 23 |
+
prompt = ""
|
| 24 |
+
for human, bot in history:
|
| 25 |
+
prompt += f"<|user|>{human}\n<|assistant|>{bot}\n"
|
| 26 |
+
prompt += f"<|user|>{message}\n<|assistant|>"
|
| 27 |
+
|
| 28 |
+
output = llm(prompt, max_tokens=350)
|
| 29 |
+
return output["choices"][0]["text"].strip()
|
| 30 |
+
|
| 31 |
+
gr.ChatInterface(
|
| 32 |
+
fn=chat,
|
| 33 |
+
title="Iris – Fine-tuned LLM"
|
| 34 |
+
).launch()
|
| 35 |
+
|