hf

package
v0.0.0-...-c27917d Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const StopToken = "<|im_end|>"

Variables

This section is empty.

Functions

This section is empty.

Types

type BestOfSequence

type BestOfSequence struct {
	FinishReason    string  `json:"finish_reason"`
	GeneratedText   string  `json:"generated_text"`
	GeneratedTokens int     `json:"generated_tokens"`
	Prefill         []Token `json:"prefill"`
	Seed            int     `json:"seed"`
	Tokens          []Token `json:"tokens"`
}

type Details

type Details struct {
	BestOfSequences []BestOfSequence `json:"best_of_sequences"`
	FinishReason    string           `json:"finish_reason"`
	GeneratedTokens int              `json:"generated_tokens"`
	Prefill         []Token          `json:"prefill"`
	Seed            int              `json:"seed"`
	Tokens          []Token          `json:"tokens"`
}

type GenerateParameters

type GenerateParameters struct {
	BestOf              *int     `json:"best_of,omitempty"`
	DecoderInputDetails bool     `json:"decoder_input_details,omitempty"`
	Details             bool     `json:"details,omitempty"`
	DoSample            bool     `json:"do_sample,omitempty"`
	MaxNewTokens        int      `json:"max_new_tokens,omitempty"`
	RepetitionPenalty   *float32 `json:"repetition_penalty,omitempty"`
	ReturnFullText      *bool    `json:"return_full_text,omitempty"`
	Seed                *int64   `json:"seed,omitempty"`
	Stop                []string `json:"stop,omitempty"`
	Temperature         *float32 `json:"temperature,omitempty"`
	TopK                *int     `json:"top_k,omitempty"`
	TopP                *float32 `json:"top_p,omitempty"`
	Truncate            *int     `json:"truncate,omitempty"`
	TypicalP            *float32 `json:"typical_p,omitempty"`
	Watermark           bool     `json:"watermark,omitempty"`
}

type GenerateRequest

type GenerateRequest struct {
	Inputs     string             `json:"inputs"`
	Parameters GenerateParameters `json:"parameters"`
	Stream     bool               `json:"stream"`
}

type GenerateResponse

type GenerateResponse struct {
	Details       *Details `json:"details"`
	GeneratedText string   `json:"generated_text"`
}

type GenerateStreamResponse

type GenerateStreamResponse struct {
	Token         *Token      `json:"token"`
	GeneratedText string      `json:"generated_text"` // Assuming it can be of any type, hence using `interface{}`
	Details       interface{} `json:"details"`        // Assuming it can be of any type, hence using `interface{}`
}

type Handler

type Handler struct {
	Prefix string
}

Handler is a HuggingFace handler

func (*Handler) Routes

func (h *Handler) Routes(r *gin.Engine)

Routes maps the routes

type Token

type Token struct {
	ID      int     `json:"id"`
	Text    string  `json:"text"`
	Logprob float32 `json:"logprob"`
	Special bool    `json:"special"`
}

Jump to

Keyboard shortcuts

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