puthuggingface

package
v8.18.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 17, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Create a Hugging Face inference endpoint.

Create an inference endpoint to perform an inference task with the `hugging_face` service.

You must first create an inference endpoint on the Hugging Face endpoint page to get an endpoint URL. Select the model you want to use on the new endpoint creation page (for example `intfloat/e5-small-v2`), then select the sentence embeddings task under the advanced configuration section. Create the endpoint and copy the URL after the endpoint initialization has been finished.

The following models are recommended for the Hugging Face service:

* `all-MiniLM-L6-v2` * `all-MiniLM-L12-v2` * `all-mpnet-base-v2` * `e5-base-v2` * `e5-small-v2` * `multilingual-e5-base` * `multilingual-e5-small`

When you create an inference endpoint, the associated machine learning model is automatically deployed if it is not already running. After creating the endpoint, wait for the model deployment to complete before using it. To verify the deployment status, use the get trained model statistics API. Look for `"state": "fully_allocated"` in the response and ensure that the `"allocation_count"` matches the `"target_allocation_count"`. Avoid creating multiple endpoints for the same model unless required, as each endpoint consumes significant resources.

Index

Constants

This section is empty.

Variables

View Source
var ErrBuildPath = errors.New("cannot build path, check for missing path parameters")

ErrBuildPath is returned in case of missing parameters within the build of the request.

Functions

This section is empty.

Types

type NewPutHuggingFace

type NewPutHuggingFace func(tasktype, huggingfaceinferenceid string) *PutHuggingFace

NewPutHuggingFace type alias for index.

func NewPutHuggingFaceFunc

func NewPutHuggingFaceFunc(tp elastictransport.Interface) NewPutHuggingFace

NewPutHuggingFaceFunc returns a new instance of PutHuggingFace with the provided transport. Used in the index of the library this allows to retrieve every apis in once place.

type PutHuggingFace

type PutHuggingFace struct {
	// contains filtered or unexported fields
}

func New

Create a Hugging Face inference endpoint.

Create an inference endpoint to perform an inference task with the `hugging_face` service.

You must first create an inference endpoint on the Hugging Face endpoint page to get an endpoint URL. Select the model you want to use on the new endpoint creation page (for example `intfloat/e5-small-v2`), then select the sentence embeddings task under the advanced configuration section. Create the endpoint and copy the URL after the endpoint initialization has been finished.

The following models are recommended for the Hugging Face service:

* `all-MiniLM-L6-v2` * `all-MiniLM-L12-v2` * `all-mpnet-base-v2` * `e5-base-v2` * `e5-small-v2` * `multilingual-e5-base` * `multilingual-e5-small`

When you create an inference endpoint, the associated machine learning model is automatically deployed if it is not already running. After creating the endpoint, wait for the model deployment to complete before using it. To verify the deployment status, use the get trained model statistics API. Look for `"state": "fully_allocated"` in the response and ensure that the `"allocation_count"` matches the `"target_allocation_count"`. Avoid creating multiple endpoints for the same model unless required, as each endpoint consumes significant resources.

https://www.elastic.co/guide/en/elasticsearch/reference/current/infer-service-hugging-face.html

func (*PutHuggingFace) ChunkingSettings

func (r *PutHuggingFace) ChunkingSettings(chunkingsettings types.InferenceChunkingSettingsVariant) *PutHuggingFace

The chunking configuration object. API name: chunking_settings

func (PutHuggingFace) Do

func (r PutHuggingFace) Do(providedCtx context.Context) (*Response, error)

Do runs the request through the transport, handle the response and returns a puthuggingface.Response

func (*PutHuggingFace) ErrorTrace

func (r *PutHuggingFace) ErrorTrace(errortrace bool) *PutHuggingFace

ErrorTrace When set to `true` Elasticsearch will include the full stack trace of errors when they occur. API name: error_trace

func (*PutHuggingFace) FilterPath

func (r *PutHuggingFace) FilterPath(filterpaths ...string) *PutHuggingFace

FilterPath Comma-separated list of filters in dot notation which reduce the response returned by Elasticsearch. API name: filter_path

func (*PutHuggingFace) Header

func (r *PutHuggingFace) Header(key, value string) *PutHuggingFace

Header set a key, value pair in the PutHuggingFace headers map.

func (*PutHuggingFace) HttpRequest

func (r *PutHuggingFace) HttpRequest(ctx context.Context) (*http.Request, error)

HttpRequest returns the http.Request object built from the given parameters.

func (*PutHuggingFace) Human

func (r *PutHuggingFace) Human(human bool) *PutHuggingFace

Human When set to `true` will return statistics in a format suitable for humans. For example `"exists_time": "1h"` for humans and `"eixsts_time_in_millis": 3600000` for computers. When disabled the human readable values will be omitted. This makes sense for responses being consumed only by machines. API name: human

func (PutHuggingFace) Perform

func (r PutHuggingFace) Perform(providedCtx context.Context) (*http.Response, error)

Perform runs the http.Request through the provided transport and returns an http.Response.

func (*PutHuggingFace) Pretty

func (r *PutHuggingFace) Pretty(pretty bool) *PutHuggingFace

Pretty If set to `true` the returned JSON will be "pretty-formatted". Only use this option for debugging only. API name: pretty

func (*PutHuggingFace) Raw

func (r *PutHuggingFace) Raw(raw io.Reader) *PutHuggingFace

Raw takes a json payload as input which is then passed to the http.Request If specified Raw takes precedence on Request method.

func (*PutHuggingFace) Request

func (r *PutHuggingFace) Request(req *Request) *PutHuggingFace

Request allows to set the request property with the appropriate payload.

func (*PutHuggingFace) Service

The type of service supported for the specified task type. In this case, `hugging_face`. API name: service

func (*PutHuggingFace) ServiceSettings

func (r *PutHuggingFace) ServiceSettings(servicesettings types.HuggingFaceServiceSettingsVariant) *PutHuggingFace

Settings used to install the inference model. These settings are specific to the `hugging_face` service. API name: service_settings

type Request

type Request struct {

	// ChunkingSettings The chunking configuration object.
	ChunkingSettings *types.InferenceChunkingSettings `json:"chunking_settings,omitempty"`
	// Service The type of service supported for the specified task type. In this case,
	// `hugging_face`.
	Service huggingfaceservicetype.HuggingFaceServiceType `json:"service"`
	// ServiceSettings Settings used to install the inference model. These settings are specific to
	// the `hugging_face` service.
	ServiceSettings types.HuggingFaceServiceSettings `json:"service_settings"`
}

Request holds the request body struct for the package puthuggingface

https://github.com/elastic/elasticsearch-specification/blob/f6a370d0fba975752c644fc730f7c45610e28f36/specification/inference/put_hugging_face/PutHuggingFaceRequest.ts#L29-L91

func NewRequest

func NewRequest() *Request

NewRequest returns a Request

func (*Request) FromJSON

func (r *Request) FromJSON(data string) (*Request, error)

FromJSON allows to load an arbitrary json into the request structure

type Response

type Response struct {

	// ChunkingSettings Chunking configuration object
	ChunkingSettings *types.InferenceChunkingSettings `json:"chunking_settings,omitempty"`
	// InferenceId The inference Id
	InferenceId string `json:"inference_id"`
	// Service The service type
	Service string `json:"service"`
	// ServiceSettings Settings specific to the service
	ServiceSettings json.RawMessage `json:"service_settings"`
	// TaskSettings Task settings specific to the service and task type
	TaskSettings json.RawMessage `json:"task_settings,omitempty"`
	// TaskType The task type
	TaskType tasktype.TaskType `json:"task_type"`
}

Response holds the response body struct for the package puthuggingface

https://github.com/elastic/elasticsearch-specification/blob/f6a370d0fba975752c644fc730f7c45610e28f36/specification/inference/put_hugging_face/PutHuggingFaceResponse.ts#L22-L24

func NewResponse

func NewResponse() *Response

NewResponse returns a Response

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL