When piping the output of one terminal command to another on a Unix-based system, by default only the Standard Output (stdout) of the first command is piped to the Standard Input (stdin) of the second command.
We can merge streams to make sure stderr is piped to the second command.
The general syntax is:
$ cmd1 2>&1 | cmd2
For a specific example: the “No such file” error below is sent to Standard Error.
The word count command receives an empty input.
$ cat invalid-file | wc
cat: invalid-file: No such file or directory
0 0 0
Now, if we merge streams, Standard Error is piped to word-count and the number of characters in the error message is counted and printed:
$ cat invalid-file 2>&1 | wc
1 7 45
This shows that en error output was sent through the pipe to the second command.
We can run a Large Language Model (LLM) – although not quite as good as ChatGPT – on a local machine.
One of the easiest to run is Alpaca, a fine-tuning of LLaMA.
The following works on an Apple M1 Mac.
Clone and build the repo:
$ git clone https://github.com/antimatter15/alpaca.cpp
$ cd alpaca.cpp/
$ make chat
Download the pre-trained model weights:
$ wget -O ggml-alpaca-7b-q4.bin -c https://gateway.estuary.tech/gw/ipfs/QmQ1bf2BTnYxq73MFJWu1B7bQ2UD6qG7D7YDCxhTndVkPC
(See the source repo below for alternatives if this fails).
Run the model:
main: seed = 1679968451
llama_model_load: loading model from 'ggml-alpaca-7b-q4.bin' - please wait ...
llama_model_load: ggml ctx size = 4529.34 MB
llama_model_load: memory_size = 512.00 MB, n_mem = 16384
llama_model_load: loading model part 1/1 from 'ggml-alpaca-7b-q4.bin'
llama_model_load: .................................... done
llama_model_load: model size = 4017.27 MB / num tensors = 291
== Running in chat mode. ==
- Press Ctrl+C to interject at any time.
- Press Return to return control to LLaMa.
- If you want to submit another line, end your input in '\'.
> What is the age of the universe?
The current estimate for when our Universe was created,
according to modern cosmology and astronomy,
is 13.798 billion years ago (±0.2%).