如何提示gpt,这样它就不会在时间窗口上出错

问题描述 投票:0回答:1

我正在尝试从遗产描述中提取财产状况。特别是,任何在 2020 年或以上进行翻修的房产都应标记为“JUST_RENOVATED”,而如果翻修发生在 2020 年之前,则应简单地标记为“GOOD”。

这是一个例子:

给出以下描述:

Entièrement rénovée en 2017, cette jolie maison 2 chambres vous séduira par ses pièces épurées et lumineuses. PEB exceptionnel (PEB A) grâce à la qualité d'isolation utilisée. Faible consommation de gaz pour le chauffage central. Châssis triple vitrage. Cuisine ouverte entièrement équipée. Installation électrique aux normes RGIE. Compteur bi-horaire. Pour plus de renseignements et pour participer aux prochaines visites, merci de contacter l'agence immobilière ASTON & PARTNERS au 081/30.44.44.

房产状况应为“良好”。

但是,GPT 似乎很难理解时间窗口。它通常会标记为“JUST_RENOVATED”,证明它处于翻新时间窗口内(尽管 2017 年在 2020 年之前)。

这是我使用的提示,我该如何改进它?

Extract the property condition based on descriptions.

Follow this order of decision :
1. Tag any property that has been renovated recently (i.e. 2020 and above) by "JUST_RENOVATED". If renovation have been made before 2020, tag by "GOOD".
2. Tag any property that has been recently build or is a project by "AS_NEW".
3. Tag any property with need of restorations by "TO_RENOVATE".
4. Tag any property in good condition (i.e. good energetic performance) by "GOOD".
5. If none of the above tag suit the description, tag by "NOT_FOUND".

Answer only with the tag.

最终,Python 代码(如果有帮助的话):

def debug_prompt(description):
    intro_message = f""" 
        Extract the property condition based on descriptions.

        Follow this order of decision :
        1. Tag any property that has been renovated recently (i.e. 2020 and above) by "JUST_RENOVATED". If renovation have been made before 2020, tag by "GOOD".
        2. Tag any property that has been recently build or is a project by "AS_NEW".
        3. Tag any property with need of restorations by "TO_RENOVATE".
        4. Tag any property in good condition (i.e. good energetic performance) by "GOOD".
        5. If none of the above tag suit the description, tag by "NOT_FOUND".

        Answer only with the tag.
    """

    system_message = [{"role": "system", "content": intro_message}]


    debug_prompt = [{
        "role": "user", 
        "content": f"""
            Extract the estate condition from the following description: '''{description}'''.
        """
    }]
    
    messages = system_message + debug_prompt

    response = client.chat.completions.create(
        model="gpt-3.5-turbo",
        messages=messages,
        temperature=0,
    )
    
    for response in response.choices:
        print(response.message.content.strip())
python openai-api large-language-model
1个回答
0
投票

我已经使用了您的系统并通过 API 提示消息,gpt-3.5-turbo 响应:好,这是期望的结果 - 所以我不太确定为什么您没有得到相同的结果。我从 gpt-4-turbo 得到了同样的结果,这通常比 3.5-turbo 给出更好的结果,所以我建议你尝试一下。

此外,对系统消息的关注程度有时也值得怀疑,我建议您也尝试将信息从系统消息转移到主提示中。我发现这给出了良好的结果,并且就您的数据而言,gpt-3.5-turbo 和 gpt-4-turbo 再次返回了所需的良好结果。

作为检查,我还在上次测试中将数据中的翻新日期更改为 2022 年,并且两个 LLM 都正确返回:JUST_RENOVATED。

请注意(与您的代码一样)所有测试都是在零温度下进行的,以确保可重复性。

© www.soinside.com 2019 - 2024. All rights reserved.