modelfile

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// File size thresholds and workspace limits
	WeightFileSizeThreshold int64 = 128 * humanize.MByte // 128MB - threshold for considering file as weight file
	MaxSingleFileSize       int64 = 128 * humanize.GByte // 128GB - maximum size for a single file
	MaxWorkspaceFileCount   int   = 2048                 // 2048 files - maximum number of files in workspace
	MaxTotalWorkspaceSize   int64 = 8 * humanize.TByte   // 8TB - maximum total workspace size
)

Variables

View Source
var (
	// Config file patterns - supported configuration file extensions.
	ConfigFilePatterns = []string{
		"*.json",
		"*.jsonl",
		"*.json5",
		"*.jsonc",
		"*.yaml",
		"*.yml",
		"*.toml",
		"*.ini",
		"*.config",
		"*.cfg",
		"*.conf",
		"*.properties",
		"*.props",
		"*.prop",
		"*.xml",
		"*.xsd",
		"*.rng",

		"*.modelcard",
		"*.meta",
		"*tokenizer.model*",
		"config.json.*",
		"*.hparams",
		"*.params",
		"*.hyperparams",
		"*.wandb",
		"*.mlflow",
		"*.tensorboard",
	}

	// Model file patterns - supported model file extensions.
	ModelFilePatterns = []string{

		"*.safetensors",

		"*.bin",
		"*.pt",
		"*.pth",
		"*.mar",
		"*.pte",
		"*.pt2",
		"*.ptl",

		"*.tflite",
		"*.h5",
		"*.hdf",
		"*.hdf5",
		"*.pb",
		"*.meta",
		"*.data-*",
		"*.index",

		"*.gguf",
		"*.ggml",
		"*.ggmf",
		"*.ggjt",
		"*.q4_0",
		"*.q4_1",
		"*.q5_0",
		"*.q5_1",
		"*.q8_0",
		"*.f16",
		"*.f32",

		"*.ckpt",
		"*.checkpoint",
		"*.dist_ckpt",

		"*.tensor",
		"*.weights",
		"*.state",
		"*.embedding",
		"*.vocab",

		"*.ot",
		"*.engine",
		"*.trt",
		"*.onnx",
		"*.msgpack",
		"*.model",
		"*.pkl",
		"*.pickle",
		"*.keras",
		"*.joblib",
		"*.npy",
		"*.npz",
		"*.nc",
		"*.mlmodel",
		"*.coreml",
		"*.mleap",
		"*.surml",
		"*.llamafile",
		"*.caffemodel",
		"*.prototxt",
		"*.dlc",
		"*.circle",
		"*.nb",
	}

	// Code file patterns - supported script and notebook files.
	CodeFilePatterns = []string{}/* 140 elements not displayed */

	// Doc file patterns - supported documentation files
	DocFilePatterns = []string{}/* 103 elements not displayed */

)

Functions

func IsFileType

func IsFileType(filename string, patterns []string) bool

IsFileType checks if the filename matches any of the given patterns

func SizeShouldBeWeightFile added in v0.0.4

func SizeShouldBeWeightFile(size int64) bool

For large unknown file type, usually it is a weight file.

Types

type Modelfile

type Modelfile interface {
	// GetConfigs returns the args of the config command in the modelfile,
	// and deduplicates the args. The order of the args is the same as the
	// order in the modelfile.
	GetConfigs() []string

	// GetModels returns the args of the model command in the modelfile,
	// and deduplicates the args. The order of the args is the same as the
	// order in the modelfile.
	GetModels() []string

	// GetCode returns the args of the code command in the modelfile,
	// and deduplicates the args. The order of the args is the same as the
	// order in the modelfile.
	GetCodes() []string

	// GetDatasets returns the args of the dataset command in the modelfile,
	// and deduplicates the args. The order of the args is the same as the
	// order in the modelfile.
	GetDatasets() []string

	// GetDocs returns the args of the doc command in the modelfile,
	// and deduplicates the args. The order of the args is the same as the
	// order in the modelfile.
	GetDocs() []string

	// GetName returns the value of the name command in the modelfile.
	GetName() string

	// GetArch returns the value of the arch command in the modelfile.
	GetArch() string

	// GetFamily returns the value of the family command in the modelfile.
	GetFamily() string

	// GetFormat returns the value of the format command in the modelfile.
	GetFormat() string

	// GetParamsize returns the value of the paramsize command in the modelfile.
	GetParamsize() string

	// GetPrecision returns the value of the precision command in the modelfile.
	GetPrecision() string

	// GetQuantization returns the value of the quantization command in the modelfile.
	GetQuantization() string

	// Content returns the content of the modelfile.
	Content() []byte
}

Modelfile is the interface for the modelfile. It is used to parse the modelfile by the path and get the information of the modelfile.

func NewModelfile

func NewModelfile(path string) (Modelfile, error)

NewModelfile creates a new modelfile by the path of the modelfile. It parses the modelfile and returns the modelfile interface.

func NewModelfileByWorkspace

func NewModelfileByWorkspace(workspace string, config *configmodelfile.GenerateConfig) (Modelfile, error)

NewModelfileByWorkspace creates a new modelfile by the workspace.

It generates the modelfile by the following steps:

  1. It walks the workspace and gets the files, and generates the modelfile by the files.
  2. It generates the modelfile by the model config, such as config.json and generation_config.json.
  3. It generates the modelfile by the generate config, such as name, arch, family, format, paramsize, precision, and quantization.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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