Classifier API for NLClassification tasks with Bert models, categorizes string into different
classes. The API expects a Bert based TFLite model with metadata populated.
The metadata should contain the following information:
- 1 input_process_unit for Wordpiece/Sentencepiece Tokenizer.
- 3 input tensors with names "ids", "mask" and "segment_ids".
- 1 output tensor of type float32[1, 2], with a optionally attached label file. If a label
file is attached, the file should be a plain text file with one label per line, the number
of labels should match the number of categories the model outputs.
Inherited Methods
From class
java.lang.Object
boolean
|
|
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
From interface
java.lang.AutoCloseable
Public Methods
Performs classification on a string input, returns classified Category
s.
Parameters
text |
input text to the model. |
Returns
- A list of Category results.
public
static
BertNLClassifier
createFromFile
(Context context, String modelPath)
Parameters
context |
Android context |
modelPath |
Path to the classification model |
public
static
BertNLClassifier
createFromFile
(File modelFile)
Parameters
modelFile |
The classification model File instance |
Parameters
modelFile |
The classification model File instance |
options |
to configure the classifier |
Parameters
context |
Android context. |
modelPath |
Path to the classification model |
options |
to configure the classifier |