Menu

Post image 1
Post image 2
1 / 2
0

Build a Local AI Chatbot with Python (No Internet Needed)

DEV Community·Jeffrey.Feillp·30 days ago
#zp4GCHNN
Reading 0:00
15s threshold

Jeffrey.Feillp

A guide to running open-source LLMs locally on your machine.

Why Local AI?

  • Privacy
  • No API costs
  • Works offline

Quick Setup

pip install llama-cpp-python
wget https://huggingface.co/TheBloke/Mistral-7B-GGUF/resolve/main/mistral-7b-instruct.Q4_K_M.gguf

Enter fullscreen mode Exit fullscreen mode

from llama_cpp import Llama
llm = Llama(model_path="./mistral-7b-instruct.Q4_K_M.gguf")
output = llm("Q: Hello! A:", max_tokens=64)
print(output["choices"][0]["text"])

Enter fullscreen mode Exit fullscreen mode

Read More