forked from CloudNativeAI/model-spec
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
spec: add initial model config definition
Right now we define a lot of model general information as annotations. They should be defined as a field of model config. We use the guidelines below to decide if a model artifact description should be an annotation or in a structured config file: * If a description belongs to a specific layer, it SHOULD be an annotation * If a description describes a general property of the model, it SHOULD be in a config Also a `ModelFS` structure is introduced to describe the ordering of multiple layers. Fixes: CloudNativeAI#19 Fixes: CloudNativeAI#22 Signed-off-by: Peng Tao <[email protected]>
- Loading branch information
Showing
3 changed files
with
109 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
/* | ||
* Copyright 2025 The CNAI Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package v1 | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/opencontainers/go-digest" | ||
) | ||
|
||
// ModelConfig defines the execution parameters | ||
// which should be used as a base when running a model using an inference engine. | ||
type ModelConfig struct { | ||
// The model architecture, such as transformer, cnn, rnn, etc. | ||
Architecture string `json:"architecture,omitempty"` | ||
|
||
// The model format, such as onnx, tensorflow, pytorch, etc. | ||
Format string `json:"format,omitempty"` | ||
|
||
// The size of the model parameters | ||
ParameterSize uint64 `json:"parameterSize,omitempty"` | ||
|
||
// The model precision, such as bf16, fp16, int8, mixed etc. | ||
Precision string `json:"precision,omitempty"` | ||
|
||
// The model quantization, such as awq, gptq, etc | ||
Quantization string `json:"puantization,omitempty"` | ||
} | ||
|
||
// ModelFS describes a layer content addresses | ||
type ModelFS struct { | ||
// Type is the type of the rootfs. MUST be set to "layers". | ||
Type string `json:"type"` | ||
|
||
// DiffIDs is an array of layer content hashes (DiffIDs), in order from bottom-most to top-most. | ||
DiffIDs []digest.Digest `json:"diff_ids"` | ||
} | ||
|
||
// ModelDescriptor defines the general information of a model | ||
type ModelDescriptor struct { | ||
// Date and time on which the model was built | ||
CreateTime *time.Time `json:"createTime,omitempty"` | ||
|
||
// The contact details of the people or organization responsible for the model | ||
Authors []string `json:"authors,omitempty"` | ||
|
||
// The model family, such as llama3, gpt2, qwen2, etc. | ||
Family string `json:"family,omitempty"` | ||
|
||
// The model name, such as llama3-8b-instruct, gpt2-xl, qwen2-vl-72b-instruct, etc. | ||
Name string `json:"name,omitempty"` | ||
|
||
// The URL to find more information on the model | ||
InfoURL string `json:"infoURL,omitempty"` | ||
|
||
// The URL to get documentation on the model | ||
DocURL string `json:"docURL,omitempty"` | ||
|
||
// The URL to get source code for building the model | ||
SourceURL string `json:"sourceURL,omitempty"` | ||
|
||
// The version of the packaged software | ||
Version string `json:"version,omitempty"` | ||
|
||
// The source control revision identifier for the packaged software | ||
Revision string `json:"revision,omitempty"` | ||
|
||
// The name of the distributing entity, organization or individual | ||
Vendor string `json:"vendor,omitempty"` | ||
|
||
// The license(s) under which contained software is distributed as an SPDX License Expression | ||
Licenses []string `json:"licenses,omitempty"` | ||
|
||
// The human-readable title of the model | ||
Title string `json:"title,omitempty"` | ||
|
||
// The human-readable description of the software packaged in the model | ||
Description string `json:"description,omitempty"` | ||
} | ||
|
||
// Model defines the basic information of a model. | ||
// It provides the `application/vnd.cnai.model.config.v1+json` mediatype when marshalled to JSON. | ||
type Model struct { | ||
// The model descriptor | ||
Descriptor ModelDescriptor `json:"descriptor"` | ||
|
||
// The model describes a layer content addresses | ||
ModelFS ModelFS `json:"modelfs"` | ||
|
||
// Config defines the execution parameters which should be used as a base when running a model using an inference engine. | ||
Config ModelConfig `json:"config, omitempty"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters