| |
| |
| package compactonnx |
|
|
| import "huggingface.co/turenlabs/Vigil/source/pkg/compactmodel" |
|
|
| const ( |
| MetadataSchema = "vigil.compact-onnx-metadata.v1" |
| InputName = "features" |
| OutputName = "probability" |
| MaxModelBytes = 10 * 1024 * 1024 |
| ) |
|
|
| |
| |
| type Metadata struct { |
| SchemaVersion string `json:"schema_version"` |
| Model ModelBinding `json:"model"` |
| Preprocessing PreprocessingBinding `json:"preprocessing"` |
| Threshold float64 `json:"threshold"` |
| } |
|
|
| type ModelBinding struct { |
| Family string `json:"family"` |
| SHA256 string `json:"sha256"` |
| SizeBytes int64 `json:"size_bytes"` |
| InputName string `json:"input_name"` |
| InputFeatures int `json:"input_features"` |
| OutputName string `json:"output_name"` |
| OutputElements int `json:"output_elements"` |
| } |
|
|
| type PreprocessingBinding struct { |
| SchemaVersion string `json:"schema_version"` |
| ContractSHA256 string `json:"contract_sha256"` |
| WordFeatures int `json:"word_features"` |
| CharFeatures int `json:"char_features"` |
| StructuredFeatures int `json:"structured_features"` |
| TotalFeatures int `json:"total_features"` |
| } |
|
|
| |
| |
| |
| type Config struct { |
| ModelPath string |
| MetadataPath string |
| RuntimeLibrary string |
| } |
|
|
| |
| type Markers struct { |
| ModelLoaded bool `json:"model_loaded"` |
| ModelType string `json:"model_type"` |
| ModelSHA256 string `json:"model_sha256"` |
| ModelSizeBytes int64 `json:"model_size_bytes"` |
| MetadataSHA256 string `json:"metadata_sha256"` |
| PreprocessingContractSHA256 string `json:"preprocessing_contract_sha256"` |
| Runtime string `json:"runtime"` |
| RuntimeVersion string `json:"runtime_version"` |
| FallbackUsed bool `json:"fallback_used"` |
| } |
|
|
| func (metadata Metadata) preprocessingMetadata() compactmodel.Metadata { |
| return compactmodel.Metadata{ |
| SchemaVersion: metadata.Preprocessing.SchemaVersion, |
| ContractSHA256: metadata.Preprocessing.ContractSHA256, |
| WordFeatures: metadata.Preprocessing.WordFeatures, |
| CharFeatures: metadata.Preprocessing.CharFeatures, |
| StructuredFeatures: metadata.Preprocessing.StructuredFeatures, |
| TotalFeatures: metadata.Preprocessing.TotalFeatures, |
| } |
| } |
|
|