github.com/hupe1980/go-huggingface@v0.0.15/README.md (about)

     1  # 🤗 go-huggingface
     2  ![Build Status](https://github.com/hupe1980/go-huggingface/workflows/build/badge.svg) 
     3  [![Go Reference](https://pkg.go.dev/badge/github.com/hupe1980/go-huggingface.svg)](https://pkg.go.dev/github.com/hupe1980/go-huggingface)
     4  > The Hugging Face Inference Client in Golang is a modul designed to interact with the Hugging Face model repository and perform inference tasks using state-of-the-art natural language processing models. Developed in Golang, it provides a seamless and efficient way to integrate Hugging Face models into your Golang applications.
     5  
     6  ## Installation
     7  ```
     8  go get github.com/hupe1980/go-huggingface
     9  ```
    10  
    11  ## How to use
    12  ```golang
    13  package main
    14  
    15  import (
    16  	"context"
    17  	"fmt"
    18  	"log"
    19  	"os"
    20  
    21  	"github.com/hupe1980/go-huggingface"
    22  )
    23  
    24  func main() {
    25  	ic := huggingface.NewInferenceClient(os.Getenv("HUGGINGFACEHUB_API_TOKEN"))
    26  
    27  	res, err := ic.ZeroShotClassification(context.Background(), &huggingface.ZeroShotClassificationRequest{
    28  		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!"},
    29  		Parameters: huggingface.ZeroShotClassificationParameters{
    30  			CandidateLabels: []string{"refund", "faq", "legal"},
    31  		},
    32  	})
    33  	if err != nil {
    34  		log.Fatal(err)
    35  	}
    36  
    37  	fmt.Println(res[0].Sequence)
    38  	fmt.Println("Labels:", res[0].Labels)
    39  	fmt.Println("Scores:", res[0].Scores)
    40  }
    41  ```
    42  Output:
    43  ```text
    44  Hi, I recently bought a device from your company but it is not working as advertised and I would like to get reimbursed!
    45  Labels: [refund faq legal]
    46  Scores: [0.8777876496315002 0.10522633790969849 0.016985949128866196]
    47  ```
    48  
    49  For more example usage, see [_examples](./_examples).
    50  
    51  ## License
    52  [MIT](LICENCE)