Quick start
Last updated
Last updated
This page gives an introduction to Parasail's Batch Processing Library. For more detailed information, jump to:
Parasail's batch processing engine is a very easy and inexpensive way to process thousands or millions of LLM inferences. Batch inferencing is easy: create an input file, start a batch job, wait for it to finish, then download the output.
OpenAI compatibility, Parasail batch helper library
The first step is to create a Parasail API key: . This key should be stored in your environment through something like a .bashrc file or a) .env file, or passed through the command line invocation. It is not recommended to paste directly in code as this is a common way of keys getting leaked.
Next, install openai-batch, our batch helper library that is compatible both with Parasail and OpenAI:
Now you're ready to run a batch job in as little as five lines of code! Our batch endpoint supports most transformers on HuggingFace, all you have to do is put the HuggingFace ID in the request. There is no need for this model to be a dedicated or serverless endpoint. In this example, we will use NousResearch/DeepHermes-3-Mistral-24B-Preview ().
This code will look for PARASAIL_API_KEY in the environment, and an easy way to pass it is through the command line. Running this code will produce the following output:
The first two lines of batch-itvt3wmjs7-output.jsonl
are the prompt responses:
Both Parasail and OpenAI limit the maximum size of the batch input files:
Up to 50,000 requests (lines)
Up to 500MB total input file size for Parasail
Up to 250MB total input file size for OpenAI
Max completion tokens for Parasail defaults to 8,192, but can be overridden to 16,384 through the max_completion_tokens
parameter.
A major convenience of batch processing is the ability to submit a job and resume the monitoring in a different process or flow. A developer can upload hundreds of batch jobs and millions of prompts without worrying about program crashes, errors, or resets - those prompts are processed on Parasail's servers until successful completion.
Changing the last two lines of the previous example will submit the job and print out the batch ID, then exit.
With a batch ID of batch-tclfzwczcd
we can now wait for the batch to finish and download it in a separate script:
Which outputs:
OpenAI Models
GritLM — developed by Contextual and hosted on HuggingFace by Parasail — and GTE-Qwen2-7B-Instruct from Alibaba are two excellent open source embeddding models that rival proprietary models. Embeddings like these can be easily run by changing messages
to input
.
Parameters
add_to_batch
supports all of the parameters that client.chat.completions.create
or client.embedding.create
supports, though note that open source models on parasail may not always support every parameter.
Metadata
The Parasail Batch UI can be used upload new batches, track the status of batches, and download results when finished.
While a batch is queued or running, you can view its status, download the input, or cancel it:
When a batch job is done, you can download the input and the output file as well as view the total token usage:
Batch Submission
Below is an example JSONL file, which follows the OpenAI format for batch submissions. Unlike the Parsail Batch Helper Library, this does not support OpenAI models and only supports open source HuggingFace transformers and embeddings.
Further Reading
Workloads exceeding these limits must be split into multiple batches. The add_to_batch
function in the will raise a ValueError
exception when the file size or request count is exceeded for the provider.
As seen below, we strongly recommend using encoding_format="base64"
to reduce the size of the output files for both Parasail and OpenAI.
Metadata can be added to the batch. This is useful for passing information between separate submit and download processes, as well as tracking the results on our status UI page. Any metadata added to the submission will be visible in the Batch UI progress section. For detailed information about the metadata field, see the .
Batches can be be submitted directly from the Batch section of our platform by clicking the Create Batch button. This brings up a dialog to upload a JSONL file.