AI并非萬(wàn)能,有效溝通是關(guān)鍵

近,我與一個(gè)產(chǎn)品團(tuán)隊(duì)合作,參與了一些與大模型相關(guān)的開(kāi)發(fā)工作。今天分享一些與AI(這里指大語(yǔ)言模型ChatGPT)合作實(shí)現(xiàn)軟件功能的一些感受和經(jīng)驗(yàn)。

一句話需求一樣不好用

許多人可能認(rèn)為,AI的強(qiáng)大能力能解決軟件工程中的所有問(wèn)題,例如“一句話需求”。一些演示中,簡(jiǎn)單的描述似乎就能生成豐富的功能代碼。然而,真實(shí)情況并非如此。以下是一個(gè)例子,展示了兩個(gè)版本的提示詞在同樣模型和參數(shù)條件下生成的質(zhì)量差距。

需求背景:該功能是根據(jù)用戶的一段文字生成一定數(shù)量的單選題,同時(shí)附帶正確選項(xiàng)。

修改前:

You will be provided with a document, and answer using @Language@ language, use the following content to write {{@QuestionNumber@}} easy multiple choice questions with 1 correct answer and the others are wrong answers, please note that the answer should be provided in JSON format:
[{
    "Question":"What is the capital of France?",
    "Options": [
        {"option": "Berlin", "isCorrect": false},
        {"option": "Lyon", "isCorrect": false},
        {"option": "Paris", "isCorrect": true},
        {"option": "Amsterdam", "isCorrect": false}
    ]
}
{...if more quiz,please list here as JSON format...}
]

following question:
@Content@

修改后:

system:
You are an AI assistant tasked with generating multiple-choice questions based on document content. Your goal is to create questions that are relevant and challenging, using the details provided in the document.
###Input Document Content:
@content@
###Task:
1. Generate exactly @questionnumber@ multiple-choice questions based on the content provided.
2. Each question must have one correct answer and three distractors (incorrect options).
3. Maintain the language consistency throughout the questions to match the original document content.

###Language Handling:
Ensure all parts of the question, including options, are in the same language as the input content to maintain relevance and context integrity.
###Response Format:
Respond in JSON format, structuring each question as an object within an array. Each object should contain the question text and a list of options, each marked for correctness.
###Example Response:
[{
    "Question":"What is the capital of France?",
    "Options": [
        {"option": "Berlin", "isCorrect": false},
        {"option": "Lyon", "isCorrect": false},
        {"option": "Paris", "isCorrect": true},
        {"option": "Amsterdam", "isCorrect": false}
    ]
},
{
    "Question": "What is the famouse place in Paris?",
    "Options": [
        {"option": "Historic Capitals", "isCorrect": false},
        {"option": "Modern Metropolises:", "isCorrect": false},
        {"option": "Island Paradises", "isCorrect": false},
        {"option": "Eiffel Tower", "isCorrect": true}
    ]
}
]
###Important:
1. Make sure to generate exactly @questionnumber@ questions.
2. The language using for the questions must same as the original document content.

修改前的提示詞生成效果有如下問(wèn)題經(jīng)常發(fā)生:

  1. 使用非英語(yǔ)文本生成題目,經(jīng)常會(huì)變成英文題目。
  2. 生成題目的個(gè)數(shù)少于要求。
  3. 超過(guò)5道題之后,題目?jī)?nèi)容開(kāi)始與指定的文章無(wú)關(guān)。
  4. 返回的json格式不正確。

修改后的提示詞,上面的問(wèn)題都解決了。主要區(qū)別是提示詞描述更清楚,文檔有格式,無(wú)論是人還是AI都能分清主次,生成的功能更符合需求。

注意改之前也有例子,為什么輸出格式仍然有錯(cuò)誤,一個(gè)小細(xì)節(jié)是例子里面的json格式錯(cuò)了。見(jiàn)下圖:


IMG_jsonerror.jpeg

需求不清一樣無(wú)法完成

模糊的需求描述不僅對(duì)人類(lèi)工程師不友好,對(duì)AI也是如此。例如,下面的例子是兩個(gè)評(píng)分標(biāo)準(zhǔn),用戶可以自定義評(píng)分標(biāo)準(zhǔn)。每一行是一個(gè)評(píng)分標(biāo)準(zhǔn)名字,每一列是不同分?jǐn)?shù)段的打分規(guī)則。如果這些名字和描述本身就是是沒(méi)有意義的字母組合,那么AI同樣無(wú)法理解和處理。


IMG_rubirc.png

你的期待是讓AI能夠根據(jù)打分規(guī)則進(jìn)行打分。不過(guò)因?yàn)槊侄紱](méi)有意義的隨意字母組合。那么結(jié)果會(huì)怎樣呢?看下圖的效果:


IMG_rubrics2.png

結(jié)果自然不理想。AI會(huì)盡可能提供其認(rèn)為你需要的內(nèi)容,但效果可能并不準(zhǔn)確。如果是人類(lèi)工程師,可能會(huì)直接告知無(wú)法完成任務(wù)。因此,提供清晰、具體的需求描述至關(guān)重要。

Few Shots和思維鏈(CoT)組合的威力

如果你的應(yīng)用以提示詞為主,提示詞的質(zhì)量至關(guān)重要。Few shots和思維鏈(Chain of Thought, CoT)是兩個(gè)有效的提示詞技巧。參看最上面的提示詞內(nèi)容:

  1. 任務(wù)描述:在Task節(jié)中描述任務(wù)的工作步驟,告訴模型如何推理完成任務(wù)。
  2. 輸出格式的例子:使用few shots的方式,讓模型知道你期望的輸出格式。

總結(jié)

很多現(xiàn)實(shí)工作中和人類(lèi)工程師的溝通技巧,對(duì)AI同樣有效。例如:

  1. 就算是AI,也需要清晰的需求描述。和人類(lèi)對(duì)需求文檔的要求一樣,越清晰越明確越好。而且AI更需要清晰的任務(wù)分解,否則固執(zhí)的執(zhí)行會(huì)導(dǎo)致錯(cuò)誤的結(jié)果。
  2. 現(xiàn)有的需求澄清和需求分解技巧,對(duì)AI一樣有效。Few Shots本身就是實(shí)例化需求的一個(gè)例子。
  3. CoT是通過(guò)分解任務(wù)步驟,讓AI理解推理過(guò)程,并能夠舉一反三。
  4. 同人類(lèi)工程師協(xié)作中可能會(huì)有的問(wèn)題,同AI的協(xié)作同樣會(huì)遇到。有些會(huì)更加嚴(yán)重。

用技術(shù)改變生活。歡迎留言,交流落地經(jīng)驗(yàn)。

參考

【歡迎關(guān)注我的個(gè)人博客】

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容