hfutils.utils.number

number_to_tag

hfutils.utils.number.number_to_tag(v)[source]

Categorize a number into a predefined range and return the corresponding tag for HuggingFace repository metadata.

Parameters:

v (int or float) – The number to categorize.

Returns:

A string tag representing the range in which the number falls.

Return type:

str

Raises:
  • ValueError – If no matching tag is found for the given number.

  • TypeError – If the input value is not numeric type.

Examples:

>>> number_to_tag(500)
'n<1K'
>>> number_to_tag(5000)
'1K<n<10K'
>>> number_to_tag(1000000000000)
'n>1T'