thanosql.generate()
generate
function in ThanoSQL is designed to generate text based on a given input using a pre-trained text generation model. This function leverages the capabilities of the HuggingFace Transformers library to provide efficient and high-quality text generation.
Parameter | Type | Default | Description | Options |
---|---|---|---|---|
engine | string | 'huggingface' | The engine to use for text generation. | 'huggingface' : Uses models from HuggingFace. 'thanosql' : Uses ThanoSQL’s native models. 'openai' : Uses models from OpenAI. |
input | string | The input text based on which the text generation will occur. | N/A | |
model | string | The name or path of the pre-trained text generation model. | Example: 'meta-llama/Meta-Llama-3-8B' | |
model_args | json | None | JSON string representing additional arguments for the model. | Example: '{"max_new_tokens": 50}' Common Parameters: max_new_tokens , temperature , top_p , top_k |
token | string | None | Token for authentication if required by the model. | N/A |
base_url | string | None | Base URL to point the client to a different endpoint than the default OpenAI API endpoint. This is only applicable when the engine is openai . | N/A |
generate
function using Hugging Face LLM:
generate
function using ThanoSQL LLM:
generate
function with various input formats for the OpenAI LLM:
generate
function with the base URL using the OpenAI Client:
generate
function with the huggingface
engine, ensure that only models compatible with the HuggingFace pipeline are used. Verify that the selected model is supported by the HuggingFace library to avoid compatibility issues. Even with compatible models, some models might still not work. We are actively working on improving compatibility and functionality to provide a better user experience. For more information, refer to the official Hugging Face documentation.cleanup_resources
function after loading up the LLM model. This helps prevent models from being loaded in CPU memory, which is particularly useful in a workspace with limited resources.generate
function allows for advanced configuration through the model_args
parameter, which accepts additional model arguments in JSON format. This enables fine-tuning of the text generation process to better suit specific needs.
model_args
:
Parameter | Type | Description |
---|---|---|
max_tokens (OpenAI), max_new_tokens (Hugging Face) | integer | Maximum number of tokens to generate. |
temperature | float | Sampling temperature. Lower values make output more focused, higher values make it more random. |
top_p | float | Nucleus sampling probability. Controls diversity by sampling from the top probability mass. Used as alternative to tempearture |
max_tokens
and temperature
:
temperature
or use top_p
instead:
max_tokens/max_new_tokens
parameter accordingly: