Home / Open Source / OpenChatKit tutorial: Build a custom chatbot from scratch
OpenChatKit tutorial: Build a custom chatbot from scratch
OpenChatKit is an Apache‑2.0 licensed, open‑source framework that bundles an instruction‑tuned LLM, a moderation model, retrieval extensions, and fine‑tuning recipes; you can install it with conda/mamba, run the provided bot.py, and customize it for domain‑specific chatbots.

What core features does OpenChatKit provide?
- Instruction‑tuned chat model – GPT‑NeoXT‑Chat‑Base‑20B (20 B parameters) fine‑tuned on 43 M high‑quality instructions.
- Customization recipes for fine‑tuning on your own data (e.g., Llama‑2‑7B‑32K‑beta scripts).
- Extensible retrieval system that can pull information from document stores or APIs at inference time.
- Built‑in moderation model derived from GPT‑JT‑6B to filter unsafe queries.
- Plug‑and‑play agents accessed via the simple
bot.pycommand‑line interface. - Open source with full code, model weights, and dataset links on the GitHub repo.
What hardware and system resources are needed to run OpenChatKit?
- GPU: At least 16 GB VRAM for the 7 B‑parameter Pythia‑Chat‑Base‑7B model in fp16; larger 20 B models require higher‑end GPUs (24 GB+ recommended).
- RAM: 32 GB or more is comfortable for loading models and handling retrieval indexes.
- Software: Python 3.9+, PyTorch, conda/mamba; the repository provides an
environment.ymlthat installs required packages. - Consumer‑grade machines can run the 7 B model; the inference README notes it works on “consumer hardware”.

How do I set up OpenChatKit and run my first chatbot?
- Install Miniconda and Git LFS.
- Enable Git LFS hooks:
git lfs install
- Add mamba (faster than conda):
conda install mamba -n base -c conda-forge
- Create the environment using the repo’s file:
mamba env create -f environment.yml
- Activate it:
conda activate OpenChatKit
- Run the demo bot (downloads the model on first run):
python inference/bot.py --model togethercomputer/Pythia-Chat-Base-7B
The shell shows a prompt; type messages and see the model reply. Use /help for commands and /quit to exit.
- Optional fine‑tuning – follow the
training/README.mdfor scripts likefinetune_llama-2-7b-32k-mqa.sh.
For more details see the inference README and the official blog post announcing OpenChatKit.
Links:
- GitHub repository
- OpenChatKit announcement blog
- Bot script source
Who benefits most from OpenChatKit and who might skip it?
- Ideal users: Researchers or developers who want a fully open‑source base, need to experiment with retrieval‑augmented chat, or require a modifiable moderation layer. The modular design fits academic projects, niche domain bots, and hobbyist experimentation.
- May skip: Teams that need a turnkey SaaS solution with managed scaling, ultra‑low latency inference on very large models, or minimal engineering overhead. In those cases a hosted service or a higher‑level library like LangChain could be simpler.
- License: Apache‑2.0 permits commercial use, but you must retain attribution and include the license text.
What other open‑source conversational AI frameworks can I consider?
- Ollama – a local runtime that serves many open‑source LLMs with a simple API. See the internal guide /open-source/ollama-local-ai-runtime/.
- ExLlamaV2 – optimized for low‑VRAM environments; helpful if you run on 8‑12 GB GPUs. Details in /open-source/exllamav2-low-vram-guide/.
- LM Studio – a desktop UI for loading, prompting, and fine‑tuning community models. Learn more at /tools/lm-studio-local-ai-review/.
These alternatives differ in focus: Ollama emphasizes fast deployment, ExLlamaV2 targets memory‑constrained hardware, and LM Studio offers a graphical interface.
Menus and names can change as products update. If a step looks different, check the product's own help page.
Frequently asked questions
How can I fine‑tune a model with OpenChatKit?
OpenChatKit ships training scripts (e.g., training/finetune_llama-2-7b-32k-mqa.sh) and a prepare.py helper for dataset conversion; run them inside the prepared conda environment to produce checkpoint files.
What retrieval options does OpenChatKit support?
It provides an extensible retrieval system that can be hooked to a document index, API endpoint, or any live data source at inference time, allowing the bot to augment responses with up‑to‑date information.
Is OpenChatKit free for commercial use?
Yes. The project is released under the Apache 2.0 license, which permits commercial deployment as long as you keep the license notice and attribution.