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 Method Summary
From class org.tensorflow.lite.task.core.BaseTaskApi
void |
checkNotClosed()
|
synchronized void |
close()
|
abstract void |
deinit(long arg0)
|
void |
finalize()
|
long |
getNativeHandle()
|
boolean |
isClosed()
|
From class java.lang.Object
Object
|
clone()
|
boolean |
|
void |
finalize()
|
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
public List<Category>
classify (String text)
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 (File modelFile)
Parameters
modelFile |
The classification model File instance |
Parameters
context |
Android context |
modelPath |
Path to the classification model |
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 |
Protected Methods
protected void deinit (long
nativeHandle)