Compute cosine similarity between a source sentence and a list of candidate sentences.
This example assumes using HuggingFace; is in scope and apiKey contains your HuggingFace API key.
1 2 3 4 5 6 7 8 9101112131415161718
usingvarclient=newHuggingFaceEmbeddingClient(apiKey);varscores=awaitclient.SimilarityAsync(inputs:newSimilarityInput{SourceSentence="What is Deep Learning?",Sentences=[ "Deep Learning is a subset of Machine Learning.", "The weather is sunny today.", "Neural networks are inspired by the human brain.", ],});for(vari=0;i<scores.Count;i++){Console.WriteLine($"[{i}] similarity={scores[i]:F4}");}