Search⌘ K
AI Features

Solution Review: Consuming Sentence Similarity Model

Explore how to consume a sentence similarity model in ML.NET by modifying code to accept user inputs and output similarity scores. Understand how the model compares phrases and the importance of context in interpreting results.

We'll cover the following...

The complete solution is available in the following playground:

<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>
Sentence similarity solution

Solving the challenge

We modify the code inside the Program.cs file: ...