Chinese chunk begins with a full-stop #5364

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

Originally created by @Sumkor on GitHub (Sep 3, 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.7.3

Cloud or Self Hosted

Self Hosted (Docker), Self Hosted (Source)

Steps to reproduce

Upload Chinese documents in knowledge base, when select automatic chunking, some chunk begins with a full-stop。

✔️ Expected Behavior

No response

Actual Behavior

图片

Originally created by @Sumkor on GitHub (Sep 3, 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.7.3 ### Cloud or Self Hosted Self Hosted (Docker), Self Hosted (Source) ### Steps to reproduce Upload Chinese documents in knowledge base, when select automatic chunking, some chunk begins with a full-stop。 ### ✔️ Expected Behavior _No response_ ### ❌ Actual Behavior ![图片](https://github.com/user-attachments/assets/448749f3-5635-48ac-bf59-1679b385fcb9)
yindo added the 🐞 bug label 2026-02-21 18:10:37 -05:00
yindo closed this issue 2026-02-21 18:10:37 -05:00
Author
Owner

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

I found a similar unsolved discussion that might be relevant to your issue: Help: CSV format document segmentation problem, which was last updated on 2024-08-08 [1].

The issue you're experiencing with some chunks beginning with a full-stop when uploading Chinese documents and selecting automatic chunking in Dify version 0.7.3 is likely due to the segmentation rules in automatic mode. These rules may not handle punctuation correctly, especially in languages like Chinese where sentence boundaries are not as clearly defined by spaces or punctuation as in English.

The automatic chunking algorithm for Chinese text in Dify is implemented using the EnhanceRecursiveCharacterTextSplitter class. This class uses specific parameters for chunk size, chunk overlap, and separators, which include Chinese punctuation like "。". Here is the relevant code snippet:

character_splitter = EnhanceRecursiveCharacterTextSplitter.from_encoder(
    chunk_size=DatasetProcessRule.AUTOMATIC_RULES['segmentation']['max_tokens'],
    chunk_overlap=DatasetProcessRule.AUTOMATIC_RULES['segmentation']['chunk_overlap'],
    separators=["\n\n", "。", ". ", " ", ""],
    embedding_model_instance=embedding_model_instance
)

This setup ensures that the text is split into chunks based on the specified separators, which include the Chinese period "。", making it suitable for processing Chinese text [2].

Additionally, the automatic mode is being phased out, and it is recommended to switch to custom mode for better control over segmentation and cleaning strategies. In custom mode, you can configure segmentation and cleaning strategies according to different document formats and scenario requirements, which may help avoid issues like chunks starting with punctuation marks [3][4][5][6].

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Sep 3, 2024): <!-- Answer --> I found a similar unsolved discussion that might be relevant to your issue: [Help: CSV format document segmentation problem](https://github.com/langgenius/dify/discussions/7085), which was last updated on 2024-08-08 <sup>[[1]](https://github.com/langgenius/dify/discussions/7085)</sup>. The issue you're experiencing with some chunks beginning with a full-stop when uploading Chinese documents and selecting automatic chunking in Dify version 0.7.3 is likely due to the segmentation rules in automatic mode. These rules may not handle punctuation correctly, especially in languages like Chinese where sentence boundaries are not as clearly defined by spaces or punctuation as in English. The automatic chunking algorithm for Chinese text in Dify is implemented using the `EnhanceRecursiveCharacterTextSplitter` class. This class uses specific parameters for chunk size, chunk overlap, and separators, which include Chinese punctuation like "。". Here is the relevant code snippet: ```python character_splitter = EnhanceRecursiveCharacterTextSplitter.from_encoder( chunk_size=DatasetProcessRule.AUTOMATIC_RULES['segmentation']['max_tokens'], chunk_overlap=DatasetProcessRule.AUTOMATIC_RULES['segmentation']['chunk_overlap'], separators=["\n\n", "。", ". ", " ", ""], embedding_model_instance=embedding_model_instance ) ``` This setup ensures that the text is split into chunks based on the specified separators, which include the Chinese period "。", making it suitable for processing Chinese text <sup>[[2]](https://github.com/langgenius/dify/blob/main/api/core/rag/index_processor/index_processor_base.py)</sup>. Additionally, the automatic mode is being phased out, and it is recommended to switch to custom mode for better control over segmentation and cleaning strategies. In custom mode, you can configure segmentation and cleaning strategies according to different document formats and scenario requirements, which may help avoid issues like chunks starting with punctuation marks <sup>[[3]](https://github.com/langgenius/dify-docs/blob/main/en/guides/knowledge-base/create-knowledge-and-upload-documents.md)</sup><sup>[[4]](https://github.com/langgenius/dify-docs/blob/main/zh_CN/guides/knowledge-base/create_knowledge_and_upload_documents.md)</sup><sup>[[5]](https://github.com/langgenius/dify-docs/blob/main/zh_CN/guides/knowledge-base/create-knowledge-and-upload-documents.md)</sup><sup>[[6]](https://github.com/langgenius/dify-docs/blob/main/zh_CN/guides/knowledge-base/create-knowledge-and-upload-documents-copy.md)</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#5364