taskflow#

class Taskflow(task, model=None, mode=None, device_id=0, from_hf_hub=False, **kwargs)[source]#

Bases: object

The Taskflow is the end2end interface that could convert the raw text to model result, and decode the model result to task result. The main functions as follows:
  1. Convert the raw text to task result.

  2. Convert the model to the inference model.

  3. Offer the usage and help message.

Parameters:
  • task (str) – The task name for the Taskflow, and get the task class from the name.

  • model (str, optional) – The model name in the task, if set None, will use the default model.

  • mode (str, optional) – Select the mode of the task, only used in the tasks of word_segmentation and ner. If set None, will use the default mode.

  • device_id (int, optional) – The device id for the gpu, xpu and other devices, the defalut value is 0.

  • kwargs (dict, optional) – Additional keyword arguments passed along to the specific task.

help()[source]#

Return the task usage message.

task_path()[source]#

Return the path of current task

static tasks()[source]#

Return the available task list.