glam/schemas/20251121/linkml/modules/classes/Token.yaml

117 lines
4.7 KiB
YAML

id: https://nde.nl/ontology/hc/class/Token
name: token_class
title: Token Class
version: 1.1.0
prefixes:
linkml: https://w3id.org/linkml/
hc: https://nde.nl/ontology/hc/
schema: http://schema.org/
dcterms: http://purl.org/dc/terms/
prov: http://www.w3.org/ns/prov#
crm: http://www.cidoc-crm.org/cidoc-crm/
skos: http://www.w3.org/2004/02/skos/core#
rdfs: http://www.w3.org/2000/01/rdf-schema#
org: http://www.w3.org/ns/org#
xsd: http://www.w3.org/2001/XMLSchema#
imports:
- linkml:types
- ../slots/has_or_had_identifier
- ../slots/has_or_had_label
- ../slots/has_or_had_description
- ../slots/has_or_had_type
- ../slots/has_or_had_quantity
- ./TokenType
- ./Quantity
default_prefix: hc
classes:
Token:
class_uri: schema:QuantitativeValue
description: "Token count representation for LLM API usage tracking.\n\n**Key Fields**:\n\n| Field | Description | Example |\n|-------|-------------|---------|\n| has_or_had_type | Type of token | CachedTokenType |\n| has_or_had_quantity | Count value | 50 (cached tokens) |\n\n**Schema.org Alignment**:\n\nMaps to `schema:QuantitativeValue` for numeric values with context.\n\n**Use Cases**:\n\n1. **Cached tokens**: Prompt tokens served from cache (reduced cost)\n2. **Reasoning tokens**: Chain-of-thought tokens (GLM 4.7, o1)\n3. **Input/Output tokens**: Standard prompt/completion counts\n\n**Migration History**:\n\n- v1.0.0: Simple class with token_type attribute\n- v1.1.0: Updated to use has_or_had_type \u2192 TokenType per Rule 53/56\n\n**Example (Cached Tokens)**:\n\n```yaml\nToken:\n has_or_had_type:\n has_or_had_identifier: hc:TokenType/CACHED\n has_or_had_label: Cached Token\n has_or_had_quantity:\n quantity_value: 50\n has_or_had_description: Tokens from provider cache\n\
```\n"
exact_mappings:
- schema:QuantitativeValue
slots:
- has_or_had_identifier
- has_or_had_label
- has_or_had_description
- has_or_had_type
- has_or_had_quantity
slot_usage:
has_or_had_identifier:
range: uriorcurie
required: false
examples:
- value: https://nde.nl/ontology/hc/token/llm-response-001-cached
description: Token count instance identifier
has_or_had_type:
range: TokenType
required: false
inlined: true
description: 'The type of token (INPUT, OUTPUT, CACHED, REASONING, TOTAL).
References TokenType taxonomy.
'
examples:
- value:
has_or_had_identifier: hc:TokenType/CACHED
has_or_had_label: Cached Token
description: Cached token type
- value:
has_or_had_identifier: hc:TokenType/REASONING
has_or_had_label: Reasoning Token
description: Reasoning/thinking token type
has_or_had_quantity:
range: Quantity
required: false
inlined: true
description: 'The numeric token count with optional metadata.
For simple use cases, prefer quantity_value directly.
'
examples:
- value:
quantity_value: 50
has_or_had_description: Tokens served from cache
description: Cached token count
has_or_had_label:
range: string
required: false
examples:
- value: Cached tokens for context window
has_or_had_description:
range: string
required: false
examples:
- value: 50 prompt tokens served from provider KV cache
comments:
- Token models LLM token counts with type and quantity
- "Updated per Rule 53/56 to use has_or_had_type \u2192 TokenType"
- Replaces simple token_type string attribute
see_also:
- https://platform.openai.com/docs/api-reference/chat/object#usage
- https://docs.z.ai/guides/capabilities/thinking-mode
examples:
- value:
has_or_had_identifier: https://nde.nl/ontology/hc/token/example-cached-001
has_or_had_type:
has_or_had_identifier: hc:TokenType/CACHED
has_or_had_label: Cached Token
has_or_had_quantity:
quantity_value: 50
has_or_had_description: Prompt tokens from cache
has_or_had_description: 50 cached tokens reducing API cost
description: Cached token count with full metadata
- value:
has_or_had_type:
has_or_had_identifier: hc:TokenType/REASONING
has_or_had_label: Reasoning Token
has_or_had_quantity:
quantity_value: 1250
description: Reasoning tokens from GLM 4.7 thinking mode
annotations:
specificity_score: 0.1
specificity_rationale: Generic utility class/slot created during migration
custodian_types: "['*']"
custodian_types_rationale: Universal utility concept