Update app.py
Browse files
app.py
CHANGED
|
@@ -8,9 +8,11 @@
|
|
| 8 |
import gradio as gr
|
| 9 |
from llama_cpp import Llama
|
| 10 |
|
| 11 |
-
#
|
| 12 |
MODEL_REPO = "kikalore/iris"
|
| 13 |
-
MODEL_FILE = "model-3b-Q4_K_M.gguf"
|
|
|
|
|
|
|
| 14 |
|
| 15 |
llm = Llama.from_pretrained(
|
| 16 |
repo_id=MODEL_REPO,
|
|
@@ -20,6 +22,7 @@ llm = Llama.from_pretrained(
|
|
| 20 |
)
|
| 21 |
|
| 22 |
def chat(message, history):
|
|
|
|
| 23 |
prompt = ""
|
| 24 |
for human, bot in history:
|
| 25 |
prompt += f"<|user|>{human}\n<|assistant|>{bot}\n"
|
|
@@ -28,8 +31,9 @@ def chat(message, history):
|
|
| 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-
|
| 34 |
-
)
|
| 35 |
|
|
|
|
|
|
| 8 |
import gradio as gr
|
| 9 |
from llama_cpp import Llama
|
| 10 |
|
| 11 |
+
# Modello .gguf ospitato nel repo del modello
|
| 12 |
MODEL_REPO = "kikalore/iris"
|
| 13 |
+
MODEL_FILE = "model-3b-Q4_K_M.gguf"
|
| 14 |
+
|
| 15 |
+
print("Loading model...")
|
| 16 |
|
| 17 |
llm = Llama.from_pretrained(
|
| 18 |
repo_id=MODEL_REPO,
|
|
|
|
| 22 |
)
|
| 23 |
|
| 24 |
def chat(message, history):
|
| 25 |
+
# costruisci contesto della conversazione
|
| 26 |
prompt = ""
|
| 27 |
for human, bot in history:
|
| 28 |
prompt += f"<|user|>{human}\n<|assistant|>{bot}\n"
|
|
|
|
| 31 |
output = llm(prompt, max_tokens=350)
|
| 32 |
return output["choices"][0]["text"].strip()
|
| 33 |
|
| 34 |
+
demo = gr.ChatInterface(
|
| 35 |
fn=chat,
|
| 36 |
+
title="Iris – Fine-Tuned LLM"
|
| 37 |
+
)
|
| 38 |
|
| 39 |
+
demo.launch()
|