Using GPT4All in the command line on an Intel Mac

With the following script, you can run yet another large language model, namely GPT4All, locally on your command line. GPT4All creates its own application, also for OS X, but I had trouble installing it.

As today, there are some issues with Intel Macs. It's on their roadmap, they will probably fix it sooner than later. But for now, you can use it in the command line with the following script.

All installation and compilation instructions are included and, as always, feel free to use it. It's very small and it's licensed under MIT. Enjoy!

#!/usr/bin/env bash set -e _log_error() { printf "\033[0;31m%s\033[0m\n" "${1}" } INSTALL_PATH=~/src/github/nomic-ai/gpt4all-chat if [ ! -d "$INSTALL_PATH" ]; then _log_error "Failed to locate repository" echo "Please execute" echo "mkdir -p ~/src/github/nomic-ai" echo "cd ~/src/github/nomic-ai" echo "git clone --recurse-submodules https://github.com/nomic-ai/gpt4all-chat" exit 1 fi BIN_PATH=$INSTALL_PATH/ggml/build/bin/gpt-j if [ ! -f "$BIN_PATH" ]; then _log_error "Failed to locate binary" echo "Please execute" echo "cd $INSTALL_PATH/ggml" echo "mkdir build" echo "cd build" echo "cmake .." echo "cmake --build . --parallel" exit 1 fi MODEL_PATH=$INSTALL_PATH/ggml/build/ggml-gpt4all-j.bin if [ ! -f "$MODEL_PATH" ]; then _log_error "Failed to locate language model" echo "Please execute" echo "cd $(dirname $MODEL_PATH)" echo "wget https://gpt4all.io/models/ggml-gpt4all-j.bin" exit 1 fi $BIN_PATH -m $MODEL_PATH -n 200 --top_k 40 --top_p 0.9 -b 9 --temp 0.2 "$@"

You can start the script as follows:

./gpt4all -p "What are a few common characteristics of, dare I say, well maintained software? The answer is as follows:"
echo "What are a few common characteristics of, dare I say, well maintained software? The answer is as follows:" | ./gpt4all

As always, feedback is highly welcome.