{
    "x-license": {
        "id": "Apache-2.0",
        "notice": "Copyright 2025-2026 Dorsal Hub LTD",
        "url": "https://github.com/dorsalhub/open-validation-schemas/blob/main/LICENSE"
    },
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "$id": "https://dorsalhub.com/schemas/open/embedding",
    "title": "Embedding",
    "version": "0.6.0",
    "description": "Store a vector and (optionally) the algorithm or embedding model which generated it. Supports both array (dense) and object (sparse) representations.",
    "type": "object",
    "properties": {
        "model": {
            "type": "string",
            "description": "The model, tool or algorithm used to create this embedding.",
            "maxLength": 1024
        },
        "target": {
            "type": "string",
            "description": "The name of or a reference to the variable, feature, or file being embedded.",
            "maxLength": 256
        },
        "vector": {
            "description": "The embedding vector data.",
            "oneOf": [
                {
                    "title": "Array Representation",
                    "type": "array",
                    "description": "A flat list of numbers (typically used for dense vectors).",
                    "items": {
                        "type": "number"
                    },
                    "minItems": 1,
                    "maxItems": 16384
                },
                {
                    "title": "Object Representation",
                    "type": "object",
                    "description": "A coordinate list of indices and values (typically used for sparse vectors). 'indices' and 'values' must be the same length, and every index must be less than 'dimensions'.",
                    "properties": {
                        "dimensions": {
                            "type": "integer",
                            "description": "The total size of the vector space (e.g. the vocabulary size).",
                            "minimum": 1
                        },
                        "indices": {
                            "type": "array",
                            "description": "The positions of the non-zero elements.",
                            "items": {
                                "type": "integer",
                                "minimum": 0
                            },
                            "minItems": 1,
                            "maxItems": 100000,
                            "uniqueItems": true
                        },
                        "values": {
                            "type": "array",
                            "description": "The values corresponding to the indices.",
                            "items": {
                                "type": "number"
                            },
                            "minItems": 1,
                            "maxItems": 100000
                        }
                    },
                    "required": [
                        "dimensions",
                        "indices",
                        "values"
                    ],
                    "additionalProperties": false
                }
            ]
        },
        "attributes": {
            "type": "object",
            "description": "Arbitrary metadata relevant to this embedding.",
            "maxProperties": 16,
            "propertyNames": {
                "maxLength": 128
            },
            "additionalProperties": {
                "anyOf": [
                    {
                        "type": "string",
                        "maxLength": 1024
                    },
                    {
                        "type": "number"
                    },
                    {
                        "type": "boolean"
                    },
                    {
                        "type": "null"
                    }
                ]
            }
        }
    },
    "required": [
        "vector"
    ],
    "additionalProperties": false
}