
Using ONNX BERT Model for Text-based Q&A in your Mobile .NET Apps
In the first article of this series, I explained how to load, evaluate and convert a PyTorch-trained BERT QnA model to an ONNX-compatible format. In the second article, I explained how to load an ONNX Model, perform processing tasks on both the input and output and connect the prediction pipeline to the frontend UI. In this article, I will give a high-level overview of how to load the converted ONNX BERT model trained using PyTorch. Getting Started The BERT QnA model aims to recognize the context in each text input by looking in both forward & backward directions and provide a text-based human-readable answer as output. This code base provides a more interactive feel by allowing users to input text as a question and context, and the BERT ONNX model will reply with a text-based answer. NuGet Packages Used The following NuGet packages were installed in the Uno platform application project for this code base. Microsoft ML OnnxRuntime Skia Sharp BERT Tokenizers INFERENCING WITH PyTorchBertQnA The TensorFlowMNISTClassifier C# file houses the class-based code for loading, processing, and prediction tasks. STEP 1: Load Embedded Resources In the 1st article of this series, we mentioned the large .onnx file that was created