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 | |
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
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 |