You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Many people want to get starting with using chatbots locally.
However, they often are intimidated by the complexity and the steep learning curve needed to even run a basic chatbot.
In this gist, I share a few simple methods to run a chatbot locally without the need to do 69 installation steps.
All you need a machine with enough memory to run the model.
A computer with 8GB of cpu ram is the minimum requirement.
This is a super simple guide to run a chatbot locally using docker containers.
Pre-requisites
All you need is:
Docker
A model
Docker
To install docker on ubuntu, simply run:
sudo apt install docker.io
Model
You can select any model you want as long as it's a gguf. I recommend openchat-3.5-1210.Q4_K_M to get started: It requires 6GB of memery (can work without gpu too)
You can select any model you want as long as it's a gguf. I recommend Meta-Llama-3-8B-Instruct-Q5_K_M to get started: It requires 6GB of memery (can work without gpu too)
Llamafile uses llama.cpp server under the hood which provides an OpenAI compatible API. You can make requestes to the API as follows:
curl http://127.0.0.1:8080/v1/chat/completions -H "Content-Type: application/json" -H "Authorization: Bearer $OPENAI_API_KEY" -d '{
"model": "/models/Meta-Llama-3-8B-Instruct-Q5_K_M.gguf",
"messages": [
{
"role": "system",
"content": "You will be provided with statements, and your task is to convert them to standard English."
},
{
"role": "user",
"content": "She not went to the market."
}
],
"temperature": 2.0,
"max_tokens": 64,
"top_p": 1
}'
This will return the following response:
{"choices":[{"finish_reason":"stop","index":0,"message":{"content":"She didn't go to the market. ","role":"assistant"}}],"created":1703860191,"id":"chatcmpl-blpd2RutXMbnqdbCnJkbvTR5cLlo9hvz","model":"/models/Meta-Llama-3-8B-Instruct-Q5_K_M.gguf","object":"chat.completion","usage":{"completion_tokens":15,"prompt_tokens":68,"total_tokens":83}}