Prompt Hub - 使用大型語言模型進行數學理解(Mathematical Understanding with LLMs)

使用大型語言模型進行數學理解(Mathematical Understanding with LLMs)

本段包含一組用於測試大型語言模型數學能力的提示集合。


目錄


複合函數的求值

背景

此提示透過要求大型語言模型對給定的複合函數進行求值,以測試其數學能力。

提示詞

g(x) = f^{-1}(x), \, g(0) = 5, \, g(4) = 7, \, g(3) = 2, \, g(7) = 9, \, g(9) = 6, What\, is \, f(f(f(6)))?

程式

from openai import OpenAI
client = OpenAI()
 
response = client.chat.completions.create(
model="gpt-4",
messages=[
    {
    "role": "user",
    "content": "Suppose  g(x) = f^{-1}(x), g(0) = 5, g(4) = 7, g(3) = 2, g(7) = 9, g(9) = 6 what is f(f(f(6)))?\n"
    }
],
temperature=1,
max_tokens=256,
top_p=1,
frequency_penalty=0,
presence_penalty=0
)
import fireworks.client
fireworks.client.api_key = "<FIREWORKS_API_KEY>"
completion = fireworks.client.ChatCompletion.create(
    model="accounts/fireworks/models/mixtral-8x7b-instruct",
    messages=[
        {
        "role": "user",
        "content": "Suppose  g(x) = f^{-1}(x), g(0) = 5, g(4) = 7, g(3) = 2, g(7) = 9, g(9) = 6 what is f(f(f(6)))?",
        }
    ],
    stop=["<|im_start|>","<|im_end|>","<|endoftext|>"],
    stream=True,
    n=1,
    top_p=1,
    top_k=40,
    presence_penalty=0,
    frequency_penalty=0,
    prompt_truncate_len=1024,
    context_length_exceeded_behavior="truncate",
    temperature=0.9,
    max_tokens=4000
)

使用大型語言模型加總奇數

背景

此提示透過要求大型語言模型判斷多個奇數相加是否為偶數,以測試其數學能力。此範例中也會運用「思路鏈(Chain-of-Thought)」提示技巧來引導模型進行推理。

提示詞

這些數字中的奇數相加會得到一個偶數:15、32、5、13、82、7、1。
請將問題拆解為多個步驟來解答。首先,找出奇數,將它們相加,並指出結果是奇數還是偶數。

程式

from openai import OpenAI
client = OpenAI()
 
response = client.chat.completions.create(
model="gpt-4",
messages=[
    {
    "role": "user",
    "content": "The odd numbers in this group add up to an even number: 15, 32, 5, 13, 82, 7, 1. \nSolve by breaking the problem into steps. First, identify the odd numbers, add them, and indicate whether the result is odd or even."
    }
],
temperature=1,
max_tokens=256,
top_p=1,
frequency_penalty=0,
presence_penalty=0
)
import fireworks.client
fireworks.client.api_key = "<FIREWORKS_API_KEY>"
completion = fireworks.client.ChatCompletion.create(
    model="accounts/fireworks/models/mixtral-8x7b-instruct",
    messages=[
        {
        "role": "user",
        "content": "The odd numbers in this group add up to an even number: 15, 32, 5, 13, 82, 7, 1. \nSolve by breaking the problem into steps. First, identify the odd numbers, add them, and indicate whether the result is odd or even.",
        }
    ],
    stop=["<|im_start|>","<|im_end|>","<|endoftext|>"],
    stream=True,
    n=1,
    top_p=1,
    top_k=40,
    presence_penalty=0,
    frequency_penalty=0,
    prompt_truncate_len=1024,
    context_length_exceeded_behavior="truncate",
    temperature=0.9,
    max_tokens=4000
)

References

Mathematical Understanding with LLMs


目錄:Prompt Hub - 提示詞匯集

上一篇:Prompt Hub - 圖像生成 (Image Generation)
下一篇:Prompt Hub - 使用大型語言模型進行問答 (Question Answering with LLMs)