package
0.1.1
Repository: https://github.com/gomlx/go-huggingface.git
Documentation: pkg.go.dev

# README

hub package

Downloads HuggingFace Hub files, a port of huggingFace_hub python library to Go.

Introduction

A simple, straight-forward port of github.com/huggingface/huggingface_hub library for Go.

Features supported:

  • Cache system that matches HuggingFace Hub, so the same cache can be shared with Python.
  • Concurrency safe: only one download when multiple workers are trying to download simultaneously the same model.
  • Allow arbitrary progress function to be called (for progress bar).
  • Arbitrary revision.
  • Parallel download of files, max=20 by default.

TODOs:

  • Add support for optional parameters.
  • Authentication tokens: should be relatively easy.
  • Resume downloads from interrupted connections.
  • Check disk-space before starting to download.

Example

Enumerate files from a HuggingFace repository and download all of them to a cache.

	repo := hub.New(modelID).WithAuth(hfAuthToken)
	var fileNames []string
	for fileName, err := range repo.IterFileNames() {
		if err != nil { panic(err) }
		fmt.Printf("\t%s\n", fileName)
		fileNames = append(fileNames, fileName)
	}
	downloadedFiles, err := repo.DownloadFiles(fileNames...)
	if err != nil { ... }

# Functions

DefaultCacheDir for HuggingFace Hub, same used by the python library.
DefaultHttpUserAgent returns a user agent to use with HuggingFace Hub API.
New creates a reference to a HuggingFace model given its id.

# Constants

No description provided by the author
No description provided by the author
No description provided by the author
RepoIdSeparator is used to separate repository/model names parts when mapping to file names.
No description provided by the author
No description provided by the author
No description provided by the author

# Variables

DefaultDirCreationPerm is used when creating new cache subdirectories.
DefaultFileCreationPerm is used when creating files inside the cache subdirectories.
SessionId is unique and always created anew at the start of the program, and used during the life of the program.

# Structs

FileInfo represents one of the model file, in the Info structure.
Repo from which one wants to download files.
RepoInfo holds information about a HuggingFace repo, it is the json served when hitting the URL https://huggingface.co/api/<repo_type>/<model_id> TODO: Not complete, only holding the fields used so far by the library.
SafeTensorsInfo holds counts on number of parameters of various types.

# Type aliases

RepoType supported by HuggingFace-Hub.