bug: Spark series models Parameter top_k should be int. #5431

Closed
opened 2026-02-21 18:10:56 -05:00 by yindo · 1 comment
Owner

Originally created by @AAEE86 on GitHub (Sep 6, 2024).

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

0.8.0-beta1

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

The web front end is not set with int type.
Quicker_20240906_172949

✔️ Expected Behavior

No response

Actual Behavior

No response

Originally created by @AAEE86 on GitHub (Sep 6, 2024). ### Self Checks - [X] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [X] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [X] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [X] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [X] Please do not modify this template :) and fill in all the required fields. ### Dify version 0.8.0-beta1 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce The web front end is not set with int type. ![Quicker_20240906_172949](https://github.com/user-attachments/assets/d51fbb5d-8a92-468f-a19a-6a95b32d5b9b) ### ✔️ Expected Behavior _No response_ ### ❌ Actual Behavior _No response_
yindo added the 🐞 bug label 2026-02-21 18:10:56 -05:00
yindo closed this issue 2026-02-21 18:10:56 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Sep 6, 2024):

The top_k parameter in the Spark series models is indeed set as an integer in the configuration file. Here is the relevant section from the provided document:

  - name: top_k
    type: int
    min: 0
    max: 99
    label:
      zh_Hans: 取样数量
      en_US: Top k
    help:
      zh_Hans: 生成时,采样候选集的大小。例如,取值为50时,仅将单次生成中得分最高的50个token组成随机采样的候选集。取值越大,生成的随机性越高;取值越小,生成的确定性越高。
      en_US: The size of the sample candidate set when generated. For example, when the value is 50, only the 50 highest-scoring tokens in a single generation form a randomly sampled candidate set. The larger the value, the higher the randomness generated; the smaller the value, the higher the certainty generated.

The top_k parameter is defined with type: int, which means it is set as an integer [1].

If the web front end is not reflecting this, it might be an issue with how the front-end form is generated or validated. The front-end form for configuring the Spark series models is generated using a YAML schema that defines various fields. For the top_k parameter, the validation is applied dynamically based on the model type. If the model is of type 'A', the top_k parameter is included in the schema with the following validation rules:

  • type: Integer
  • min: 1
  • default: 50

Here is the relevant code snippet for the top_k parameter validation:

if model == 'A':
    rules.append(
        ParameterRule(
            name='top_k', type=ParameterType.INT,
            use_template='top_k',
            min=1,
            default=50,
            label=I18nObject(
                zh_Hans='Top K', en_US='Top K'
            )
        )
    )
)

Additionally, the YAML configuration for the top_k parameter includes a help description and optional requirement status:

- name: top_k
  label:  
    zh_Hans: 取样数量
    en_US: Top k
  type: int  
  help:  
    zh_Hans: 仅从每个后续标记的前 K 个选项中采样。
    en_US: Only sample from the top K options for each subsequent token.
  required: false  
  min: 0
  max: 99

The top_k parameter is dynamically included in the model's parameter schema based on the specific model type, ensuring that only models supporting this parameter will have it in their configuration [2][3][4][5].

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Sep 6, 2024): <!-- Answer --> The `top_k` parameter in the Spark series models is indeed set as an integer in the configuration file. Here is the relevant section from the provided document: ```yaml - name: top_k type: int min: 0 max: 99 label: zh_Hans: 取样数量 en_US: Top k help: zh_Hans: 生成时,采样候选集的大小。例如,取值为50时,仅将单次生成中得分最高的50个token组成随机采样的候选集。取值越大,生成的随机性越高;取值越小,生成的确定性越高。 en_US: The size of the sample candidate set when generated. For example, when the value is 50, only the 50 highest-scoring tokens in a single generation form a randomly sampled candidate set. The larger the value, the higher the randomness generated; the smaller the value, the higher the certainty generated. ``` The `top_k` parameter is defined with `type: int`, which means it is set as an integer <sup>[[1]](https://github.com/langgenius/dify/blob/main/api/core/model_runtime/model_providers/perfxcloud/llm/Qwen2-72B-Instruct-GPTQ-Int4.yaml)</sup>. If the web front end is not reflecting this, it might be an issue with how the front-end form is generated or validated. The front-end form for configuring the Spark series models is generated using a YAML schema that defines various fields. For the `top_k` parameter, the validation is applied dynamically based on the model type. If the model is of type 'A', the `top_k` parameter is included in the schema with the following validation rules: - `type`: Integer - `min`: 1 - `default`: 50 Here is the relevant code snippet for the `top_k` parameter validation: ```python if model == 'A': rules.append( ParameterRule( name='top_k', type=ParameterType.INT, use_template='top_k', min=1, default=50, label=I18nObject( zh_Hans='Top K', en_US='Top K' ) ) ) ) ``` Additionally, the YAML configuration for the `top_k` parameter includes a help description and optional requirement status: ```yaml - name: top_k label: zh_Hans: 取样数量 en_US: Top k type: int help: zh_Hans: 仅从每个后续标记的前 K 个选项中采样。 en_US: Only sample from the top K options for each subsequent token. required: false min: 0 max: 99 ``` The `top_k` parameter is dynamically included in the model's parameter schema based on the specific model type, ensuring that only models supporting this parameter will have it in their configuration <sup>[[2]](https://github.com/langgenius/dify-docs/blob/main/zh_CN/guides/model-configuration/customizable-model.md)</sup><sup>[[3]](https://github.com/langgenius/dify-docs/blob/main/en/guides/model-configuration/predefined-model.md)</sup><sup>[[4]](https://github.com/langgenius/dify-docs/blob/main/jp/guides/model-configuration/customizable-model.md)</sup><sup>[[5]](https://github.com/langgenius/dify/blob/main/api/core/model_runtime/model_providers/perfxcloud/llm/Meta-Llama-3-8B-Instruct.yaml)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#5431