defaults.py 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. from core.model_runtime.entities.model_entities import DefaultParameterName
  2. PARAMETER_RULE_TEMPLATE: dict[DefaultParameterName, dict] = {
  3. DefaultParameterName.TEMPERATURE: {
  4. "label": {
  5. "en_US": "Temperature",
  6. "zh_Hans": "温度",
  7. },
  8. "type": "float",
  9. "help": {
  10. "en_US": "Controls randomness. Lower temperature results in less random completions."
  11. " As the temperature approaches zero, the model will become deterministic and repetitive."
  12. " Higher temperature results in more random completions.",
  13. "zh_Hans": "温度控制随机性。较低的温度会导致较少的随机完成。随着温度接近零,模型将变得确定性和重复性。"
  14. "较高的温度会导致更多的随机完成。",
  15. },
  16. "required": False,
  17. "default": 0.0,
  18. "min": 0.0,
  19. "max": 1.0,
  20. "precision": 2,
  21. },
  22. DefaultParameterName.TOP_P: {
  23. "label": {
  24. "en_US": "Top P",
  25. "zh_Hans": "Top P",
  26. },
  27. "type": "float",
  28. "help": {
  29. "en_US": "Controls diversity via nucleus sampling: 0.5 means half of all likelihood-weighted options"
  30. " are considered.",
  31. "zh_Hans": "通过核心采样控制多样性:0.5表示考虑了一半的所有可能性加权选项。",
  32. },
  33. "required": False,
  34. "default": 1.0,
  35. "min": 0.0,
  36. "max": 1.0,
  37. "precision": 2,
  38. },
  39. DefaultParameterName.TOP_K: {
  40. "label": {
  41. "en_US": "Top K",
  42. "zh_Hans": "Top K",
  43. },
  44. "type": "int",
  45. "help": {
  46. "en_US": "Limits the number of tokens to consider for each step by keeping only the k most likely tokens.",
  47. "zh_Hans": "通过只保留每一步中最可能的 k 个标记来限制要考虑的标记数量。",
  48. },
  49. "required": False,
  50. "default": 50,
  51. "min": 1,
  52. "max": 100,
  53. "precision": 0,
  54. },
  55. DefaultParameterName.PRESENCE_PENALTY: {
  56. "label": {
  57. "en_US": "Presence Penalty",
  58. "zh_Hans": "存在惩罚",
  59. },
  60. "type": "float",
  61. "help": {
  62. "en_US": "Applies a penalty to the log-probability of tokens already in the text.",
  63. "zh_Hans": "对文本中已有的标记的对数概率施加惩罚。",
  64. },
  65. "required": False,
  66. "default": 0.0,
  67. "min": 0.0,
  68. "max": 1.0,
  69. "precision": 2,
  70. },
  71. DefaultParameterName.FREQUENCY_PENALTY: {
  72. "label": {
  73. "en_US": "Frequency Penalty",
  74. "zh_Hans": "频率惩罚",
  75. },
  76. "type": "float",
  77. "help": {
  78. "en_US": "Applies a penalty to the log-probability of tokens that appear in the text.",
  79. "zh_Hans": "对文本中出现的标记的对数概率施加惩罚。",
  80. },
  81. "required": False,
  82. "default": 0.0,
  83. "min": 0.0,
  84. "max": 1.0,
  85. "precision": 2,
  86. },
  87. DefaultParameterName.MAX_TOKENS: {
  88. "label": {
  89. "en_US": "Max Tokens",
  90. "zh_Hans": "最大标记",
  91. },
  92. "type": "int",
  93. "help": {
  94. "en_US": "Specifies the upper limit on the length of generated results."
  95. " If the generated results are truncated, you can increase this parameter.",
  96. "zh_Hans": "指定生成结果长度的上限。如果生成结果截断,可以调大该参数。",
  97. },
  98. "required": False,
  99. "default": 64,
  100. "min": 1,
  101. "max": 2048,
  102. "precision": 0,
  103. },
  104. DefaultParameterName.RESPONSE_FORMAT: {
  105. "label": {
  106. "en_US": "Response Format",
  107. "zh_Hans": "回复格式",
  108. },
  109. "type": "string",
  110. "help": {
  111. "en_US": "Set a response format, ensure the output from llm is a valid code block as possible,"
  112. " such as JSON, XML, etc.",
  113. "zh_Hans": "设置一个返回格式,确保llm的输出尽可能是有效的代码块,如JSON、XML等",
  114. },
  115. "required": False,
  116. "options": ["JSON", "XML"],
  117. },
  118. DefaultParameterName.JSON_SCHEMA: {
  119. "label": {
  120. "en_US": "JSON Schema",
  121. },
  122. "type": "text",
  123. "help": {
  124. "en_US": "Set a response json schema will ensure LLM to adhere it.",
  125. "zh_Hans": "设置返回的json schema,llm将按照它返回",
  126. },
  127. "required": False,
  128. },
  129. }