Bỏ qua tới nội dung
Bài 9/12 · Prompt engineering từ cơ bản đến trung cấp (DAIR.AI)

Generated knowledge prompting

Cho model tự sinh "kiến thức" liên quan trước, rồi đưa kiến thức đó vào prompt để cải thiện dự đoán ở các tác vụ suy luận thường thức.

Trung cấp@shine19046 phút đọc

Bài này giới thiệu generated knowledge prompting (prompt với kiến thức tự sinh): dùng chính model để sinh kiến thức liên quan trước khi đưa ra dự đoán.

Minh hoạ generated knowledge prompting

Nguồn ảnh: Liu et al. 2022

Ý tưởng

LLM tiếp tục được cải thiện, và một kỹ thuật phổ biến là đưa thêm kiến thức hoặc thông tin vào để giúp model dự đoán chính xác hơn.

Theo ý tưởng tương tự, liệu có thể dùng chính model để sinh kiến thức trước khi dự đoán không? Đó là điều bài báo của Liu et al. 2022 thử nghiệm: sinh kiến thức để dùng làm một phần của prompt. Cụ thể, cách này hữu ích đến đâu với các tác vụ như suy luận thường thức?

Ví dụ

Thử một prompt đơn giản:

Prompt:

code
Part of golf is trying to get a higher point total than others. Yes or No?

Đầu ra:

code
Yes.

Loại lỗi này cho thấy giới hạn của LLM khi làm các tác vụ cần thêm kiến thức về thế giới. Làm sao cải thiện bằng cách sinh kiến thức?

Bước 1: sinh kiến thức

Trước hết, chúng ta sinh vài "kiến thức":

Prompt:

code
Input: Greece is larger than mexico.
Knowledge: Greece is approximately 131,957 sq km, while Mexico is approximately 1,964,375 sq km, making Mexico 1,389% larger than Greece.

Input: Glasses always fog up.
Knowledge: Condensation occurs on eyeglass lenses when water vapor from your sweat, breath, and ambient humidity lands on a cold surface, cools, and then changes into tiny drops of liquid, forming a film that you see as fog. Your lenses will be relatively cool compared to your breath, especially when the outside air is cold.

Input: A fish is capable of thinking.
Knowledge: Fish are more intelligent than they appear. In many areas, such as memory, their cognitive powers match or exceed those of ’higher’ vertebrates including non-human primates. Fish’s long-term memories help them keep track of complex social relationships.

Input: A common effect of smoking lots of cigarettes in one’s lifetime is a higher than normal chance of getting lung cancer.
Knowledge: Those who consistently averaged less than one cigarette per day over their lifetime had nine times the risk of dying from lung cancer than never smokers. Among people who smoked between one and 10 cigarettes per day, the risk of dying from lung cancer was nearly 12 times higher than that of never smokers.

Input: A rock is the same size as a pebble.
Knowledge: A pebble is a clast of rock with a particle size of 4 to 64 millimetres based on the Udden-Wentworth scale of sedimentology. Pebbles are generally considered larger than granules (2 to 4 millimetres diameter) and smaller than cobbles (64 to 256 millimetres diameter).

Input: Part of golf is trying to get a higher point total than others.
Knowledge:

Kiến thức 1:

code
The objective of golf is to play a set of holes in the least number of strokes. A round of golf typically consists of 18 holes. Each hole is played once in the round on a standard golf course. Each stroke is counted as one point, and the total number of strokes is used to determine the winner of the game.

Kiến thức 2:

code
Golf is a precision club-and-ball sport in which competing players (or golfers) use many types of clubs to hit balls into a series of holes on a course using the fewest number of strokes. The goal is to complete the course with the lowest score, which is calculated by adding up the total number of strokes taken on each hole. The player with the lowest score wins the game.

Prompt trên là prompt được cung cấp trong bài báo của Liu et al. 2022.

Bước 2: tích hợp kiến thức và dự đoán

Bước tiếp theo là đưa kiến thức vào và lấy dự đoán. Tác giả đã định dạng lại câu hỏi theo kiểu QA để dẫn dắt định dạng câu trả lời.

Prompt:

code
Question: Part of golf is trying to get a higher point total than others. Yes or No?

Knowledge: The objective of golf is to play a set of holes in the least number of strokes. A round of golf typically consists of 18 holes. Each hole is played once in the round on a standard golf course. Each stroke is counted as one point, and the total number of strokes is used to determine the winner of the game.

Explain and Answer: 

Câu trả lời 1 (độ tự tin rất cao):

code
No, the objective of golf is not to get a higher point total than others. Rather, the objective is to play a set of holes in the least number of strokes. The total number of strokes is used to determine the winner of the game, not the total number of points.
code
Question: Part of golf is trying to get a higher point total than others. Yes or No?

Knowledge: Golf is a precision club-and-ball sport in which competing players (or golfers) use many types of clubs to hit balls into a series of holes on a course using the fewest number of strokes. The goal is to complete the course with the lowest score, which is calculated by adding up the total number of strokes taken on each hole. The player with the lowest score wins the game.

Explain and Answer:

Câu trả lời 2 (độ tự tin thấp hơn nhiều):

code
Yes, part of golf is trying to get a higher point total than others. Each player tries to complete the course with the lowest score, which is calculated by adding up the total number of strokes taken on each hole. The player with the lowest score wins the game.

Nhận xét

Ví dụ này có vài điều rất thú vị. Ở câu trả lời thứ nhất, model rất tự tin, còn ở câu thứ hai thì không hẳn. Tác giả đã đơn giản hoá quy trình để minh hoạ, nhưng còn vài chi tiết cần cân nhắc khi đi tới câu trả lời cuối cùng. Xem bài báo để biết thêm.

Nguồn