Spaces:
Sleeping
Sleeping
File size: 1,058 Bytes
a5a431f 0cb757f a5a431f 696e2b8 0cb757f 6b156ef 0cb757f a5a431f 696e2b8 0cb757f a5a431f 696e2b8 0cb757f a5a431f 696e2b8 a5a431f 696e2b8 a5a431f 696e2b8 0cb757f 696e2b8 0cb757f a5a431f 0cb757f a5a431f 0cb757f a5a431f 696e2b8 0cb757f 696e2b8 0cb757f 696e2b8 a5a431f 0cb757f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | import gradio as gr
from llama_cpp import Llama
from huggingface_hub import hf_hub_download
# Download the GGUF model
model_path = hf_hub_download(
repo_id="ciphermosaic/qwen-alpaca-gguf",
filename="Qwen2.5-0.5B-Instruct.Q4_K_M.gguf"
)
# Load the model
llm = Llama(
model_path=model_path,
n_ctx=2048,
chat_format="chatml",
verbose=False,
)
# Chat function
def chat(message, history):
messages = []
# Add previous conversation
if history:
messages.extend(history)
# Add current user message
messages.append({
"role": "user",
"content": message
})
# Generate response
response = llm.create_chat_completion(
messages=messages,
temperature=0.7,
max_tokens=256,
)
reply = response["choices"][0]["message"]["content"]
return reply
# Gradio interface
demo = gr.ChatInterface(
fn=chat,
type="messages",
title="🤖 Qwen Alpaca Chatbot",
description="A fine-tuned Qwen 0.5B GGUF model running with llama.cpp",
)
demo.launch() |