Skip to content

Commit

Permalink
Change float32 to float64
Browse files Browse the repository at this point in the history
  • Loading branch information
hupe1980 committed Sep 16, 2023
1 parent 54e89c6 commit 5b4a363
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
10 changes: 10 additions & 0 deletions _examples/feature_extraction/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,30 @@ func main() {

res1, err1 := ic.FeatureExtraction(context.Background(), &huggingface.FeatureExtractionRequest{
Inputs: []string{"Hello World"},
Options: huggingface.Options{
WaitForModel: huggingface.PTR(true),
},
})
if err1 != nil {
log.Fatal(err1)
}

fmt.Println("FeatureExtraction:")
fmt.Println(res1[0])
fmt.Println()

res2, err2 := ic.FeatureExtractionWithAutomaticReduction(context.Background(), &huggingface.FeatureExtractionRequest{
Inputs: []string{"Hello World"},
Model: "sentence-transformers/all-mpnet-base-v2",
Options: huggingface.Options{
WaitForModel: huggingface.PTR(true),
},
})
if err2 != nil {
log.Fatal(err2)
}

fmt.Println("FeatureExtractionWithAutomaticReduction:")
fmt.Println(res2[0])
fmt.Println()
}
4 changes: 2 additions & 2 deletions feature_extraction.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ type FeatureExtractionRequest struct {
}

// Response structure for the feature extraction endpoint
type FeatureExtractionResponse [][][][]float32
type FeatureExtractionResponse [][][][]float64

// Response structure for the feature extraction endpoint
type FeatureExtractionWithAutomaticReductionResponse [][]float32
type FeatureExtractionWithAutomaticReductionResponse [][]float64

// FeatureExtraction performs feature extraction using the specified model.
// It sends a POST request to the Hugging Face inference endpoint with the provided input data.
Expand Down
4 changes: 4 additions & 0 deletions huggingface.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,3 +203,7 @@ func contains[T comparable](collection []T, element T) bool {

return false
}

func PTR[T any](input T) *T {
return &input
}

0 comments on commit 5b4a363

Please sign in to comment.