ragflow icon indicating copy to clipboard operation
ragflow copied to clipboard

[Question]: When I use Chinese, The Categorize component didn't work very well

Open yangyonguo opened this issue 9 months ago • 4 comments

Describe your problem

I have configured Categorize component in Chinese on the front-end web page. After running it, often find that it cannot match the expected categorize branch. Is it because the Categorize component base is prompt framework written in English, splicing the Chinese content I input, assembly into the final Chinese and English mixing prompt will appear this problem

yangyonguo avatar Feb 18 '25 01:02 yangyonguo

What about adding a Generate component a head of it to translate user's input into English?

KevinHuSh avatar Feb 18 '25 03:02 KevinHuSh

What about adding a Generate component a head of it to translate user's input into English?

Image

self.prompt = """
        You're a text classifier. You need to categorize the user’s questions into {} categories, 
        namely: {}
        Here's description of each category:
        {}

        You could learn from the following examples:
        {}
        You could learn from the above examples.
        Just mention the category names, no need for any additional words.
        
        ---- Real Data ----
        {}
        """.format(
            len(self.category_description.keys()),
            "/".join(list(self.category_description.keys())),
            "\n".join(descriptions),
            "- ".join(cate_lines),
            chat_hist
        )

Firstly, thank you for reply.

In the above source code of agent\component\categorize.py, prompt builds in English with the information configured in the Categorize component, So the final mixed prompt contain both Chinese and English? I'm confused about this.

Secondly, Your reply means i must add translate before the Generate component, but now the problem is the Categorize component that named '服务分类' in the image above, I can't change what's encapsulated inside it.

yangyonguo avatar Feb 18 '25 08:02 yangyonguo

@KevinHuSh Welcome to correct

yangyonguo avatar Feb 18 '25 15:02 yangyonguo

Image

KevinHuSh avatar Feb 19 '25 06:02 KevinHuSh