|
<< Click to Display Table of Contents >> Navigation: 3. Script Language > AI - Artificial Intelligence Commands > LMS. - LM-Studio Commands > LMS. - LM Studio Interface |
MiniRobotLanguage (MRL)
LMS.Select Model Command
Find and Set a Model Intelligently
Intention
The LMS.Select Model command provides a powerful and user-friendly way to find and activate a model on the LM Studio server. Instead of requiring the exact, full model name, this command uses a tolerant, multi-stage search to find the best possible match for your input.
How it Works:
• 1. Exact Match: It first looks for a model name that is an exact (case-insensitive) match.
• 2. Contains Match: If no exact match is found, it searches for the first available model whose name contains your input text. For example, `"phi-3"` will match `"microsoft/Phi-3-mini-4k-instruct-q4" `.
• 3. Fuzzy Match: If still no match is found, it uses a Levenshtein distance algorithm to find the model name that is "closest" to your input, correcting for typos and minor differences.
Once a model is found, it is automatically set as the active model for all subsequent `LMS.ask` and `LMS.askex` commands.
Syntax
LMS.Select Model|P1|[P2]
Parameter Explanation
P1 - (Required) The search pattern for the model name (e.g., "phi-3" or "llama").
P2 - (Optional) A variable to store the full, exact name of the model that was found and loaded. If no match is found, this variable will be empty.
Example
'**********************************************
' LMS.Select Model - Sample
'**********************************************
'
' Use a partial name to find and load a model.
$$MOD = "phi-3-mini"
' The command will find the full model name, like "microsoft/Phi-3-mini-4k-instruct-q4".
LMS.Select Model|$$MOD|$$FULL
'
' Check if a model was successfully found and loaded.
IFV.$$FULL|==|
MBX.Error: Could not find a matching model for '$$MOD'.
ELS.
MBX.Successfully selected model: $$FULL
EIF.
ENR.
Remarks
This command requires a connection to the LM Studio server to retrieve the list of available models. If the server is not running, the command will fail and the return variable (P2) will be empty.
See also:
• LMS.Set Model - Set Model by Exact Name
• LMS.List Models - Get All Available Models
• LMS.AskEx - Extended AI Query