BertNLClassifier
Stay organized with collections
Save and categorize content based on your preferences.
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 |
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2021-10-15 UTC.
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"Missing the information I need"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"Too complicated / too many steps"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"Out of date"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"Samples / code issue"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"Other"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"Easy to understand"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"Solved my problem"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"Other"
}]