<!DOCTYPE html>
    <html lang="vi" xmlns="http://www.w3.org/1999/xhtml" prefix="og: http://ogp.me/ns#">
    <head>
<title>Hướng dẫn kỹ thuật lời nhắc. Kỹ thuật viết lời nhắc. Chuỗi lời nhắc</title>
<meta name="description" content="Hướng dẫn kỹ thuật lời nhắc. Kỹ thuật viết lời nhắc. Chuỗi lời nhắc - Savefile - Blogs -...">
<meta name="author" content="Blog FOSS by Lê Trung Nghĩa">
<meta name="copyright" content="Blog FOSS by Lê Trung Nghĩa [webmaster@vinades.vn]">
<meta name="generator" content="NukeViet v4.5">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta property="og:title" content="Hướng dẫn kỹ thuật lời nhắc. Kỹ thuật viết lời nhắc. Chuỗi lời nhắc">
<meta property="og:type" content="website">
<meta property="og:description" content="Savefile - Blogs - https&#x3A;&#x002F;&#x002F;letrungnghia.mangvn.org&#x002F;savefile&#x002F;Education&#x002F;huong-dan-ky-thuat-loi-nhac-ky-thuat-viet-loi-nhac-chuoi-loi-nhac-7797.html">
<meta property="og:site_name" content="Blog FOSS by Lê Trung Nghĩa">
<meta property="og:url" content="https://letrungnghia.mangvn.org/savefile/Education/huong-dan-ky-thuat-loi-nhac-ky-thuat-viet-loi-nhac-chuoi-loi-nhac-7797.html">
<link rel="shortcut icon" href="https://letrungnghia.mangvn.org/favicon.ico">
<link rel="canonical" href="https://letrungnghia.mangvn.org/savefile/Education/huong-dan-ky-thuat-loi-nhac-ky-thuat-viet-loi-nhac-chuoi-loi-nhac-7797.html">
<link rel="alternate" href="https://letrungnghia.mangvn.org/rss/" title="Blogs" type="application/rss+xml">
<link rel="alternate" href="https://letrungnghia.mangvn.org/rss/Government/" title="Blogs - Government" type="application/rss+xml">
<link rel="alternate" href="https://letrungnghia.mangvn.org/rss/Policy/" title="Blogs - Policy" type="application/rss+xml">
<link rel="alternate" href="https://letrungnghia.mangvn.org/rss/Philosophy/" title="Blogs - Philosophy" type="application/rss+xml">
<link rel="alternate" href="https://letrungnghia.mangvn.org/rss/Security/" title="Blogs - Security" type="application/rss+xml">
<link rel="alternate" href="https://letrungnghia.mangvn.org/rss/Legal/" title="Blogs - Legal" type="application/rss+xml">
<link rel="alternate" href="https://letrungnghia.mangvn.org/rss/Education/" title="Blogs - Education" type="application/rss+xml">
<link rel="alternate" href="https://letrungnghia.mangvn.org/rss/Business/" title="Blogs - Business" type="application/rss+xml">
<link rel="alternate" href="https://letrungnghia.mangvn.org/rss/Community/" title="Blogs - Community" type="application/rss+xml">
<link rel="alternate" href="https://letrungnghia.mangvn.org/rss/Interoperability/" title="Blogs - Interoperability" type="application/rss+xml">
<link rel="alternate" href="https://letrungnghia.mangvn.org/rss/Standards/" title="Blogs - Standards" type="application/rss+xml">
<link rel="alternate" href="https://letrungnghia.mangvn.org/rss/Author/" title="Blogs - Author" type="application/rss+xml">
<link rel="alternate" href="https://letrungnghia.mangvn.org/rss/Opinions/" title="Blogs - Opinions" type="application/rss+xml">
<link rel="alternate" href="https://letrungnghia.mangvn.org/rss/CC/" title="Blogs - CC" type="application/rss+xml">
<link rel="alternate" href="https://letrungnghia.mangvn.org/rss/Cloud/" title="Blogs - Cloud" type="application/rss+xml">
<link rel="alternate" href="https://letrungnghia.mangvn.org/rss/Hardware/" title="Blogs - Hardware" type="application/rss+xml">
<link rel="alternate" href="https://letrungnghia.mangvn.org/rss/Software/" title="Blogs - Software" type="application/rss+xml">
<link rel="alternate" href="https://letrungnghia.mangvn.org/rss/Statistics/" title="Blogs - Statistics" type="application/rss+xml">
<link rel="alternate" href="https://letrungnghia.mangvn.org/rss/Trends/" title="Blogs - Trends" type="application/rss+xml">
<link rel="alternate" href="https://letrungnghia.mangvn.org/rss/China/" title="Blogs - China" type="application/rss+xml">
<link rel="alternate" href="https://letrungnghia.mangvn.org/rss/OSs/" title="Blogs - OSs" type="application/rss+xml">
<link rel="alternate" href="https://letrungnghia.mangvn.org/rss/Blogs/" title="Blogs - Blogs" type="application/rss+xml">
<link rel="alternate" href="https://letrungnghia.mangvn.org/rss/Outsourcing/" title="Blogs - Outsourcing" type="application/rss+xml">
<link rel="alternate" href="https://letrungnghia.mangvn.org/rss/elearning/" title="Blogs - Elearning" type="application/rss+xml">
<link rel="preload" as="style" href="https://letrungnghia.mangvn.org/assets/css/font-awesome.min.css" type="text/css">
<link rel="preload" as="style" href="https://letrungnghia.mangvn.org/themes/default/css/bootstrap.non-responsive.css" type="text/css">
<link rel="preload" as="style" href="https://letrungnghia.mangvn.org/themes/default/css/style.css" type="text/css">
<link rel="preload" as="style" href="https://letrungnghia.mangvn.org/themes/default/css/style.non-responsive.css" type="text/css">
<link rel="preload" as="style" href="https://letrungnghia.mangvn.org/themes/default/css/news.css" type="text/css">
<link rel="preload" as="style" href="https://letrungnghia.mangvn.org/themes/default/css/custom.css" type="text/css">
<link rel="preload" as="style" href="https://letrungnghia.mangvn.org/assets/css/default.vi.1106.css" type="text/css">
<link rel="preload" as="script" href="https://letrungnghia.mangvn.org/assets/js/jquery/jquery.min.js" type="text/javascript">
<link rel="preload" as="script" href="https://letrungnghia.mangvn.org/assets/js/language/vi.js" type="text/javascript">
<link rel="preload" as="script" href="https://letrungnghia.mangvn.org/assets/js/DOMPurify/purify3.js" type="text/javascript">
<link rel="preload" as="script" href="https://letrungnghia.mangvn.org/assets/js/global.js" type="text/javascript">
<link rel="preload" as="script" href="https://letrungnghia.mangvn.org/assets/js/site.js" type="text/javascript">
<link rel="preload" as="script" href="https://letrungnghia.mangvn.org/themes/default/js/news.js" type="text/javascript">
<link rel="preload" as="script" href="https://letrungnghia.mangvn.org/themes/default/js/main.js" type="text/javascript">
<link rel="preload" as="script" href="https://letrungnghia.mangvn.org/themes/default/js/custom.js" type="text/javascript">
<link rel="preload" as="script" href="https://letrungnghia.mangvn.org/themes/default/js/bootstrap.min.js" type="text/javascript">
<link rel="stylesheet" href="https://letrungnghia.mangvn.org/assets/css/font-awesome.min.css">
<link rel="stylesheet" href="https://letrungnghia.mangvn.org/themes/default/css/bootstrap.non-responsive.css">
<link rel="stylesheet" href="https://letrungnghia.mangvn.org/themes/default/css/style.css">
<link rel="stylesheet" href="https://letrungnghia.mangvn.org/themes/default/css/style.non-responsive.css">
<link rel="StyleSheet" href="https://letrungnghia.mangvn.org/themes/default/css/news.css">
<link rel="stylesheet" href="https://letrungnghia.mangvn.org/themes/default/css/custom.css">
<link rel="stylesheet" href="https://letrungnghia.mangvn.org/assets/css/default.vi.1106.css">
<style type="text/css">
	body{background: #fff;}
</style>
<script>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-70254229-3', '');
ga('send', 'pageview');
</script>
</head>
    <body>
<div id="print">
	<div id="hd_print">
		<h2 class="pull-left">Blog FOSS by Lê Trung Nghĩa</h2>
		<p class="pull-right"><a title="Blog FOSS by Lê Trung Nghĩa" href="https://letrungnghia.mangvn.org/">https://letrungnghia.mangvn.org</a></p>
	</div>
	<div class="clear"></div>
	<hr />
	<div id="content">
		<h1>Hướng dẫn kỹ thuật lời nhắc. Kỹ thuật viết lời nhắc. Chuỗi lời nhắc</h1>
		<ul class="list-inline">
			<li>Thứ năm - 06/11/2025 06:19</li>
			<li class="hidden-print txtrequired"><em class="fa fa-print">&nbsp;</em><a title="In ra" href="javascript:;" onclick="window.print()">In ra</a></li>
			<li class="hidden-print txtrequired"><em class="fa fa-power-off">&nbsp;</em><a title="Đóng cửa sổ này" href="javascript:;" onclick="window.close()">Đóng cửa sổ này</a></li>
		</ul>
		<div class="clear"></div>
		<div id="hometext">
		</div>
				<div class="imghome">
			<img alt="Hướng dẫn kỹ thuật lời nhắc. Kỹ thuật viết lời nhắc. Chuỗi lời nhắc" src="https://letrungnghia.mangvn.org/uploads/letrungnghia/news/2025/0_prompt-engineering.png" width="460" class="img-thumbnail" />
		</div>
		<div class="clear"></div>
		<div id="bodytext" class="clearfix">
			<p align="justify"><b><span style="background: rgb(255, 255, 0);">Prompt Chaining</span></b></p>

<p align="justify">Theo: <a href="https://www.promptingguide.ai/techniques/prompt_chaining">https://www.promptingguide.ai/techniques/prompt_chaining</a></p>

<p align="justify"><b>Giới thiệu Chuỗi lời nhắc </b></p>

<div class="image-center"><img alt="" height="393" src="https://letrungnghia.mangvn.org/uploads/letrungnghia/news/2025/2.7-prompt-chaining_1.png" width="690" /></div>

<p align="center">Video: <a href="https://www.youtube.com/watch?v=CKZC5RigYEc">Chuỗi lời nhắc với GPT-4o và Flowise AI (Sách hướng dẫn)</a></p>

<p align="justify">Để cải thiện độ tin cậy và hiệu suất của LLM, một trong những kỹ thuật thiết kế lời nhắc quan trọng là chia nhỏ tác vụ thành các tác vụ con. Khi các tác vụ con đó đã được xác định, LLM sẽ được nhắc nhở bằng một tác vụ con và sau đó phản hồi của nó được sử dụng làm đầu vào cho một lời nhắc khác. Đây chính là phương pháp xâu chuỗi lời nhắc, trong đó một tác vụ được chia thành các tác vụ con với mục đích tạo ra một chuỗi các thao tác nhắc.</p>

<p align="justify">Xâu chuỗi lời nhắc rất hữu ích để hoàn thành các tác vụ phức tạp mà LLM có thể gặp khó khăn khi được nhắc bằng một lời nhắc quá chi tiết. Trong việc xâu chuỗi nhắc nhở, các lời nhắc chuỗi thực hiện các chuyển đổi hoặc quy trình bổ sung dựa trên các phản hồi được tạo ra trước khi đạt đến trạng thái mong muốn cuối cùng.</p>

<p align="justify">Bên cạnh việc đạt được hiệu suất tốt hơn, việc xâu chuỗi lời nhắc còn giúp tăng cường tính minh bạch của ứng dụng LLM, tăng khả năng kiểm soát và độ tin cậy. Điều này có nghĩa là bạn có thể gỡ lỗi các vấn đề với phản hồi của mô hình dễ dàng hơn nhiều, đồng thời phân tích và cải thiện hiệu suất trong các giai đoạn khác nhau cần cải thiện.</p>

<p align="justify">Xâu chuỗi lời nhắc đặc biệt hữu ích khi xây dựng các trợ lý đàm thoại được LLM hỗ trợ và cải thiện tính cá nhân hóa cũng như trải nghiệm người dùng trong ứng dụng của bạn.</p>

<p align="justify"><b>Các trường hợp sử dụng cho chuỗi lời nhắc</b></p>

<p align="justify"><i>Chuỗi nhắc cho QA tài liệu</i></p>

<p align="justify">Chuỗi lời nhắc có thể được sử dụng trong các tình huống khác nhau, bao gồm nhiều thao tác hoặc chuyển đổi. Ví dụ, một trường hợp sử dụng phổ biến của LLM liên quan đến việc trả lời các câu hỏi về một tài liệu văn bản lớn. Sẽ rất hữu ích nếu bạn thiết kế hai lời nhắc khác nhau, trong đó lời nhắc đầu tiên chịu trách nhiệm trích xuất các trích dẫn liên quan để trả lời câu hỏi và lời nhắc thứ hai lấy dữ liệu đầu vào là các trích dẫn và tài liệu gốc để trả lời câu hỏi cho trước. Nói cách khác, bạn sẽ tạo hai lời nhắc khác nhau để thực hiện nhiệm vụ trả lời một câu hỏi được đưa ra trong tài liệu.</p>

<p align="justify">Lời nhắc đầu tiên bên dưới trích xuất các trích dẫn liên quan từ tài liệu được đưa ra cho câu hỏi. Lưu ý rằng để đơn giản, chúng tôi đã thêm một trình giữ chỗ cho tài liệu {{document}}. Để kiểm tra lời nhắc, bạn có thể sao chép và dán một bài viết từ Wikipedia, chẳng hạn như trang này, để thiết kế lời nhắc. Do ngữ cảnh được sử dụng rộng hơn cho nhiệm vụ này, chúng tôi đang sử dụng mô hình gpt-4-1106-preview từ OpenAI. Bạn có thể sử dụng lời nhắc này với các LLM ngữ cảnh dài khác như Claude.</p>

<p><i><span style="background: transparent">Prompt 1:</span></i></p>

<pre class="western" style="margin-left: 1.25cm">
<code class="western hljs perl"><span style="background: transparent">Bạn là <span class="hljs-keyword">m</span>ột <span class="hljs-keyword">tr</span>ợ lý hữu ích. Nhiệ<span class="hljs-keyword">m</span> vụ của bạn là giúp <span class="hljs-keyword">tr</span>ả lời <span class="hljs-keyword">m</span>ột câu hỏi được đưa ra trong tài liệu. Bước đầu tiên là <span class="hljs-keyword">tr</span>ích xuất các <span class="hljs-keyword">tr</span>ích dẫn liên quan đến câu hỏi từ tài liệu, được phân cách bằng <span class="hljs-comment">####. Vui lòng xuất danh sách trích dẫn bằng &lt;quotes&gt;&lt;/quotes&gt;. Trả lời &quot;Không tìm thấy trích dẫn liên quan!&quot; nếu không tìm thấy trích dẫn liên quan.</span></span></code>
<code class="western hljs bash"><span style="background: transparent"><span class="hljs-comment">####</span></span></code>
<code class="western hljs coffeescript"><span style="background: transparent">{{<span class="hljs-built_in">document</span>}}</span></code>
<code class="western hljs bash"><span style="background: transparent"><span class="hljs-comment">####</span></span></code></pre>

<p align="justify">Sau đây là ảnh chụp màn hình toàn bộ lời nhắc bao gồm câu hỏi được truyền bằng việc sử dụng vai trò của người dùng.</p>

<div class="image-center"><img alt="" height="597" src="https://giaoducmo.avnuc.vn/uploads/news/2025_11/2.7-prompt-chaining_2.png" width="766" /></div>

<p align="justify"><i>Output of Prompt 1:</i></p>

<pre class="western" style="margin-left: 1.25cm">
<code class="western hljs xml"><span class="hljs-tag">&lt;<span class="hljs-title">quotes</span>&gt;</span></code>
<code class="western hljs diff"><span class="hljs-deletion">- Lời nhắc chuỗi suy nghĩ (CoT)&#91;27&#93;</span></code>
<code class="western hljs diff"><span class="hljs-deletion">- Lời nhắc kiến thức được tạo ra&#91;37&#93;</span></code>
<code class="western hljs diff"><span class="hljs-deletion">- Lời nhắc từ ít nhất đến nhiều nhất&#91;38&#93;</span></code>
<code class="western hljs diff"><span class="hljs-deletion">- Giải mã tính tự nhất quán&#91;39&#93;</span></code>
<code class="western hljs diff"><span class="hljs-deletion">- Lời nhắc dựa trên độ phức tạp&#91;41&#93;</span></code>
<code class="western hljs diff"><span class="hljs-deletion">- Tự tinh chỉnh&#91;42&#93;</span></code>
<code class="western hljs diff"><span class="hljs-deletion">- Lời nhắc cây suy nghĩ&#91;43&#93;</span></code>
<code class="western hljs diff"><span class="hljs-deletion">- Lời nhắc Maieutic&#91;45&#93;</span></code>
<code class="western hljs diff"><span class="hljs-deletion">- Lời nhắc kích thích định hướng&#91;46&#93;</span></code>
<code class="western hljs diff"><span class="hljs-deletion">- Đảo ngược văn bản và nhúng&#91;59&#93;</span></code>
<code class="western hljs markdown"><span class="hljs-bullet">- </span>Sử dụng giảm dần độ dốc để tìm kiếm lời nhắc&#91;<span class="hljs-link_label">61</span>&#93;&#91;<span class="hljs-link_reference">62</span>&#93;&#91;<span class="hljs-link_label">63</span>&#93;&#91;<span class="hljs-link_reference">64</span>&#93;</code>
<code class="western hljs markdown"><span class="hljs-bullet">- </span>Chèn lời nhắc&#91;<span class="hljs-link_label">65</span>&#93;&#91;<span class="hljs-link_reference">66</span>&#93;&#91;<span class="hljs-link_label">67</span>&#93;</code>
<code class="western hljs xml"><span class="hljs-tag">&lt;/<span class="hljs-title">quotes</span>&gt;</span></code></pre>

<p align="justify" style="line-height: 100%; margin-bottom: 0cm">&nbsp;</p>

<p align="justify">Các trích dẫn được trả về trong lời nhắc đầu tiên giờ đây có thể được sử dụng làm đầu vào cho lời nhắc thứ hai bên dưới. Lưu ý rằng bạn có thể dọn dẹp các trích dẫn thêm một chút, tức là xóa các trích dẫn. Các trích dẫn đó có thể được xóa hoặc sử dụng như một phần của một lời nhắc khác trong chuỗi, nhưng bạn có thể bỏ qua điều này ngay bây giờ. Lời nhắc thứ hai sau đó sẽ lấy các trích dẫn liên quan được trích xuất bởi lời nhắc 1 và chuẩn bị một câu trả lời hữu ích cho câu hỏi được đưa ra trong tài liệu và các trích dẫn được trích xuất đó. Lời nhắc thứ hai có thể như sau:</p>

<p><i>Prompt 2:</i></p>

<pre class="western" style="margin-left: 1.25cm">
<code class="western hljs xml">Cho một tập hợp các trích dẫn liên quan (được phân cách bằng <span class="hljs-tag">&lt;<span class="hljs-title">quotes</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-title">quotes</span>&gt;</span>) được trích xuất từ một tài liệu và tài liệu gốc (được phân cách bằng ####), vui lòng soạn câu trả lời cho câu hỏi. Đảm bảo câu trả lời chính xác, có giọng điệu thân thiện và hữu ích.</code>

<code class="western hljs bash"><span class="hljs-comment">####</span></code>
<code class="western hljs coffeescript">{{<span class="hljs-built_in">document</span>}}</code>
<code class="western hljs bash"><span class="hljs-comment">####</span></code>

<code class="western hljs xml"><span class="hljs-tag">&lt;<span class="hljs-title">quotes</span>&gt;</span></code>
<code class="western hljs diff"><span class="hljs-deletion">- Lời nhắc chuỗi suy nghĩ (CoT)&#91;27&#93;</span></code>
<code class="western hljs diff"><span class="hljs-deletion">- Lời nhắc kiến thức được tạo ra&#91;37&#93;</span></code>
<code class="western hljs diff"><span class="hljs-deletion">- Lời nhắc từ ít nhất đến nhiều nhất&#91;38&#93;</span></code>
<code class="western hljs diff"><span class="hljs-deletion">- Giải mã tính nhất quán tự thân&#91;39&#93;</span></code>
<code class="western hljs diff"><span class="hljs-deletion">- Lời nhắc dựa trên độ phức tạp&#91;41&#93;</span></code>
<code class="western hljs diff"><span class="hljs-deletion">- Tự tinh chỉnh&#91;42&#93;</span></code>
<code class="western hljs diff"><span class="hljs-deletion">- Lời nhắc cây suy nghĩ&#91;43&#93;</span></code>
<code class="western hljs diff"><span class="hljs-deletion">- Lời nhắc Maieutic&#91;45&#93;</span></code>
<code class="western hljs diff"><span class="hljs-deletion">- Lời nhắc kích thích định hướng&#91;46&#93;</span></code>
<code class="western hljs diff"><span class="hljs-deletion">- Đảo ngược văn bản và nhúng&#91;59&#93;</span></code>
<code class="western hljs markdown"><span class="hljs-bullet">- </span>Sử dụng gradient descent để tìm kiếm lời nhắc &#91;<span class="hljs-link_label">61</span>&#93;&#91;<span class="hljs-link_reference">62</span>&#93;&#91;<span class="hljs-link_label">63</span>&#93;&#91;<span class="hljs-link_reference">64</span>&#93;</code>
<code class="western hljs markdown"><span class="hljs-bullet">- </span>Chèn lời nhắc &#91;<span class="hljs-link_label">65</span>&#93;&#91;<span class="hljs-link_reference">66</span>&#93;&#91;<span class="hljs-link_label">67</span>&#93;</code>
<code class="western hljs xml"><span class="hljs-tag">&lt;/<span class="hljs-title">quotes</span>&gt;</span></code></pre>

<p><i>Đầu ra của Lời nhắc 2: (Output of Prompt 2:)</i></p>

<pre class="western" style="margin-left: 1.25cm">
<code class="western hljs ">Các kỹ thuật nhắc được nêu trong tài liệu này bao gồm: </code>
<code class="western hljs markdown"><span class="hljs-bullet">1. </span>Lời nhắc chuỗi tư duy (CoT) &#91;27&#93;</code>
<code class="western hljs markdown"><span class="hljs-bullet">2. </span>Lời nhắc kiến thức được tạo ra &#91;37&#93;</code>
<code class="western hljs markdown"><span class="hljs-bullet">3. </span>Lời nhắc từ ít nhất tới nhiều nhất &#91;38&#93;</code>
<code class="western hljs markdown"><span class="hljs-bullet">4. </span>Giải mã tự nhất quán &#91;39&#93;</code>
<code class="western hljs markdown"><span class="hljs-bullet">5. </span>Lời nhắc dựa trên sự phức tạp &#91;41&#93;</code>
<code class="western hljs markdown"><span class="hljs-bullet">6. </span>Tự tinh chỉnh &#91;42&#93;</code>
<code class="western hljs markdown"><span class="hljs-bullet">7. </span>Lời nhắc Cây tư duy &#91;43&#93;</code>
<code class="western hljs markdown"><span class="hljs-bullet">8. </span>Lời nhắc Maieutic&#91;45&#93;</code>
<code class="western hljs markdown"><span class="hljs-bullet">9. </span>Lời nhắc kích thích định hướng &#91;46&#93;</code>
<code class="western hljs markdown"><span class="hljs-bullet">10. </span>Đảo ngược văn bản và nhúng &#91;59&#93;</code>
<code class="western hljs markdown"><span class="hljs-bullet">11. </span>Sử dụng độ dốc giảm dần để tìm kiếm các lời nhắc &#91;<span class="hljs-link_label">61</span>&#93;&#91;<span class="hljs-link_reference">62</span>&#93;&#91;<span class="hljs-link_label">63</span>&#93;&#91;<span class="hljs-link_reference">64</span>&#93;</code>
<code class="western hljs markdown"><span class="hljs-bullet">12. </span>Chèn lời nhắc &#91;<span class="hljs-link_label">65</span>&#93;&#91;<span class="hljs-link_reference">66</span>&#93;&#91;<span class="hljs-link_label">67</span>&#93;</code>

<code class="western hljs ">Mỗi kỹ thuật này sử dụng các chiến lược riêng để tăng cường hoặc chỉ định các tương tác với các mô hình ngôn ngữ lớn nhằm tạo ra kết quả mong muốn.</code></pre>

<p align="justify">Như bạn thấy, việc đơn giản hóa và tạo chuỗi lời nhắc là một phương pháp nhắc hữu ích khi các phản hồi cần trải qua nhiều thao tác hoặc chuyển đổi. Để thực hành, bạn có thể thiết kế một lời nhắc loại bỏ các trích dẫn (ví dụ: &#91;27&#93;) khỏi phản hồi trước khi gửi phản hồi này dưới dạng phản hồi cuối cùng cho người dùng ứng dụng của bạn.</p>

<p>Bạn cũng có thể tìm thêm các ví dụ về chuỗi lời nhắc trong <a href="https://docs.anthropic.com/claude/docs/prompt-chaining">tài liệu này</a>, sử dụng Claude LLM. Ví dụ của chúng tôi được lấy cảm hứng và điều chỉnh từ các ví dụ của họ.</p>

<p align="justify" style="font-style: normal"><em><a href="https://giaoducmo.avnuc.vn/ai/huong-dan-ky-thuat-loi-nhac-ky-thuat-viet-loi-nhac-1577.html"><span style="font-style: normal"><span style="font-weight: normal"><span style="background: transparent">Về ‘Kỹ thuật viết lời nhắc’</span></span></span></a></em><em><span style="font-style: normal"> ………. <a href="https://giaoducmo.avnuc.vn/ai/huong-dan-ky-thuat-loi-nhac-ky-thuat-viet-loi-nhac-loi-nhac-kien-thuc-duoc-tao-1583.html">Phần trước</a> ………. Phần tiếp theo</span></em></p>

<p align="justify" style="font-style: normal">&nbsp;</p>

<p align="justify"><span style="background: rgb(255, 255, 0);">Video: <a href="https://www.youtube.com/watch?v=CKZC5RigYEc">Prompt Chaining with GPT-4o and Flowise AI (Tutorial)</a></span></p>

<p align="justify"><b><span style="background: rgb(255, 255, 0);">Introduction to Prompt Chaining</span></b></p>

<p align="justify"><span style="background: rgb(255, 255, 0);">To improve the reliability and performance of LLMs, one of the important prompt engineering techniques is to break tasks into its subtasks. Once those subtasks have been identified, the LLM is prompted with a subtask and then its response is used as input to another prompt. This is what&#039;s referred to as prompt chaining, where a task is split into subtasks with the idea to create a chain of prompt operations.</span></p>

<p align="justify"><span style="background: rgb(255, 255, 0);">Prompt chaining is useful to accomplish complex tasks which an LLM might struggle to address if prompted with a very detailed prompt. In prompt chaining, chain prompts perform transformations or additional processes on the generated responses before reaching a final desired state.</span></p>

<p align="justify"><span style="background: rgb(255, 255, 0);">Besides achieving better performance, prompt chaining helps to boost the transparency of your LLM application, increases controllability, and reliability. This means that you can debug problems with model responses much more easily and analyze and improve performance in the different stages that need improvement.</span></p>

<p align="justify"><span style="background: rgb(255, 255, 0);">Prompt chaining is particularly useful when building LLM-powered conversational assistants and improving the personalization and user experience of your applications.</span></p>

<p><a name="use-cases-for-prompt-chaining"></a><b><span style="background: rgb(255, 255, 0);">Use Cases for Prompt Chaining</span></b></p>

<p><a name="prompt-chaining-for-document-qa"></a><i><span style="background: rgb(255, 255, 0);">Prompt Chaining for Document QA</span></i></p>

<p align="justify"><span style="background: rgb(255, 255, 0);">Prompt chaining can be used in different scenarios that could involve several operations or transformations. For instance, one common use case of LLMs involves answering questions about a large text document. It helps if you design two different prompts where the first prompt is responsible for extracting relevant quotes to answer a question and a second prompt takes as input the quotes and original document to answer a given question. In other words, you will be creating two different prompts to perform the task of answering a question given in a document.</span></p>

<p align="justify"><span style="background: rgb(255, 255, 0);">The first prompt below extracts the relevant quotes from the document given the question. Note that for simplicity, we have added a placeholder for the document </span><code class="western"><span style="background: rgb(255, 255, 0);">{{document}}</span></code><span style="background: rgb(255, 255, 0);">. To test the prompt you can copy and paste an article from Wikipedia such as this page for <a href="https://en.wikipedia.org/wiki/Prompt_engineering" target="_blank">prompt engineering</a>. Due to larger context used for this task, we are using the </span><code class="western"><span style="background: rgb(255, 255, 0);">gpt-4-1106-preview</span></code><span style="background: rgb(255, 255, 0);"> model from OpenAI. You can use the prompt with other long-context LLMs like Claude.</span></p>

<p><i><span style="background: rgb(255, 255, 0);">Prompt 1:</span></i></p>

<pre class="western" style="margin-left: 1.25cm">
<code class="western"><span style="background: rgb(255, 255, 0);">You are a helpful assistant. Your task is to help answer a question given in a document. The first step is to extract quotes relevant to the question from the document, delimited by ####. Please output the list of quotes using &lt;quotes&gt;&lt;/quotes&gt;. Respond with &quot;No relevant quotes found!&quot; if no relevant quotes were found.</span></code>
<code class="western"><span style="background: rgb(255, 255, 0);">####</span></code>
<code class="western"><span style="background: rgb(255, 255, 0);">{{document}}</span></code>
<code class="western"><span style="background: rgb(255, 255, 0);">####</span></code></pre>

<p><span style="background: rgb(255, 255, 0);">Here is a screenshot of the entire prompt including the question which is passed using the </span><code class="western"><span style="background: rgb(255, 255, 0);">user</span></code><span style="background: rgb(255, 255, 0);"> role.</span></p>

<p align="justify"><i><span style="background: rgb(255, 255, 0);">Output of Prompt 1:</span></i></p>

<pre class="western" style="margin-left: 1.25cm">
<code class="western"><span style="background: rgb(255, 255, 0);">&lt;quotes&gt;</span></code>
<code class="western"><span style="background: rgb(255, 255, 0);">- Chain-of-thought (CoT) prompting&#91;27&#93;</span></code>
<code class="western"><span style="background: rgb(255, 255, 0);">- Generated knowledge prompting&#91;37&#93;</span></code>
<code class="western"><span style="background: rgb(255, 255, 0);">- Least-to-most prompting&#91;38&#93;</span></code>
<code class="western"><span style="background: rgb(255, 255, 0);">- Self-consistency decoding&#91;39&#93;</span></code>
<code class="western"><span style="background: rgb(255, 255, 0);">- Complexity-based prompting&#91;41&#93;</span></code>
<code class="western"><span style="background: rgb(255, 255, 0);">- Self-refine&#91;42&#93;</span></code>
<code class="western"><span style="background: rgb(255, 255, 0);">- Tree-of-thought prompting&#91;43&#93;</span></code>
<code class="western"><span style="background: rgb(255, 255, 0);">- Maieutic prompting&#91;45&#93;</span></code>
<code class="western"><span style="background: rgb(255, 255, 0);">- Directional-stimulus prompting&#91;46&#93;</span></code>
<code class="western"><span style="background: rgb(255, 255, 0);">- Textual inversion and embeddings&#91;59&#93;</span></code>
<code class="western"><span style="background: rgb(255, 255, 0);">- Using gradient descent to search for prompts&#91;61&#93;&#91;62&#93;&#91;63&#93;&#91;64&#93;</span></code>
<code class="western"><span style="background: rgb(255, 255, 0);">- Prompt injection&#91;65&#93;&#91;66&#93;&#91;67&#93;</span></code>
<code class="western"><span style="background: rgb(255, 255, 0);">&lt;/quotes&gt;</span></code></pre>

<p align="justify"><span style="background: rgb(255, 255, 0);">The quotes that were returned in the first prompt can now be used as input to the second prompt below. Note that you can clean up the quotes a bit more, i.e., remove the citations. Those citations could be removed or utilized as part of another prompt in the chain but you can ignore this for now. The second prompt then takes the relevant quotes extracted by prompt 1 and prepares a helpful response to the question given in the document and those extracted quotes. The second prompt can be the following:</span></p>

<p><i><span style="background: rgb(255, 255, 0);">Prompt 2:</span></i></p>

<pre class="western" style="margin-left: 1.25cm">
<code class="western"><span style="background: rgb(255, 255, 0);">Given a set of relevant quotes (delimited by &lt;quotes&gt;&lt;/quotes&gt;) extracted from a document and the original document (delimited by ####), please compose an answer to the question. Ensure that the answer is accurate, has a friendly tone, and sounds helpful.</span></code>

<code class="western"><span style="background: rgb(255, 255, 0);">####</span></code>
<code class="western"><span style="background: rgb(255, 255, 0);">{{document}}</span></code>
<code class="western"><span style="background: rgb(255, 255, 0);">####</span></code>

<code class="western"><span style="background: rgb(255, 255, 0);">&lt;quotes&gt;</span></code>
<code class="western"><span style="background: rgb(255, 255, 0);">- Chain-of-thought (CoT) prompting&#91;27&#93;</span></code>
<code class="western"><span style="background: rgb(255, 255, 0);">- Generated knowledge prompting&#91;37&#93;</span></code>
<code class="western"><span style="background: rgb(255, 255, 0);">- Least-to-most prompting&#91;38&#93;</span></code>
<code class="western"><span style="background: rgb(255, 255, 0);">- Self-consistency decoding&#91;39&#93;</span></code>
<code class="western"><span style="background: rgb(255, 255, 0);">- Complexity-based prompting&#91;41&#93;</span></code>
<code class="western"><span style="background: rgb(255, 255, 0);">- Self-refine&#91;42&#93;</span></code>
<code class="western"><span style="background: rgb(255, 255, 0);">- Tree-of-thought prompting&#91;43&#93;</span></code>
<code class="western"><span style="background: rgb(255, 255, 0);">- Maieutic prompting&#91;45&#93;</span></code>
<code class="western"><span style="background: rgb(255, 255, 0);">- Directional-stimulus prompting&#91;46&#93;</span></code>
<code class="western"><span style="background: rgb(255, 255, 0);">- Textual inversion and embeddings&#91;59&#93;</span></code>
<code class="western"><span style="background: rgb(255, 255, 0);">- Using gradient descent to search for prompts&#91;61&#93;&#91;62&#93;&#91;63&#93;&#91;64&#93;</span></code>
<code class="western"><span style="background: rgb(255, 255, 0);">- Prompt injection&#91;65&#93;&#91;66&#93;&#91;67&#93;</span></code>
<code class="western"><span style="background: rgb(255, 255, 0);">&lt;/quotes&gt;</span></code></pre>

<p><i><span style="background: rgb(255, 255, 0);">Output of Prompt 2:</span></i></p>

<pre class="western" style="margin-left: 1.25cm">
<code class="western"><span style="background: rgb(255, 255, 0);">The prompting techniques mentioned in the document include:</span></code>

<code class="western"><span style="background: rgb(255, 255, 0);">1. Chain-of-thought (CoT) prompting&#91;27&#93;</span></code>
<code class="western"><span style="background: rgb(255, 255, 0);">2. Generated knowledge prompting&#91;37&#93;</span></code>
<code class="western"><span style="background: rgb(255, 255, 0);">3. Least-to-most prompting&#91;38&#93;</span></code>
<code class="western"><span style="background: rgb(255, 255, 0);">4. Self-consistency decoding&#91;39&#93;</span></code>
<code class="western"><span style="background: rgb(255, 255, 0);">5. Complexity-based prompting&#91;41&#93;</span></code>
<code class="western"><span style="background: rgb(255, 255, 0);">6. Self-refine&#91;42&#93;</span></code>
<code class="western"><span style="background: rgb(255, 255, 0);">7. Tree-of-thought prompting&#91;43&#93;</span></code>
<code class="western"><span style="background: rgb(255, 255, 0);">8. Maieutic prompting&#91;45&#93;</span></code>
<code class="western"><span style="background: rgb(255, 255, 0);">9. Directional-stimulus prompting&#91;46&#93;</span></code>
<code class="western"><span style="background: rgb(255, 255, 0);">10. Textual inversion and embeddings&#91;59&#93;</span></code>
<code class="western"><span style="background: rgb(255, 255, 0);">11. Using gradient descent to search for prompts&#91;61&#93;&#91;62&#93;&#91;63&#93;&#91;64&#93;</span></code>
<code class="western"><span style="background: rgb(255, 255, 0);">12. Prompt injection&#91;65&#93;&#91;66&#93;&#91;67&#93;</span></code>

<code class="western"><span style="background: rgb(255, 255, 0);">Each of these techniques employs unique strategies to enhance or specify the interactions with large language models to produce the desired outcomes.</span></code></pre>

<p align="justify"><span style="background: rgb(255, 255, 0);">As you can see, simplifying and creating prompt chains is a useful prompting approach where the responses need to undergo several operations or transformations. As an exercise, feel free to design a prompt that removes the citations (e.g., &#91;27&#93;) from the response before sending this as a final response to the user of your application.</span></p>

<p align="justify"><span style="background: rgb(255, 255, 0);">You can also find more examples of prompt chaining in this <a href="https://docs.anthropic.com/claude/docs/prompt-chaining" target="_blank">documentation</a> that leverages the Claude LLM. Our example is inspired and adapted from their examples.</span></p>

<p align="justify">Dịch: Lê Trung Nghĩa</p>

<p align="justify">letrungnghia.foss@gmail.com</p>
&nbsp;
		</div>
				<div id="author">
						<p>
				<strong>Tác giả:</strong>
				<a href="https://letrungnghia.mangvn.org/author/Nghia-Le-Trung/">Nghĩa Lê Trung</a>
			</p>
		</div>
	</div>
	<div id="footer" class="clearfix">
		<div id="url">
			<strong>URL của bản tin này: </strong><a href="https://letrungnghia.mangvn.org/savefile/Education/huong-dan-ky-thuat-loi-nhac-ky-thuat-viet-loi-nhac-chuoi-loi-nhac-7797.html" title="Hướng dẫn kỹ thuật lời nhắc. Kỹ thuật viết lời nhắc. Chuỗi lời nhắc">https://letrungnghia.mangvn.org/savefile/Education/huong-dan-ky-thuat-loi-nhac-ky-thuat-viet-loi-nhac-chuoi-loi-nhac-7797.html</a>

		</div>
		<div class="clear"></div>
		<div class="copyright">
			&copy; Blog FOSS by Lê Trung Nghĩa
		</div>
		<div id="contact">
			<a href="mailto:webmaster@vinades.vn">webmaster@vinades.vn</a>
		</div>
	</div>
</div>
        <div id="timeoutsess" class="chromeframe">
            Bạn đã không sử dụng Site, <a onclick="timeoutsesscancel();" href="https://letrungnghia.mangvn.org/#">Bấm vào đây để duy trì trạng thái đăng nhập</a>. Thời gian chờ: <span id="secField"> 60 </span> giây
        </div>
        <div id="openidResult" class="nv-alert" style="display:none"></div>
        <div id="openidBt" data-result="" data-redirect=""></div>
<div id="run_cronjobs" style="visibility:hidden;display:none;"><img alt="cron" src="/index.php?second=cronjobs&amp;p=u7pvXmXf" width="1" height="1" /></div>
<script src="https://letrungnghia.mangvn.org/assets/js/jquery/jquery.min.js"></script>
<script>var nv_base_siteurl="/",nv_lang_data="vi",nv_lang_interface="vi",nv_name_variable="nv",nv_fc_variable="op",nv_lang_variable="language",nv_module_name="news",nv_func_name="savefile",nv_is_user=0, nv_my_ofs=7,nv_my_abbr="+07",nv_cookie_prefix="nv4c_Cgoz2",nv_check_pass_mstime=1738000,nv_area_admin=0,nv_safemode=0,theme_responsive=0,nv_recaptcha_ver=2,nv_recaptcha_sitekey="6LcNwC8UAAAAAMm8ZTYNygweLUQtOU0IapbDRk69",nv_recaptcha_type="image",XSSsanitize=1;</script>
<script src="https://letrungnghia.mangvn.org/assets/js/language/vi.js"></script>
<script src="https://letrungnghia.mangvn.org/assets/js/DOMPurify/purify3.js"></script>
<script src="https://letrungnghia.mangvn.org/assets/js/global.js"></script>
<script src="https://letrungnghia.mangvn.org/assets/js/site.js"></script>
<script src="https://letrungnghia.mangvn.org/themes/default/js/news.js"></script>
<script src="https://letrungnghia.mangvn.org/themes/default/js/main.js"></script>
<script src="https://letrungnghia.mangvn.org/themes/default/js/custom.js"></script>
<script type="application/ld+json">
        {
            "@context": "https://schema.org",
            "@type": "Organization",
            "url": "https://letrungnghia.mangvn.org",
            "logo": "https://letrungnghia.mangvn.org/uploads/letrungnghia/le-trung-nghia.png"
        }
        </script>
<script src="https://letrungnghia.mangvn.org/themes/default/js/bootstrap.min.js"></script>
</body>
</html>