github.com/hupe1980/go-huggingface@v0.0.15/_examples/sentence_similarity/main.go (about) 1 package main 2 3 import ( 4 "context" 5 "fmt" 6 "log" 7 "os" 8 9 "github.com/hupe1980/go-huggingface" 10 ) 11 12 func main() { 13 ic := huggingface.NewInferenceClient(os.Getenv("HUGGINGFACEHUB_API_TOKEN")) 14 15 res, err := ic.SentenceSimilarity(context.Background(), &huggingface.SentenceSimilarityRequest{ 16 Inputs: huggingface.SentenceSimilarityInputs{ 17 SourceSentence: "That is a happy person", 18 Sentences: []string{"That is a happy dog", "That is a very happy person", "Today is a sunny day"}, 19 }, 20 Model: "sentence-transformers/all-MiniLM-L6-v2", 21 }) 22 if err != nil { 23 log.Fatal(err) 24 } 25 26 fmt.Println(res) 27 }