Smart Shell » Linux Magazine
The PaLMShell.bash script allows users to connect to the Google Pathways API Large Language Model (PaLM) directly from the command line. This simple Bash script acts as an interface to the Google Pathways large language model (LLM) API over a RESTful API, providing a straightforward method of access compared to more complex implementations in high-level compiled languages. With this script, users only require a shell script – no additional libraries, packages, or configuration files are needed.
Large Language Models (LLMs)
Large Language Models, known as LLMs, have gained significant popularity recently. These models are neural networks trained on massive amounts of data using substantial computing power, resulting in models with potentially billions of parameters. One of the most well-known LLMs is ChatGPT (Chat Generative Pre-trained Transformer) from OpenAI, trained with 175 billion parameters and launched in 2022 as an interactive chatbot. Other notable LLMs include LLaMA (Large Language Model Meta AI) from Meta and BLOOM (BigScience Large Open-science Open-access Multilingual Language Model) created collaboratively by over 1,000 artificial intelligence researchers for large-scale public accessibility.
Google PaLM and PaLM2
Google's Pathways Language Model (PaLM), introduced in April 2022 and trained on 540 billion parameters, is the focus of the shell-based LLM client discussed in this article. PaLM, now part of Google Gemini within the Google AI Studio, is a versatile LLM capable of generalizing across domains and tasks efficiently. In May 2023, Google announced the successor to PaLM, PaLM2, marking the next evolution of their LLM technology. The Google PaLM service is accessible through the PaLM API, a RESTful interface to the online LLM service.
Developing a Bash-based PaLM Client
Accessing the Google PaLM RESTful API with a Bash script requires an API key obtainable through an online request process, typically taking a few days for approval. The objectives of a Bash script functioning as a PaLM shell are:
- Successful connection to the Google PaLM RESTful API via HTTP.
- Simple operation with one shell command for exiting the shell.
- Automatic logging and session recording as a shell transcript to a file.
Implementation Details
External utilities such as date and tr were utilized in constructing the PaLM shell Bash script, with the primary phases of the script being:
- Initialization: Setting up the PaLM API key, reporting version, date, and license, and creating the external log file name.
- Infinite Command Loop (REPL): Continuously reading, echoing prompts, printing to the user, and recording to an external file until the termination command 'bye' is entered.
- De-initialization: Finalizing the exit message and cleanly exiting the Bash shell script.
Developing a Bash-based PaLM client offers a user-friendly approach to accessing the Google PaLM service efficiently from the command line, simplifying interaction with the PaLM API for various applications.