This API starts a GPT2 text generation process and waits for the response.
import booste
out_list = booste.gpt2(api_key, in_string, length)
Arg | Description | Required | Type | Example |
---|---|---|---|---|
api_key | Your API key, found on the User Dashboard | True | string | "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' |
in_string | The given sequence of words | True | string | "I went on a walk and suddenly, I" |
length | The quantity of words to predict following the in_string | False (default=5) | int | 10 |
List - the predicted text, separated into list form.
To convert to string, add:
out_string = " ".join(out_list)
Adjusting these parameters from the default is not recommended.
Arg | Description | Required | Type | Example |
---|---|---|---|---|
temperature | A value between 0.1 and 1, to adjust randomness. - Smaller values create seemingly random output. - Larger values create repeating phrases in the output. |
False (default=0.8) | float | 0.8 |
window_max | A value between 1 and 1023, to manage inference workload. GPT-2 can only accept an input string less than 1024 words long. Booste uses a "sliding window" approach to handle longer length requests, where the input string is trimmed to the n=window_max most recent words. - Smaller values will generate text quickly (0.3 sec/word), but output will drift to unrelated topics due to lost context. - Larger values will generate text slowly (2 min/word), but output will retain more context. |
False (default=100) | int | 250 |
This is the asynchronous version of the API.
It starts a GPT2 text generation process and returns a task_id.
import booste
task_id = booste.gpt2_async_start(api_key, in_string, length)
Arg | Description | Required | Type | Example |
---|---|---|---|---|
api_key | Your API key, found on the User Dashboard | True | string | "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' |
in_string | The given sequence of words | True | string | "I went on a walk and suddenly, I" |
length | The quantity of words to predict following the in_string | False (default=5) | int | 10 |
String - a task ID for your inference job.
Use this task_id with the async check function at a later time to check on the job.
Adjusting these parameters from the default is not recommended.
Arg | Description | Required | Type | Example |
---|---|---|---|---|
temperature | A value between 0.1 and 1, to adjust randomness. - Smaller values create seemingly random output. - Larger values create repeating phrases in the output. |
False (default=0.8) | float | 0.8 |
window_max | A value between 1 and 1023, to manage inference workload. GPT-2 can only accept an input string less than 1024 words long. Booste uses a "sliding window" approach to handle longer length requests, where the input string is trimmed to the n=window_max most recent words. - Smaller values will generate text quickly (0.3 sec/word), but output will drift to unrelated topics due to lost context. - Larger values will generate text slowly (2 min/word), but output will retain more context. |
False (default=100) | int | 250 |
This is the asynchronous version of the API.
It checks on an existing GPT2 text generation process and returns the status.
import booste
dict_out = booste.gpt2_async_check(api_key, task_id)
Arg | Description | Required | Type | Example |
---|---|---|---|---|
api_key | Your API key, found on the User Dashboard | True | string | "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' |
task_id | The task ID returned by the async start function | True | string | "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" |
Dict - a dictionary structured as follows:
If the job is still running or has failed:
{
'Status': job_status,
'TaskID': task_id
}
If the job was successful:
{
'Status': job_status,
'Output': out_list
}