The rcd-llm-dmenu-launcher.sh script lets you select and launch LLMs via dmenu. It kills any running llama-server, launches the chosen model with its GPU layers (NGL), logs output, and provides audible feedback. A user-friendly LLM manager!
This project is built on top of the amazing llama.cpp project by @ggerganov.
The script is designed to manage and launch Large Language Models (LLMs) using a user-friendly interface (dmenu
). It allows you to:
- Select a model from a list of predefined LLM files.
- Kill any running instance of
llama-server
(if one exists). - Launch a new instance of
llama-server
with the selected model and its corresponding number of GPU layers (NGL
).
-
Model Selection:
- The script uses
dmenu
to display a list of LLM filenames (without full paths) for selection. - The
dmenu
interface is customized with specific styling:- Font:
DejaVu
with a pixel size of24
. - Colors: Foreground (
-nf
) is blue, and background (-nb
) is pink. - Behavior: Case-insensitive (
-i
) and displays up to10
lines (-l 10
).
- Font:
- The script uses
-
Dynamic Model Configuration:
- Models and their corresponding
NGL
(Number of GPU Layers) values are stored in an associative array (MODELS
). - Each model is mapped to its full file path and
NGL
value.
- Models and their corresponding
-
Process Management:
- The script checks if
llama-server
is already running usingpgrep
. - If a running instance is found, it kills the process before launching a new one.
- The script checks if
-
Logging:
- The output of
llama-server
is redirected to a log file (~/tmp/llm.log
) for debugging and monitoring.
- The output of
-
User Feedback:
- The script uses
espeak
to provide audible feedback when starting a new LLM instance. - It also prints the selected model and
NGL
value to the terminal.
- The script uses
-
Model List:
- The script defines an associative array (
MODELS
) where each key is the full path to an LLM file, and the value is the correspondingNGL
value.
- The script defines an associative array (
-
dmenu
Selection:- The script extracts the filenames (using
basename
) from theMODELS
array and displays them indmenu
. - The user selects a model from the list.
- The script extracts the filenames (using
-
Model Validation:
- The script maps the selected filename back to its full path and retrieves the corresponding
NGL
value.
- The script maps the selected filename back to its full path and retrieves the corresponding
-
Process Management:
- If
llama-server
is already running, the script kills the process using its PID. - It then launches a new instance of
llama-server
with the selected model andNGL
value.
- If
-
Logging and Feedback:
- The script logs the output of
llama-server
to~/tmp/llm.log
. - It provides audible and visual feedback to the user.
- The script logs the output of
-
Valid Model:
./rcd-llm-dmenu-launcher.sh QwQ-LCoT-3B-Instruct.Q4_K_M.gguf
- Output (if model exists):
Selected Model: /home/data1/protected/Programming/llamafile/QwQ-LCoT-3B-Instruct.Q4_K_M.gguf NGL: 999
- Output (if model exists):
-
Invalid Model:
./rcd-llm-dmenu-launcher.sh NonExistentModel.gguf
- Output:
Error: Model 'NonExistentModel.gguf' not found in the list.
- Output:
-
No Model Provided:
./rcd-llm-dmenu-launcher.sh
- Displays the
dmenu
interface for model selection.
A
dmenu
prompt appears with a list of LLM filenames: You are supposed to modify the list of GGUF files yourself within the script!QwQ-LCoT-3B-Instruct.Q4_K_M.gguf Phi-3.5-mini-instruct-Q3_K_M.gguf Qwen2.5-1.5B-Instruct-Q4_K_M.gguf Dolphin3.0-Qwen2.5-1.5B-Q5_K_M.gguf Dolphin3.0-Qwen2.5-3B-Q5_K_M.gguf OLMo-2-1124-7B-Instruct-Q3_K_M.gguf SmolLM-1.7B-Instruct-Q5_K_M.gguf DeepSeek-R1-Distill-Qwen-1.5B-Q5_K_M.gguf
- Displays the
Simply modify full path for your own models.
-
Select a model (e.g.,
QwQ-LCoT-3B-Instruct.Q4_K_M.gguf
). -
The script:
- Kills any running
llama-server
instance. - Launches a new instance with the selected model and its
NGL
value. - Logs the output to
~/tmp/llm.log
.
- Kills any running
Selected Model: /home/data1/protected/Programming/llamafile/QwQ-LCoT-3B-Instruct.Q4_K_M.gguf
NGL: 999
- "Starting Large Language Model with QwQ-LCoT-3B-Instruct.Q4_K_M.gguf"
-
Add/Remove Models:
- Edit the
MODELS
associative array to include or exclude models. - Example:
declare -A MODELS=( ["/path/to/model1.gguf"]=999 ["/path/to/model2.gguf"]=20 )
- Edit the
-
Change
dmenu
Styling:- Modify the
dmenu
command in the script to adjust font, colors, or behavior.
- Modify the
-
Log File Location:
- Change the
LOG
variable to specify a different log file path.
- Change the
-
dmenu
:- Required for model selection. Install it using your package manager:
sudo apt install dmenu
- Required for model selection. Install it using your package manager:
-
espeak
:- Used for audible feedback. Install it using:
sudo apt install espeak
- Used for audible feedback. Install it using:
-
llama-server
:- Ensure
llama-server
is installed and accessible in your$PATH
.
- Ensure
For quick access, bind the script to a key in your Window Manager or add it to a menu. Example for IceWM (~/.icewm/toolbar): plaintext
prog "LLM Model" /usr/share/icons/hicolor/scalable/apps/oregano.svg /home/data1/protected/bin/rcd/rcd-llm-dmenu-launcher.sh
The rcd-llm-dmenu-launcher.sh
script is a powerful and user-friendly tool for managing and launching Large Language Models. It combines the flexibility of dmenu
with robust process management and logging capabilities, making it an excellent choice for LLM workflows.