DEV Community

whatminjacodes [she/they]
whatminjacodes [she/they]

Posted on • Updated on

Building a Simple Chatbot using GPT model - part 1

I have been wanting to understand the vulnerabilities related to Large Language Model (LLM) applications and generative AI, so I thought a good way to understand these in practice would be by first developing my own chatbot.

So here's a two-part series where I go through what LLMs are, how to set up a development environment, and how to actually develop a chatbot.

This first post helps you set up the environment, as well as explains what LLMs are. In a post next week, I will go through the development of the chatbot.

What are LLMs?

LLM stands for Large Language Model. It is a system designed to understand and generate human-like text. LLMs are trained with vast amounts of data from various sources, such as books, articles, and websites. This allows the algorithm to predict what sequences of words are probable responses to a user-provided input.

One example of a system using an LLM, which probably everyone has heard about by now, is ChatGPT. It is an AI system that uses natural language processing to create a conversation with the user and utilizes OpenAI's Generative Pre-trained Transformer (GPT), a neural network machine learning model.

Setup the Environment

Now that you have the background info for this series, let's set up our environment.

I'm using WSL 2 with Ubuntu 20.04 LTS, so if you are not using the same setup, the commands I use might be a little different on your distribution.

1. Update and Upgrade Ubuntu

Open your Ubuntu terminal and run the following commands to update and upgrade your package lists:

sudo apt update
sudo apt upgrade
Enter fullscreen mode Exit fullscreen mode

This will ensure you have the latest software updates.

2. Install Python

This guide will use Python and pip to run the required Python scripts and manage packages. Most Ubuntu installations come with Python pre-installed. Verify the installation by running the following commands:

python3 --version
pip3 --version
Enter fullscreen mode Exit fullscreen mode

If Python or pip is not installed, install them using this command:

sudo apt install python3 python3-pip
Enter fullscreen mode Exit fullscreen mode

3. Install Virtual Environment Tools

Creating a virtual environment is a best practice to manage dependencies for your projects. This will create an isolated environment that prevents conflicts between different projects that may require different versions of the same package.

Install venv by running:

sudo apt install python3-venv
Enter fullscreen mode Exit fullscreen mode

4. Create a Virtual Environment

Navigate to the directory where you want to create your project and set up a virtual environment:

mkdir name-of-directory
cd name-of-directory
python3 -m venv venv-name
Enter fullscreen mode Exit fullscreen mode
  • mkdir name-of-directory: Creates a new directory called name-of-directory for your project. Change the name to what you want it to be.
  • cd name-of-directory: Changes the current directory to the directory you just created.
  • python3 -m venv venv-name: Creates a virtual environment named venv-name in the directory. Change the name to what you want it to be.

5. Activate the Virtual Environment

Activate the virtual environment with the following command, changing venv-name to the one you chose when creating the virtual environment in the step above:

source venv-name/bin/activate
Enter fullscreen mode Exit fullscreen mode

You should see the virtual environment name (e.g., venv-name) in your terminal prompt, indicating that it's activated.

(venv-name) example@ubuntu:/name-of-directory$
Enter fullscreen mode Exit fullscreen mode

6. Upgrade pip

Ensure that pip is up to date:

pip3 install --upgrade pip
Enter fullscreen mode Exit fullscreen mode

That's it!

In this blog post, we set up the environment so it is ready when we start building the chatbot on the next post that I'm publishing next week!

You can also follow my Instagram @whatminjahacks if you are interested to see more about my days as a Cyber Security consultant and learn more about cyber security with me!

Top comments (2)

heyeasley profile image
heyeasley 🍓🥭 • Edited

Cool. Useful.

whatminjacodes profile image
whatminjacodes [she/they]