Text Processing
Explore how ML.NET leverages PyTorch for advanced text processing with deep learning. Understand training and consuming models for sentiment analysis and sentence similarity, and learn to implement these tasks using specific ML.NET API methods.
We'll cover the following...
ML.NET is capable of using deep learning for advanced text analysis, such as accurate sentiment analysis and assessing sentence similarities. For these purposes, ML.NET uses a popular open-source ML library known as PyTorch. In ML.NET, this library is accessed via some NuGet packages.
The following playground demonstrates how two types of text analysis tasks can be done in the context of deep learning in ML.NET with the help of PyTorch:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<PlatformTarget>x64</PlatformTarget>
<Nullable>disable</Nullable>
</PropertyGroup>
<ItemGroup>
<Compile Remove="ImageClassificationDemo.training.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.ML" Version="3.0.0-preview.23266.6" />
<PackageReference Include="Microsoft.ML.TorchSharp" Version="0.21.0-preview.23266.6" />
<PackageReference Include="TorchSharp-cuda-linux" Version="0.99.5" />
</ItemGroup>
</Project>
Note: PyTorch dependencies might take a couple of minutes to build if we lauch the playground.
PyTorch dependencies
First, we'll need to install the relevant dependencies. If we open the MLApp.csproj file, we'll see the following NuGet ...