You are viewing
main version, which requires installation from source. If you'd like
regular npm install, checkout the latest stable version (
v3.8.1).
Join the Hugging Face community
and get access to the augmented documentation experience
Collaborate on models, datasets and Spaces
Faster examples with accelerated inference
Switch between documentation themes
pipelines
Pipelines provide a high-level, easy to use, API for running machine learning models.
Example: Instantiate pipeline using the pipeline function.
import { pipeline } from '@huggingface/transformers';
const classifier = await pipeline('sentiment-analysis');
const output = await classifier('I love transformers!');
pipelines.pipeline(task, [model], [options]) ⇒ Promise. < AllTasks >
Utility factory method to build a Pipeline object.
Kind: static method of pipelines
Returns: Promise.<AllTasks> - A Pipeline object for the specified task.
Throws:
Error If an unsupported pipeline is requested.
| Param | Type | Default | Description |
| task | T | | The task defining which pipeline will be returned. Currently accepted tasks are: "audio-classification": will return a AudioClassificationPipeline. "automatic-speech-recognition": will return a AutomaticSpeechRecognitionPipeline. "depth-estimation": will return a DepthEstimationPipeline. "document-question-answering": will return a DocumentQuestionAnsweringPipeline. "feature-extraction": will return a FeatureExtractionPipeline. "fill-mask": will return a FillMaskPipeline. "image-classification": will return a ImageClassificationPipeline. "image-segmentation": will return a ImageSegmentationPipeline. "image-to-text": will return a ImageToTextPipeline. "object-detection": will return a ObjectDetectionPipeline. "question-answering": will return a QuestionAnsweringPipeline. "summarization": will return a SummarizationPipeline. "text2text-generation": will return a Text2TextGenerationPipeline. "text-classification" (alias "sentiment-analysis" available): will return a TextClassificationPipeline. "text-generation": will return a TextGenerationPipeline. "token-classification" (alias "ner" available): will return a TokenClassificationPipeline. "translation": will return a TranslationPipeline. "translation_xx_to_yy": will return a TranslationPipeline. "zero-shot-classification": will return a ZeroShotClassificationPipeline. "zero-shot-audio-classification": will return a ZeroShotAudioClassificationPipeline. "zero-shot-image-classification": will return a ZeroShotImageClassificationPipeline. "zero-shot-object-detection": will return a ZeroShotObjectDetectionPipeline.
|
| [model] | string | null | The name of the pre-trained model to use. If not specified, the default model for the task will be used. |
| [options] | PretrainedModelOptions | | Optional parameters for the pipeline. |
pipelines~AllTasks : string
All possible pipeline types.
Kind: inner typedef of pipelines
Update on GitHub