github.com/hupe1980/go-huggingface@v0.0.15/_examples/zero_shot_classification/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.ZeroShotClassification(context.Background(), &huggingface.ZeroShotClassificationRequest{
    16  		Inputs: []string{"Hi, I recently bought a device from your company but it is not working as advertised and I would like to get reimbursed!"},
    17  		Parameters: huggingface.ZeroShotClassificationParameters{
    18  			CandidateLabels: []string{"refund", "faq", "legal"},
    19  		},
    20  	})
    21  	if err != nil {
    22  		log.Fatal(err)
    23  	}
    24  
    25  	fmt.Println(res[0].Sequence)
    26  	fmt.Println("Labels:", res[0].Labels)
    27  	fmt.Println("Scores:", res[0].Scores)
    28  }