Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: bug for glm prompt format #638

Merged
merged 2 commits into from
Sep 15, 2024
Merged

Conversation

zhangch-ss
Copy link
Contributor

fixed a bug in the GLM prompt formatting. #637

The previous formatted prompt:
[gMASK]<sop><|user|>\nI'm playing a dice game and want to calculate my chances. I roll the die 20 times, and I'm trying to figure out the probability of landing on a 6 exactly five times, considering each roll has a one in six chance of being a 6. Could you help me with that?<|assistant|>
the function calling result:
image

The fixed formatted prompt:
Single role: user

[gMASK]<sop><|system|>
你是一个名为 ChatGLM 的人工智能助手。你是基于智谱AI训练的语言模型 GLM-4 模型开发的,你的任务是针对用户的问题和要求提供适当的答复和支持

# 可用工具

## calculate_ROI

{
    "name": "calculate_ROI",
    "description": "Calculate the Return on Investment (ROI) for a given investment amount and net profit. Note that the provided function is in Python 3 syntax.",
    "parameters": {
        "type": "object",
        "properties": {
            "investment_amount": {
                "type": "number",
                "description": "The initial amount of money invested. This is a float type value.",
                "format": "float"
            },
            "net_profit": {
                "type": "number",
                "description": "The profit made from the investment. This is a float type value.",
                "format": "float"
            },
            "duration_years": {
                "type": "integer",
                "description": "The duration of the investment in years.",
                "default": 1
            }
        },
        "required": [
            "investment_amount",
            "net_profit"
        ]
    }
}
在调用上述函数时,请使用 Json 格式表示调用的参数。<|user|>
Calculate the profit margin of a company with revenue of $200,000 and expenses of $150,000.<|assistant|>

Multiple roles, system and user

[gMASK]<sop><|system|>
你是一个名为 ChatGLM 的人工智能助手。你是基于智谱AI训练的语言模型 GLM-4 模型开发的,你的任务是针对用户的问题和要求提供适当的答复和支持

# 可用工具

## find_flights

{
    "name": "find_flights",
    "description": "Searches for available flights between an origin and a destination on a specified date for a given number of passengers. Note that the provided function is in Python 3 syntax.",
    "parameters": {
        "type": "object",
        "required": [
            "origin",
            "destination",
            "date",
            "passengers"
        ],
        "properties": {
            "origin": {
                "type": "string",
                "description": "The three-letter IATA code of the origin airport, such as 'SFO' for San Francisco International Airport."
            },
            "destination": {
                "type": "string",
                "description": "The three-letter IATA code of the destination airport, similar to the origin format."
            },
            "date": {
                "type": "string",
                "description": "The departure date of the flight in the format YYYY-MM-DD, such as '2023-04-15'."
            },
            "passengers": {
                "type": "integer",
                "description": "The total number of passengers traveling."
            }
        }
    }
}
在调用上述函数时,请使用 Json 格式表示调用的参数。

## book_flight

{
    "name": "book_flight",
    "description": "Registers a specified flight for the given list of passengers on a particular date. Note that the provided function is in Python 3 syntax.",
    "parameters": {
        "type": "object",
        "required": [
            "flight",
            "passengers",
            "date"
        ],
        "properties": {
            "flight": {
                "type": "string",
                "description": "The unique identifier of the flight to be booked."
            },
            "passengers": {
                "type": "array",
                "items": {
                    "type": "string"
                },
                "description": "A list of names of the passengers traveling."
            },
            "date": {
                "type": "string",
                "description": "The departure date of the flight in the format YYYY-MM-DD."
            }
        }
    }
}
在调用上述函数时,请使用 Json 格式表示调用的参数。<|system|>
You are very powerful travel agent, you are able to search for flights and book them for your customers.<|user|>
I need to travel from Berlin to New York on 2021-10-10 with 2 passengers. Can you help me find available flights and also assist with booking once we choose the right one?<|assistant|>

the function calling result:
image

Copy link
Collaborator

@HuanzhiMao HuanzhiMao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @zhangch-ss!
LGTM. Will update the leaderboard soon to reflect this.

@HuanzhiMao HuanzhiMao linked an issue Sep 14, 2024 that may be closed by this pull request
@ShishirPatil ShishirPatil merged commit 46c3e85 into ShishirPatil:main Sep 15, 2024
ShishirPatil pushed a commit that referenced this pull request Sep 15, 2024
…627, #635, and #638. (#639)

This PR updates the leaderboard to reflect the change in score due to
the following PR merge:

1. #608
2. #600
3. #616 
4. #623
5. #626
6. #627
7. #635 
8. #638

---------

Co-authored-by: Charlie Cheng-Jie Ji <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BFCL] The handling of prompt formatting in GLM is incorrect.
3 participants