manifest.go 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. // Package manifest provides documentation for the Ollama manifest format.
  2. // This package contains no code.
  3. //
  4. // # Manifests
  5. //
  6. // A manifest is a JSON object that describes a model. The JSON object has a
  7. // single field "layers" which is a list of layers that make up the model. Each
  8. // layer has the following fields:
  9. //
  10. // A layer is a single, logical unit of a model. Layers are stored in the cache
  11. // as files with the name of the digest of the layer. Layers are pushed and
  12. // pulled from the registry as blobs.
  13. //
  14. // A layer is represented as a JSON object with the following fields:
  15. //
  16. // - "digest": The digest of the layer.
  17. // - "mediaType": The media type of the layer.
  18. // - "size": The size of the layer in bytes.
  19. //
  20. // Layers are typically stored in a blob store, such as a registry, and are
  21. // referenced by their digest. This package does not define how layers are
  22. // stored or retrieved.
  23. //
  24. // # Configuration Layer
  25. //
  26. // The configuration of a model is represented as a layer with the media type:
  27. //
  28. // application/vnd.ollama.image.config; type=<type>
  29. //
  30. // The "type" parameter in the media type specifies the format of the
  31. // configuration (e.g., "safetensor" or "gguf").
  32. //
  33. // There may be only one configuration layer in a model.
  34. //
  35. // # Template Layer
  36. //
  37. // The model template is a layer with the media type:
  38. //
  39. // application/vnd.ollama.image.template; [name=<name>]
  40. //
  41. // The "name" parameter in the media type specifies the name of the template as
  42. // for lookup at runtime. The name is optional and may be omitted. If omitted,
  43. // the template is the default template for the model.
  44. //
  45. // # Tensor Layers
  46. //
  47. // The tensors of a model are represented as layers with the media type:
  48. //
  49. // application/vnd.ollama.image.tensor; name=<name>; dtype=<dtype>; shape=<shape>
  50. //
  51. // The "name" parameter in the media type specifies the name of the tensor as
  52. // defined in the model's configuration and are bound only by the rules for
  53. // names as defined in the configuration format, as represented by the
  54. // configuration's "type".
  55. //
  56. // The "dtype" parameter in the media type specifies the data type of the tensor
  57. // as a string.
  58. //
  59. // TODO: Define more specifically how to represent data types as strings.
  60. //
  61. // The "shape" parameter in the media type specifies the shape of the tensor as
  62. // a comma-separated list of integers; one per dimension.
  63. //
  64. // # Tokenization Layers
  65. //
  66. // The tokenization of a model is represented as a layer with the media type:
  67. //
  68. // application/vnd.ollama.image.tokenizer
  69. //
  70. // The configuration of the tokenizer is represented as a layer with the media type:
  71. //
  72. // application/vnd.ollama.image.tokenizer.config
  73. //
  74. // # Miscellaneous Layers
  75. //
  76. // These extra layer mime types are reserved:
  77. //
  78. // application/vnd.ollama.image.license
  79. //
  80. // This layer contains one of the many licenses for the model in plain text.
  81. //
  82. // # Example Manifest
  83. //
  84. // The following is an example manifest containing a configuration, a model
  85. // template, and two tensors (digests shortened for brevity):
  86. //
  87. // {
  88. // "layers": [{
  89. // "digest": "sha256:a...",
  90. // "mediaType": "application/vnd.ollama.image.config; type=safetensors",
  91. // "size": 1234
  92. // },{
  93. // "digest": "sha256:b...",
  94. // "mediaType": "application/vnd.ollama.image.template",
  95. // "size": 5678
  96. // },{
  97. // "digest": "sha256:c...",
  98. // "mediaType": "application/vnd.ollama.image.tensor; name=input; dtype=F32; shape=1,2,3",
  99. // "size": 9012
  100. // },{
  101. // "digest": "sha256:d...",
  102. // "mediaType": "application/vnd.ollama.image.tensor; name=output; dtype=I32; shape=4,5,6",
  103. // "size": 3456
  104. // }]
  105. // }
  106. //
  107. // # Legacy Media Types
  108. //
  109. // The appliaction/vnd.ollama.image.model media type is deprecated, but will
  110. // remain supported for backwards compatibility, for some undefined amount of
  111. // time. New models should use the media types defined above.
  112. //
  113. // # Reserved media types
  114. //
  115. // The media type prefix "application/vnd.ollama.image." is reserved for
  116. // defining new media types for layers known to Ollama. Currently, all other
  117. // prefixes are ignored by official Ollama registry clients.
  118. package manifest