Skip to content

Commit 608e163

Browse files
authored
[docs] Follow up register_pipeline (huggingface#35310)
example json
1 parent 94fe0b9 commit 608e163

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

docs/source/en/add_new_pipeline.md

+17-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ class PairClassificationPipeline(Pipeline):
184184
```
185185

186186
The implementation is framework agnostic, and will work for PyTorch and TensorFlow models. If we have saved this in
187-
a file named `pair_classification.py`, we can then import it and register it like this. The [register_pipeline](https://github.com/huggingface/transformers/blob/9feae5fb0164e89d4998e5776897c16f7330d3df/src/transformers/pipelines/base.py#L1387) function registers the pipeline details (task type, pipeline class, supported backends) to a models `config.json` file.
187+
a file named `pair_classification.py`, we can then import it and register it like this.
188188

189189
```py
190190
from pair_classification import PairClassificationPipeline
@@ -199,6 +199,22 @@ PIPELINE_REGISTRY.register_pipeline(
199199
)
200200
```
201201

202+
The [register_pipeline](https://github.com/huggingface/transformers/blob/9feae5fb0164e89d4998e5776897c16f7330d3df/src/transformers/pipelines/base.py#L1387) function registers the pipeline details (task type, pipeline class, supported backends) to a models `config.json` file.
203+
204+
```json
205+
"custom_pipelines": {
206+
"pair-classification": {
207+
"impl": "pair_classification.PairClassificationPipeline",
208+
"pt": [
209+
"AutoModelForSequenceClassification"
210+
],
211+
"tf": [
212+
"TFAutoModelForSequenceClassification"
213+
],
214+
}
215+
},
216+
```
217+
202218
Once this is done, we can use it with a pretrained model. For instance `sgugger/finetuned-bert-mrpc` has been
203219
fine-tuned on the MRPC dataset, which classifies pairs of sentences as paraphrases or not.
204220

0 commit comments

Comments
 (0)