A bulk AI writing job with Ollama is not a single batch API call. It is a script that reads one prompt per line from a JSONL or TXT file, sends each prompt to your local Ollama server as a non-streaming request, and writes every response to disk as it arrives. Two documented approaches cover most needs: a small sequential batch tool that tracks progress, and a concurrent pipeline that adds retries and per-result checkpointing so a long run can survive a crash.
This guide is for a technically curious beginner or intermediate practitioner who already has Ollama installed and wants to push hundreds or thousands of drafting, rewriting, or summarization tasks through a local model. It concentrates on pipeline mechanics rather than prompt craft, and it separates what the cited sources document from what you should measure on your own hardware.
What a bulk writing job actually looks like on Ollama
Ollama runs a local HTTP service, and the community batch tooling assumes it is listening on port 11434 (ollama-batch-requests). The documented “batch-style” usage is the non-streaming form of a request: the stream parameter is set to false, so the model returns one complete response instead of a token stream that your client would have to reassemble (Markaicode).
That distinction matters when you are planning scale. There is no documented server-side endpoint that accepts thousands of prompts in a single call. The batch inputs used by the community script are described as being based on OpenAI’s batch API and Ollama’s /generate endpoint documentation, which means the batching is orchestrated entirely by your code: your script owns the queue, the concurrency, the retries, and the storage of results.
When local Ollama is the wrong tool
A local pipeline is not automatically the right answer, and the Markaicode tutorial states the counterargument plainly. If you are processing fewer than a few hundred records as a one-off, a plain for loop calling the CLI is simpler and easier to debug than concurrent threads. If you need guaranteed throughput SLAs or horizontal autoscaling, a managed inference endpoint removes the operational burden of running and monitoring a local server. And if your data must not touch local disk unencrypted, or you need an audited processing trail, an existing ETL or orchestration tool such as Airflow or Dagster with an LLM step is the better fit than a standalone script.
Local Ollama earns its place when the job is large enough that manual runs are painful, the data should stay on your machine, and you are willing to own retry and checkpoint logic yourself.
Prerequisites before the first run
- Ollama installed and running locally, with the API reachable on port 11434 (the port assumed by the community batch tool).
- At least one model pulled locally. The documented JSONL example uses
llama3.1:8b, but any pulled model can be named in the request. - Python with the
requestsandtqdmpackages installed for the sequential batch tool. - An input file in JSONL or TXT format, plus enough disk space for the output file.
- A deliberate decision about concurrency, because worker count and GPU memory interact.
Two documented patterns, and how to choose between them
The two sources describe genuinely different designs. One processes requests sequentially and shows progress; the other runs concurrent worker threads, retries transient failures, and checkpoints results. The table below compares only the features the sources actually document.
| Dimension | Sequential batch tool | Concurrent pipeline |
|---|---|---|
| Processing model | Sequential requests with progress tracking | Concurrent worker threads |
| Failure handling | Not documented in the source | Retries transient failures with exponential backoff |
| Progress safety | Progress bar during the run | Checkpoints every result to disk as it completes |
| Input formats | JSONL and TXT | JSONL |
| Setup effort | Clone the repository and install two packages | Build and test against a small sample: 30–45 minutes if Ollama is installed and a model is pulled |
| Best suited to | Hundreds of records, simple debugging, quick one-offs | Long runs where losing progress or exhausting the GPU is the main risk |
Pattern A: a sequential JSONL batch run
This is the fastest route to a working bulk job, and it is the right starting point for a first experiment.
- Get the tool. Clone the
ollama-batch-requestsrepository and change into its directory. - Install dependencies with
pip install requests tqdm. - Confirm Ollama is running locally on port 11434 before launching anything.
- Prepare the input file. The documented JSONL object format carries a custom ID, a model, an optional system message, the prompt, and the stream flag:
{"custom_id": "chat-1", "model": "llama3.1:8b", "system": "You are a helpful assistant.", "prompt": "How are you?", "stream": false}A plain TXT file with one prompt per line also works when you do not need per-request configuration.
- Run the script with
python src/main.py. - Check the output. Responses are saved to
src/data/output.jsonlfor JSONL input, or to a TXT file for TXT input.
The tool also supports overriding the model for an entire batch and a single-request mode for testing an individual prompt with an optional system message — useful for validating a prompt template before committing to a long run.
Pattern B: a concurrent pipeline with retries and checkpointing
When a run is long enough that restarting from zero would hurt, the Markaicode design adds three things: concurrent worker threads, exponential-backoff retries for transient failures, and a checkpoint written to disk for every completed result. The stated goal is a batch that finishes without losing progress or exhausting the GPU.
- Export prompts to JSONL with a stable
custom_idper row. That identifier is what makes the run resumable and deduplicable later. - Start a small worker pool. Begin conservatively rather than with a large thread count.
- Send one non-streaming request per prompt and collect the full response. A minimal illustrative sketch of the request shape looks like this:
import requests resp = requests.post( "http://localhost:11434/api/generate", json={ "model": "llama3.1:8b", "prompt": "Draft a 120-word product description for ...", "stream": False, }, timeout=300, ) resp.raise_for_status() text = resp.json()["response"]This snippet is illustrative and was not tested for this article; verify field names and endpoint paths against the current official Ollama API reference before relying on it.
- Retry transient failures with exponential backoff instead of failing the whole job.
- Checkpoint each result immediately, keyed by
custom_id, so a crash costs you at most the in-flight requests. - Resume by skipping completed IDs when you restart, which keeps the run idempotent.
- Reconcile counts at the end: input rows versus output rows versus error rows.
Designing prompts and outputs for writing tasks
Bulk writing jobs live or die on template discipline. The documented JSONL schema separates a system field from the prompt field, which is the natural place to put stable style instructions — voice, reading level, forbidden phrases — while the prompt carries only the per-record variable content. Because every record passes through the same template, a flaw in the template is replicated across the entire batch, so test it on a handful of rows first.
Record the model name and any sampling settings alongside each output. Without that metadata, a batch produced last week is not reproducible, and you will not be able to explain why two halves of the same job read differently.
Throughput, GPU pressure, and concurrency limits
Concurrency is the parameter most likely to surprise you. The Markaicode tutorial frames the pipeline’s purpose as finishing without exhausting the GPU, which implies that adding workers is not free. Local inference contends for the same accelerator memory, and each in-flight request carries its own context, so memory use grows with both concurrency and prompt length rather than with model weights alone.
Neither source publishes a recommended worker count or measured throughput figures, so treat any specific number as something you must establish on your own machine. A practical approach is to start with a small pool, watch memory and response latency, and increase only while both stay stable. If latency climbs sharply as you add workers, you have passed the point where concurrency helps.
Verifying a bulk run before you use the output
A completed run is not a correct run. Before the output goes anywhere, confirm that the number of results matches the number of input rows, that no custom_id appears twice, and that failures are logged rather than silently dropped. Then spot-check a sample across the length of the file: early rows, middle rows, and late rows, because a template that degrades under long context will show up late rather than early.
For anything that will be published, human review is not optional. Bulk generation is a drafting accelerator, and factual accuracy, tone, and brand consistency still require a reader.
Common failure modes and fixes
The following are diagnostic hypotheses ordered from the cheapest check to the most involved.
- Requests fail immediately with a connection error. Confirm Ollama is actually running and listening on port 11434, the port the community tool assumes. This is the most common cause and the quickest to rule out.
- The model name is rejected. Check the exact tag in the request against the models you have pulled locally; the documented example uses
llama3.1:8b. - The input file fails to parse. JSONL requires exactly one complete JSON object per line. Trailing commas, multi-line objects, and blank lines are the usual culprits.
- Output is missing or overwritten. Verify the output path the tool writes to (
src/data/output.jsonlfor JSONL input) and avoid running two jobs that target the same file. - A long run dies partway through. This is the failure mode checkpointing exists to solve. If you are on the sequential pattern, re-running from the start is the only documented recovery, which is the main reason to move to the concurrent design as jobs grow.
- Responses look truncated. Treat this as a context-window hypothesis and test shorter prompts or a different model before changing pipeline code.
Fitting bulk generation into a WordPress workflow
The natural handoff is a JSONL file in and a JSONL file out. An illustrative design — not a tested integration — is to export post IDs and source material into the input file, use the post ID as the custom_id, run the batch to produce drafts, excerpts, or meta descriptions, then map each result back to its post and import it through WP-CLI or the WordPress REST API as a draft. Keeping the custom_id equal to the post ID makes that mapping mechanical and makes duplicate detection trivial. Nothing should be published automatically; the import step should land content in draft status for editorial review.
A sensible next step
Start smaller than you think you need to. Build a 20-to-50-row sample from your real input data, run it through the sequential tool first to confirm your prompt template and output format, then run the same sample through a concurrent pipeline with checkpointing and compare wall-clock time, failure behavior, and memory pressure. Only after both behave predictably should you point the pipeline at the full dataset. If you hit an error, a throughput wall, or a template that degrades at scale, share your environment, model tag, worker count, and the observed symptom in the community so others can reproduce it.
FAQ
Does Ollama have a native batch endpoint that accepts many prompts at once?
The sources do not describe one. The documented batch-style usage is a non-streaming request per prompt, and the community tool's batch inputs are described as based on OpenAI's batch API and Ollama's /generate endpoint documentation — meaning your script performs the batching.
How many concurrent workers should I use for a local writing job?
Neither cited source publishes a recommended number or measured throughput. The documented design goal is finishing without exhausting the GPU, so start with a small worker pool, watch memory and latency, and increase only while both remain stable.
What happens if my bulk run is interrupted halfway?
It depends on the pattern. The sequential tool documents progress tracking but no resume mechanism, so you re-run from the start. The concurrent pipeline checkpoints every result to disk as it completes, so a restarted run can skip completed custom_ids.
Can I publish the generated text directly?
The sources do not address publication. For anything factual or brand-facing, treat the output as a draft: verify counts and identifiers programmatically, then route results into draft status for human editorial review.