You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`llm-batch-pipeline` is a generic LLM batch processing pipeline. It discovers and parses input files via a plugin system, renders OpenAI Batch API (or Ollama) requests, validates structured JSON outputs with a Pydantic schema, evaluates predictions against ground truth, and exports results to XLSX/JSON.
4
+
5
+
See the **Admin Guide** for installation/deployment, and the **Developer Guide** for how to extend the pipeline with custom plugins, prompts, schemas, and evaluation.
- Local LLM via Ollama: run an Ollama server (pull the model), then use `--backend ollama --base-url http://HOST:11434` (repeat `--base-url` for multi-server sharding).
46
+
- OpenAI API compatible local server (if supported by your server): use `--backend openai` and configure the OpenAI SDK base URL (commonly via `OPENAI_BASE_URL`).
47
+
48
+
## Test / Benchmark
49
+
- SpamAssassin corpus reference run: [`docs/benchmark-run.md`](docs/benchmark-run.md)
Copy file name to clipboardExpand all lines: docs/developer-guide.md
+50-2Lines changed: 50 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -109,7 +109,7 @@ class SentimentResult(BaseModel):
109
109
)
110
110
reason: str= Field(description="Explanation.")
111
111
112
-
# REQUIRED: the pipeline loads schemas by this name
112
+
# REQUIRED: `schema_loader` expects a symbol named `mySchema`
113
113
mySchema = SentimentResult
114
114
```
115
115
@@ -126,7 +126,6 @@ def register():
126
126
pre_filters=[MinRowFilter(min_rows=2)],
127
127
transformers=[NormalizeHeadersTransformer()],
128
128
post_filters=[],
129
-
default_schema_module="my_plugin.schema",
130
129
))
131
130
```
132
131
@@ -149,6 +148,55 @@ from my_plugin.plugin import register
149
148
register()
150
149
```
151
150
151
+
## Custom Prompt, Schema, and Evaluation (per batch)
152
+
153
+
The plugin system controls how inputs are parsed and preprocessed. Prompt/instructions, schema validation, and evaluation configuration are provided per *batch run*.
154
+
155
+
### Custom prompt (instructions)
156
+
157
+
The LLM `instructions` text is loaded from:
158
+
159
+
-`--prompt-file` (CLI) or `batches/<batch>/prompt.txt` (file in the batch directory)
160
+
- a built-in fallback prompt when neither exists
161
+
162
+
For submit-time overrides, use `--prompt-override` / `--prompt-override-file`.
163
+
The backends apply this by rewriting `body.instructions` for every request right before submission.
164
+
165
+
Your plugin’s `FileReader.package_for_llm()` controls the per-file content injected as the `input_text` part of the prompt.
166
+
167
+
### Custom Pydantic schema
168
+
169
+
Provide a schema via one of these mechanisms:
170
+
171
+
-`--schema-file path/to/schema.py`
172
+
- or a `schema.py` file placed in the batch directory (`batches/<batch>/schema.py`)
173
+
174
+
Your schema file must define `mySchema` (typically `class mySchema(BaseModel): ...` or `mySchema = SomeModel`).
175
+
The pipeline converts it to a strict JSON schema for structured outputs and then validates the LLM JSON against it.
176
+
177
+
Evaluation field mapping defaults to `label` and `confidence`. To evaluate other schema field names, use `--label-field` and `--confidence-field`.
178
+
179
+
Note: evaluation auto-detection of label/confidence from the schema runs only when `--schema-file` is explicitly provided.
180
+
If you rely solely on `batches/<batch>/schema.py`, set `--label-field` / `--confidence-field` explicitly.
181
+
182
+
### Custom evaluation
183
+
184
+
The built-in `evaluate` stage computes confusion matrix + precision/recall/F1 + accuracy, and optionally ROC/AUC for binary classification when `--positive-class` is set (and confidence is available).
185
+
186
+
It uses:
187
+
188
+
- Ground truth from `--ground-truth-csv` or `batches/<batch>/evaluation/ground-truth.csv`
189
+
- Category map from `--category-map` or `batches/<batch>/evaluation/category-map.json`
190
+
191
+
Supported 'custom evaluation' via plugins:
192
+
193
+
- Implement `OutputTransformer` in your plugin to reshape `validated_rows` before evaluation/export (e.g. rename/move fields so they match `--label-field` / `--confidence-field`).
194
+
195
+
If you need entirely different evaluation metrics/logic:
0 commit comments