TransformersTextRouter
Routes the text strings to different connections based on a category label.
Basic Information
- Type:
haystack_integrations.routers.transformers_text_router.TransformersTextRouter
Inputs
| Parameter | Type | Default | Description |
|---|---|---|---|
| text | str | A string of text to route. |
Outputs
| Parameter | Type | Default | Description |
|---|
Overview
Work in Progress
Bear with us while we're working on adding pipeline examples and most common components connections.
Routes the text strings to different connections based on a category label.
The labels are specific to each model and can be found it its description on Hugging Face.
Usage Example
components:
TransformersTextRouter:
type: components.routers.transformers_text_router.TransformersTextRouter
init_parameters:
Parameters
Init Parameters
These are the parameters you can configure in Pipeline Builder:
| Parameter | Type | Default | Description |
|---|---|---|---|
| model | str | The name or path of a Hugging Face model for text classification. | |
| labels | Optional[List[str]] | None | The list of labels. If not provided, the component fetches the labels from the model configuration file hosted on the Hugging Face Hub using transformers.AutoConfig.from_pretrained. |
| device | Optional[ComponentDevice] | None | The device for loading the model. If None, automatically selects the default device. If a device or device map is specified in huggingface_pipeline_kwargs, it overrides this parameter. |
| token | Optional[Secret] | Secret.from_env_var(['HF_API_TOKEN', 'HF_TOKEN'], strict=False) | The API token used to download private models from Hugging Face. If True, uses either HF_API_TOKEN or HF_TOKEN environment variables. To generate these tokens, run transformers-cli login. |
| huggingface_pipeline_kwargs | Optional[Dict[str, Any]] | None | A dictionary of keyword arguments for initializing the Hugging Face text classification pipeline. |
Run Method Parameters
These are the parameters you can configure for the component's run() method. This means you can pass these parameters at query time through the API, in Playground, or when running a job. For details, see Modify Pipeline Parameters at Query Time.
| Parameter | Type | Default | Description |
|---|---|---|---|
| text | str | A string of text to route. |
Was this page helpful?