github.com/hupe1980/go-huggingface@v0.0.15/_examples/question_answering/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.QuestionAnswering(context.Background(), &huggingface.QuestionAnsweringRequest{ 16 Inputs: huggingface.QuestionAnsweringInputs{ 17 Question: "What's my name?", 18 Context: "My name is Clara and I live in Berkeley.", 19 }, 20 }) 21 if err != nil { 22 log.Fatal(err) 23 } 24 25 fmt.Println("Answer:", res.Answer) 26 fmt.Println("Score:", res.Score) 27 fmt.Println("Start:", res.Start) 28 fmt.Println("End:", res.End) 29 }