Back to Tensorflow

BertCluAnnotator

tensorflow/lite/g3doc/api_docs/java/org/tensorflow/lite/task/text/bertclu/BertCluAnnotator.html

2.21.05.8 KB
Original Source

public class BertCluAnnotator

API for BERT-based Conversational Language Understanding.

The API expects a Bert based TFLite model with metadata populated. The metadata should contain the following information:

  • input_process_units for Wordpiece Tokenizer.
  • 3 input tensors with names "ids", "mask" and "segment_ids".
  • 6 output tensors with names "domain_task/names", "domain_task/scores", "intent_task/names", "intent_task/scores", "slot_task/names", and "slot_task/scores".

Nested Classes

| class | BertCluAnnotator.BertCluAnnotatorOptions | Options for setting up a BertCluAnnotator. |

Public Methods

| CluResponse | annotate(CluRequest cluRequest) Annotates the input utterances.

| | static BertCluAnnotator | createFromBufferAndOptions(ByteBuffer modelBuffer, BertCluAnnotator.BertCluAnnotatorOptions options) Creates a BertCluAnnotator instance with a model buffer and BertCluAnnotator.BertCluAnnotatorOptions.

| | static BertCluAnnotator | createFromFile(Context context, String modelPath) Creates a BertCluAnnotator instance from a filepath.

|

Inherited Methods

From class org.tensorflow.lite.task.core.BaseTaskApi

| synchronized void | close() Release the memory allocated from C++ and deregister the library from the static holder.

| | long | getNativeHandle() | | boolean | isClosed() |

From class java.lang.Object

| boolean | equals(Object arg0) | | final Class<?> | getClass() | | int | hashCode() | | final void | notify() | | final void | notifyAll() | | String | toString() | | final void | wait(long arg0, int arg1) | | final void | wait(long arg0) | | final void | wait() |

From interface java.io.Closeable

| abstract void | close() |

From interface java.lang.AutoCloseable

| abstract void | close() |

Public Methods

public CluResponse annotate (CluRequest cluRequest)

Annotates the input utterances.

Parameters

| cluRequest | input dialogue encoded in a CluRequest |

Returns
  • domain, intent, and slot annotations encoded in a CluResponse

public static BertCluAnnotator createFromBufferAndOptions (ByteBuffer modelBuffer, BertCluAnnotator.BertCluAnnotatorOptions options)

Creates a BertCluAnnotator instance with a model buffer and BertCluAnnotator.BertCluAnnotatorOptions.

Parameters

| modelBuffer | a direct ByteBuffer or a MappedByteBuffer of the annotator model | | options | |

Throws

| IllegalArgumentException | if the model buffer is not a direct ByteBuffer or a MappedByteBuffer | | IllegalStateException | if there is an internal error | | RuntimeException | if there is an otherwise unspecified error |

public static BertCluAnnotator createFromFile (Context context, String modelPath)

Creates a BertCluAnnotator instance from a filepath.

Parameters

| context | | | modelPath | path of the annotator model |

Throws

| IOException | if an I/O error occurs when loading the tflite model | | IllegalArgumentException | if an argument is invalid | | IllegalStateException | if there is an internal error | | RuntimeException | if there is an otherwise unspecified error |