This folder contains simple command-line tools for easily trying out the C++ Text Task APIs.
You will need:
In the console, run:
# Download the model: curl \ -L 'https://tfhub.dev/tensorflow/lite-model/mobilebert/1/default/1?lite-format=tflite' \ -o /tmp/mobilebert.tflite # Run the classification tool: bazel run -c opt \ tensorflow_lite_support/examples/task/text/desktop:bert_question_answerer_demo -- \ --model_path=/tmp/mobilebert.tflite \ --question="Where is Amazon rainforest?" \ --context="The Amazon rainforest, alternatively, the Amazon Jungle, also known in \ English as Amazonia, is a moist broadleaf tropical rainforest in the Amazon \ biome that covers most of the Amazon basin of South America. This basin \ encompasses 7,000,000 km2 (2,700,000 sq mi), of which \ 5,500,000 km2 (2,100,000 sq mi) are covered by the rainforest. This region \ includes territory belonging to nine nations."
In the console, you should get:
answer[0]: 'South America.' logit: 1.84847, start_index: 39, end_index: 40 answer[1]: 'most of the Amazon basin of South America.' logit: 1.2921, start_index: 34, end_index: 40 answer[2]: 'the Amazon basin of South America.' logit: -0.0959535, start_index: 36, end_index: 40 answer[3]: 'the Amazon biome that covers most of the Amazon basin of South America.' logit: -0.498558, start_index: 28, end_index: 40 answer[4]: 'Amazon basin of South America.' logit: -0.774266, start_index: 37, end_index: 40
You will need:
In the console, run:
# Download the model: curl \ -L 'https://storage.googleapis.com/download.tensorflow.org/models/tflite/text_classification/text_classification_v2.tflite' \ -o /tmp/movie_review.tflite # Run the detection tool: bazel run -c opt \ tensorflow_lite_support/examples/task/text/desktop:nl_classifier_demo -- \ --model_path=/tmp/movie_review.tflite \ --text="What a waste of my time." \ --input_tensor_name="input_text" \ --output_score_tensor_name="probability"
In the console, you should get:
category[0]: 'Negative' : '0.81313' category[1]: 'Positive' : '0.18687'
TODO(b/163086702): Update the links to models with metadata attached.
You will need:
In the console, run:
# Download the model: curl \ -L 'https://url/to/bert/nl/classifier' \ -o /tmp/bert_movie_review.tflite # Run the segmentation tool: bazel run -c opt \ tensorflow_lite_support/examples/task/text/desktop:bert_nl_classifier_demo -- \ --model_path=/tmp/bert_movie_review.tflite \ --text="it's a charming and often affecting journey"
In the console, you should get:
category[0]: 'negative' : '0.00006' category[1]: 'positive' : '0.99994'