import gradio as gr from llama_cpp import Llama # This pulls your specific Qwen 2.5 Coder GGUF # 1.5B fits perfectly in the 16GB RAM of a free Space llm = Llama.from_pretrained( repo_id="harishkumar12k/Qwen2.5-Coder-1.5B-Q4_K_M-GGUF", filename="qwen2.5-coder-1.5b-q4_k_m.gguf", n_ctx=2048, n_threads=2 ) def chat(message, history): # Format for Qwen-Coder prompt = "system\nYou are a helpful coding assistant.\n" for user_msg, assistant_msg in history: prompt += f"user\n{user_msg}\nassistant\n{assistant_msg}\n" prompt += f"user\n{message}\nassistant\n" output = llm( prompt, max_tokens=512, stop=["user", "<|endoftext|>"], echo=False ) return output["choices"][0]["text"].strip() demo = gr.ChatInterface( fn=chat, title="Qwen 2.5 Coder 1.5B GGUF", description="Running on HF Spaces CPU via llama-cpp-python" ) if __name__ == "__main__": demo.launch()