https://github.com/hupe1980/go-huggingface
🤗 Hugging Face Inference Client written in Go
https://github.com/hupe1980/go-huggingface
golang huggingface inference-api
Last synced: 3 months ago
JSON representation
🤗 Hugging Face Inference Client written in Go
- Host: GitHub
- URL: https://github.com/hupe1980/go-huggingface
- Owner: hupe1980
- License: mit
- Created: 2023-06-25T07:39:10.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-01-07T20:43:45.000Z (over 1 year ago)
- Last Synced: 2025-04-16T01:06:59.429Z (3 months ago)
- Topics: golang, huggingface, inference-api
- Language: Go
- Homepage:
- Size: 64.5 KB
- Stars: 48
- Watchers: 2
- Forks: 6
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 🤗 go-huggingface

[](https://pkg.go.dev/github.com/hupe1980/go-huggingface)
> 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.## Installation
```
go get github.com/hupe1980/go-huggingface
```## How to use
```golang
package mainimport (
"context"
"fmt"
"log"
"os""github.com/hupe1980/go-huggingface"
)func main() {
ic := huggingface.NewInferenceClient(os.Getenv("HUGGINGFACEHUB_API_TOKEN"))res, err := ic.ZeroShotClassification(context.Background(), &huggingface.ZeroShotClassificationRequest{
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!"},
Parameters: huggingface.ZeroShotClassificationParameters{
CandidateLabels: []string{"refund", "faq", "legal"},
},
})
if err != nil {
log.Fatal(err)
}fmt.Println(res[0].Sequence)
fmt.Println("Labels:", res[0].Labels)
fmt.Println("Scores:", res[0].Scores)
}
```
Output:
```text
Hi, I recently bought a device from your company but it is not working as advertised and I would like to get reimbursed!
Labels: [refund faq legal]
Scores: [0.8777876496315002 0.10522633790969849 0.016985949128866196]
```For more example usage, see [_examples](./_examples).
## License
[MIT](LICENCE)