This class represents a large language model. Members accessible from instances of this class are listed here:
Class constructor:
LLM
LLM(
name,
options)
Arguments
name: the name of the modeloptions(Object) (default{}): an object containing the options used by this instance
Return type
An instance of
LLM
Usage
let model = MLL("cohere.command", {max_tokens: 10})
Unloads the model that was loaded in the constructor. This is optional, but recommended, since doing so can reduce memory usage; after unloading, any subsequent attempt to use the instance raises an error.
Arguments
None
Return type
undefined
Usage
model.unload()
This method acts as a wrapper for
ML_GENERATE, and generates a
response using the prompt and options provided for the loaded
model.
Arguments
prompt(String): prompt to be used for text generationoptions(Object) (default{}): an object containing the options used by this instance; see the description ofML_GENERATEfor available options
Return type
Object: The structure is similar to that ofML_GENERATE.
Usage
let response = model.generate("What is MySql?", {"top_k": 2, "task": "generation"})
This method is a wrapper for
ML_EMBED_ROW, and generates an
embedding whose type corresponds to the MySQL
VECTOR type.
Arguments
query(String): The text of the query to be embeddedoptions(Object) (optional; default{}): an object containing the options used for embedding; see the description ofML_EMBED_ROWfor available options
Return type
Float32Array(MySQLVECTOR): The embedding
Usage
let embedding = model.embed("What is MySql?")
This method performs Retrieval Augmented Generation for a
given query using the loaded genAI model, acting as a wrapper
of ML_RAG.
Arguments
query(String): The text of the query to be used for generationoptions(Object) (default{}): The options employed for generation; these follow the same rules as the options used withLLM.generate()
Return type
Object: The structure is similar to that of the object returned byML_RAG.
Usage
let result = model.rag("What is MySql?", {schema: ["vector_store"], n_citations: 1})