Documentation
¶
Overview ¶
Package huggingface is the best library to fetch files from an huggingface repository.
Index ¶
- func AuthRequest(ctx context.Context, h *http.Client, method, url, token string, ...) (*http.Response, error)
- type Client
- func (c *Client) EnsureFile(ctx context.Context, ref ModelRef, revision, file string) (string, error)
- func (c *Client) EnsureSnapshot(ctx context.Context, ref ModelRef, revision string, glob []string) ([]string, error)
- func (c *Client) GetFileInfo(ctx context.Context, ref ModelRef, revision, file string) (string, string, int64, error)
- func (c *Client) GetModelInfo(ctx context.Context, m *Model, ref string) error
- type Model
- type ModelRef
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the client for https://huggingface.co/.
func New ¶
New returns a new *Client client to download files and list repositories.
It uses the endpoints as described at https://huggingface.co/docs/hub/api.
Respects the following environment variables described at https://huggingface.co/docs/huggingface_hub/package_reference/environment_variables: HF_HOME, HF_HUB_CACHE, HF_TOKEN_PATh and HF_TOKEN.
func (*Client) EnsureFile ¶
func (c *Client) EnsureFile(ctx context.Context, ref ModelRef, revision, file string) (string, error)
EnsureFile ensures the file is available, downloads it otherwise.
Similar to https://huggingface.co/docs/huggingface_hub/package_reference/file_download
func (*Client) EnsureSnapshot ¶
func (c *Client) EnsureSnapshot(ctx context.Context, ref ModelRef, revision string, glob []string) ([]string, error)
EnsureSnapshot ensures files available from the snapshot, downloads them otherwise.
Downloads files concurrently.
type Model ¶
type Model struct { ModelRef // Upstream is the upstream repo when the model is based on another one. Upstream ModelRef // Tensor is the native quantization of the weight. This is found in // config.json in Upstream. TensorType safetensors.DType // Number of weights. Has direct impact on performance and memory usage. NumWeights int64 // ContentLength is the number of tokens that the LLM can take as context // when relevant. Has impact on performance and memory usage. Not relevant // for image generators. ContextLength int // License is the license of the weights, for whatever that means. Use the // name for well known licences (e.g. "Apache v2.0" or "MIT") or an URL for // custom licenses. License string // LicenseURL is the URL to the license file. LicenseURL string // Files is the list of files in the repository. Files []string // Created is the time the repository was created. It can be at the earliest // 2022-03-02 as documented at // https://huggingface.co/docs/hub/api#repo-listing-api. Created time.Time // Modified is the last time the repository was modified. Modified time.Time // SHA of the reference requested. SHA string // contains filtered or unexported fields }
Model is a model stored on https://huggingface.co
type ModelRef ¶
type ModelRef struct { // Author is the owner, either a person or an organization. Author string // Repo is the name of the repository owned by the Author. Repo string // contains filtered or unexported fields }
ModelRef is a reference to a model stored on https://huggingface.co