Build and Deploy A Custom LLM Chatbot in 5 Minutes

Rahatara Ferdousi
3 min readJun 24, 2024

Ever wanted to create a custom chatbot with LLM?

đŸ‘©â€đŸłWhether you want a digital chef to help you in the kitchen or an artistic companion to discuss painting techniques, this guide will show you how to build and deploy your very own LLM chatbot in just five minutes, using Hugging Face Spaces and Gradio. And yes, it’s completely free!

🧂🍅Ingredients:

  1. Hugging Face Account
  2. Role (Decide what your LLM will act like – Chef, Painter, Relaxing Buddy?)
  3. System Instruction (Define how it should act)

đŸ„˜Step-by-Step Guide:

1. Log In to Hugging Face

Start by logging into your Hugging Face account. If you don’t have one, you can easily create it at huggingface.co.

2. Navigate to Spaces: Once logged in, go to the Spaces section. This is where you can create and manage your applications.

3. Create Your Space: Click on ‘Create New Space’. Choose a name for your Space.

4. Setup Framework and Model: Select ‘Gradio’ as the framework and ‘Chatbot’ as the model type. By default, it will select the Zephyr 7B model, which is versatile for various tasks.

5. Launch and Wait: Hit the create space button and wait for the app to deploy. It usually takes few moments. Once done, you’ll see your chatbot running.

Customization:

To make your chatbot stand out, let’s customize it as a Relaxing Buddy, perfect for unwinding after a long day.

  1. Go to Files

In your Space, navigate to the ‘Files’ tab and find the app.py file.

2. Edit the System Message

to reflect the chatbot’s new persona. For instance:

system_message = " You are a good listener. You advise relaxation exercises, suggest avoiding negative thoughts, and guide through steps to manage stress. Let's discuss what's on your mind, or ask me for a quick relaxation exercise."      

3. Deploy Changes

Click on ‘Commit Changes to Main’ and Save the changes and redeploy your Space. The chatbot will now function as a Relaxing Buddy.

Congratulations! You’ve just created a customized LLM app. Experiment with different roles and system instructions to see how versatile your chatbot can be. Share your creation in the comments and let us know how you plan to use your new AI companion!

1. GitHub Link

2. Try in Huggingface

3. Follow on TikTok

--

--

Rahatara Ferdousi

Doctoral Researcher at the University of Ottawa. Exploring AI integrated Digital Twin to Automate Railway Defect Inspection and Maintenance.