<!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. Giới thiệu. Ví dụ về lời nhắc</title>
<meta name="description" content="Hướng dẫn kỹ thuật lời nhắc. Giới thiệu. Ví dụ về 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. Giới thiệu. Ví dụ về 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-gioi-thieu-vi-du-ve-loi-nhac-7789.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-gioi-thieu-vi-du-ve-loi-nhac-7789.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-gioi-thieu-vi-du-ve-loi-nhac-7789.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. Giới thiệu. Ví dụ về lời nhắc</h1>
		<ul class="list-inline">
			<li>Thứ ba - 28/10/2025 06:02</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. Giới thiệu. Ví dụ về 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);">Examples of Prompts</span></b></p>

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

<p align="justify">Phần trước đã giới thiệu một ví dụ cơ bản về cách để nhắc cho một mô hình ngôn ngữ lớn - LLM (Large Language Model).</p>

<p align="justify">Phần này sẽ cung cấp thêm các ví dụ về cách sử dụng lời nhắc để hoàn thành các nhiệm vụ khác nhau và giới thiệu các khái niệm chính trong quá trình thực hiện. Thông thường, cách tốt nhất để học các khái niệm là thông qua các ví dụ. Một vài ví dụ dưới đây minh họa cách bạn có thể sử dụng các lời nhắc được thiết kế tốt để thực hiện các loại nhiệm vụ khác nhau.</p>

<p align="justify">Chủ đề:</p>

<ul>
	<li>
	<p align="justify">Tóm tắt văn bản</p>
	</li>
	<li>
	<p align="justify">Trích xuất thông tin</p>
	</li>
	<li>
	<p align="justify">Trả lời câu hỏi</p>
	</li>
	<li>
	<p align="justify">Phân loại văn bản</p>
	</li>
	<li>
	<p align="justify">Hội thoại</p>
	</li>
	<li>
	<p align="justify">Tạo mã</p>
	</li>
	<li>
	<p align="justify">Suy luận</p>
	</li>
</ul>

<div class="image-center"><img alt="" height="393" src="https://letrungnghia.mangvn.org/uploads/letrungnghia/news/2025/1.5-examples-of-prompts.png" width="691" /></div>

<p align="justify">Video: <a href="https://www.youtube.com/watch?v=TBhRC4Dath4">Các ví dụ cơ bản về lời nhắc cho LLM</a></p>

<p align="justify"><b>Tóm tắt văn bản</b></p>

<p align="justify">Một trong những nhiệm vụ tiêu chuẩn trong việc tạo ra ngôn ngữ tự nhiên là tóm tắt văn bản. Tóm tắt văn bản có thể bao gồm nhiều lĩnh vực và phạm vi khác nhau. Trên thực tế, một trong những ứng dụng hứa hẹn nhất của mô hình ngôn ngữ là khả năng tóm tắt các bài viết và khái niệm thành các bản tóm tắt nhanh chóng và dễ đọc. Hãy cùng thử một nhiệm vụ tóm tắt cơ bản bằng cách sử dụng các lời nhắc.</p>

<p align="justify">Giả sử bạn muốn tìm hiểu về thuốc kháng sinh, bạn có thể thử một lời nhắc như sau:</p>

<p><em>Prompt:</em></p>

<pre class="western" style="margin-left: 1.25cm">
<code class="western hljs cpp">Giải thích về thuốc kháng <span class="hljs-built_in">sinh</span></code>

<code class="western hljs makefile"><span class="hljs-title">A:</span></code></pre>

<p><em>Output:</em></p>

<pre class="western" style="text-align: justify; margin-left: 1.25cm; margin-bottom: 0.5cm">
<code class="western hljs perl">Thuốc kháng sinh là <span class="hljs-keyword">m</span>ột loại thuốc được <span class="hljs-keyword">s</span>ử dụng để điều <span class="hljs-keyword">tr</span>ị nhiễ<span class="hljs-keyword">m</span> <span class="hljs-keyword">tr</span>ùng <span class="hljs-keyword">do</span> vi khuẩn. Chúng hoạt động bằng cách tiêu diệt vi khuẩn hoặc ngăn chặn chúng sinh <span class="hljs-keyword">s</span>ôi, cho phép hệ thống miễn dịch của cơ thể chống lại nhiễ<span class="hljs-keyword">m</span> <span class="hljs-keyword">tr</span>ùng. Kháng sinh thường được dùng đường uống dưới dạng viên nén, viên nang hoặc dung dịch lỏng, hoặc đôi khi được tiê<span class="hljs-keyword">m</span> tĩnh <span class="hljs-keyword">m</span>ạch. Chúng không hiệu quả đối với nhiễ<span class="hljs-keyword">m</span> <span class="hljs-keyword">tr</span>ùng <span class="hljs-keyword">do</span> vi-rút, và việc <span class="hljs-keyword">s</span>ử dụng không đúng cách có thể dẫn đến kháng kháng sinh.</code></pre>

<p align="justify"><span style="background: transparent">&quot;A:&quot; là một định dạng gợi ý rõ ràng mà bạn sử dụng trong phần trả lời câu hỏi. Bạn đã sử dụng nó ở đây để cho mô hình biết rằng có một câu trả lời dự kiến. Trong ví dụ này, không rõ điều này hữu ích như thế nào so với việc không sử dụng nó, nhưng chúng ta sẽ để dành điều đó cho các ví dụ sau. Giả sử rằng đây là quá nhiều thông tin và bạn muốn tóm tắt lại. Trên thực tế, bạn có thể hướng dẫn mô hình tóm tắt thành một câu như sau:</span></p>

<p><em>Prompt:</em></p>

<pre class="western" style="margin-left: 1.25cm">
<code class="western hljs perl">Thuốc kháng sinh là <span class="hljs-keyword">m</span>ột loại thuốc được <span class="hljs-keyword">s</span>ử dụng để điều <span class="hljs-keyword">tr</span>ị nhiễ<span class="hljs-keyword">m</span> <span class="hljs-keyword">tr</span>ùng <span class="hljs-keyword">do</span> vi khuẩn. Chúng hoạt động bằng cách tiêu diệt hoặc ngăn chặn vi khuẩn sinh <span class="hljs-keyword">s</span>ôi, cho phép hệ thống miễn dịch của cơ thể chống lại nhiễ<span class="hljs-keyword">m</span> <span class="hljs-keyword">tr</span>ùng. Thuốc kháng sinh thường được dùng đường uống dưới dạng viên nén, viên nang hoặc dung dịch lỏng, hoặc đôi khi được tiê<span class="hljs-keyword">m</span> tĩnh <span class="hljs-keyword">m</span>ạch. Chúng không hiệu quả đối với nhiễ<span class="hljs-keyword">m</span> <span class="hljs-keyword">tr</span>ùng <span class="hljs-keyword">do</span> vi-rút, và việc <span class="hljs-keyword">s</span>ử dụng không đúng cách có thể dẫn đến tình <span class="hljs-keyword">tr</span>ạng kháng kháng sinh.</code>

<code class="western hljs perl">Giải thích những điều <span class="hljs-keyword">tr</span>ên chỉ trong <span class="hljs-keyword">m</span>ột câu:</code></pre>

<p><em>Output:</em></p>

<pre class="western" style="text-align: justify; margin-left: 1.25cm; margin-bottom: 0.5cm">
<code class="western hljs perl">Thuốc kháng sinh là thuốc được <span class="hljs-keyword">s</span>ử dụng để điều <span class="hljs-keyword">tr</span>ị nhiễ<span class="hljs-keyword">m</span> <span class="hljs-keyword">tr</span>ùng <span class="hljs-keyword">do</span> vi khuẩn bằng cách tiêu diệt hoặc ngăn chặn vi khuẩn sinh <span class="hljs-keyword">s</span>ôi, nhưng chúng không hiệu quả đối với vi-rút và việc lạ<span class="hljs-keyword">m</span> dụng có thể dẫn đến tình <span class="hljs-keyword">tr</span>ạng kháng kháng sinh.</code></pre>

<p align="justify">Việc không quá chú trọng đến độ chính xác của kết quả đầu ra ở trên, điều mà chúng ta sẽ đề cập trong hướng dẫn sau, mô hình đã cố gắng tóm tắt đoạn văn trong một câu. Bạn có thể khéo léo với các hướng dẫn, nhưng chúng ta sẽ để dành điều đó cho chương sau. Hãy thoải mái dừng lại ở đây và thử nghiệm để xem bạn có nhận được kết quả tốt hơn không.</p>

<p align="justify"><b>Trích xuất thông tin</b></p>

<p align="justify">Mặc dù các mô hình ngôn ngữ được đào tạo để thực hiện việc tạo ngôn ngữ tự nhiên và các tác vụ liên quan, nhưng nó cũng rất có khả năng thực hiện phân loại và một loạt các tác vụ xử lý ngôn ngữ tự nhiên (NLP) khác.</p>

<p align="justify">Dưới đây là ví dụ về lời nhắc trích xuất thông tin từ một đoạn văn nhất định.</p>

<p><em>Prompt:</em></p>

<pre class="western" style="margin-left: 1.25cm">
<code class="western hljs perl">Lời tuyên bố ghi công và lời cả<span class="hljs-keyword">m</span> ơn tác giả trong các bài báo nghiên cứu cần nêu rõ ràng và cụ thể liệu các tác giả có <span class="hljs-keyword">s</span>ử dụng các công nghệ AI như ChatGPT trong quá <span class="hljs-keyword">tr</span>ình chuẩn bị bản thảo và phân tích hay không và ở <span class="hljs-keyword">m</span>ức độ nào. Chúng cũng nên chỉ ra những LLM nào đã được <span class="hljs-keyword">s</span>ử dụng. Điều nà<span class="hljs-keyword">y</span> <span class="hljs-keyword">s</span>ẽ cảnh báo các biên tập viên và người phản biện xem <span class="hljs-keyword">x</span>ét kỹ lưỡng hơn các bản thảo để phát hiện các thành kiến tiề<span class="hljs-keyword">m</span> ẩn, sai <span class="hljs-keyword">s</span>ót và ghi nguồn không đúng cách. Tương tự, các tạp chí khoa học nên minh bạch về việc <span class="hljs-keyword">s</span>ử dụng LLM, ví dụ như khi lựa chọn bản thảo đã nộp.</code>

<code class="western hljs perl">Hã<span class="hljs-keyword">y</span> đề cập đến <span class="hljs-keyword">s</span>ản phẩ<span class="hljs-keyword">m</span> dựa <span class="hljs-keyword">tr</span>ên <span class="hljs-keyword">m</span>ô hình ngôn ngữ lớn được đề cập trong đoạn văn <span class="hljs-keyword">tr</span>ên:</code></pre>

<p><em>Output:</em></p>

<pre class="western" style="margin-left: 1.25cm; margin-bottom: 0.5cm">
<code class="western hljs perl">Sản phẩ<span class="hljs-keyword">m</span> dựa <span class="hljs-keyword">tr</span>ên <span class="hljs-keyword">m</span>ô hình ngôn ngữ lớn được đề cập trong đoạn văn <span class="hljs-keyword">tr</span>ên là ChatGPT.</code></pre>

<p align="justify">Có nhiều cách để cải thiện kết quả ở trên, nhưng cách này đã rất hữu ích.</p>

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

<p align="justify">Đến thời điểm này, hẳn bạn đã thấy rõ rằng mình có thể yêu cầu mô hình thực hiện các tác vụ khác nhau chỉ bằng cách ra lệnh cho nó. Đó là một khả năng mạnh mẽ mà các nhà phát triển sản phẩm AI đang sử dụng để xây dựng các sản phẩm và trải nghiệm mạnh mẽ.</p>

<p align="justify">Nguồn đoạn văn: <a href="https://www.nature.com/articles/d41586-023-00288-7">ChatGPT: năm ưu tiên nghiên cứu</a></p>

<p align="justify"><b>Trả lời câu hỏi</b></p>

<p align="justify">Một trong những cách tốt nhất để mô hình phản hồi bằng các câu trả lời cụ thể là cải thiện định dạng của lời nhắc. Như đã đề cập trước đó, lời nhắc có thể kết hợp các chỉ dẫn, ngữ cảnh, chỉ số đầu vào và đầu ra để có được kết quả tốt hơn. Mặc dù các thành phần này không bắt buộc, nhưng nó lại là một phương pháp hay vì bạn càng đưa ra chỉ dẫn cụ thể thì kết quả càng tốt. Dưới đây là ví dụ về cách thức thực hiện sau một lời nhắc có cấu trúc hơn.</p>

<p><em>Prompt:</em></p>

<pre class="western" style="margin-left: 1.25cm">
<code class="western hljs perl">Trả lời câu hỏi dựa <span class="hljs-keyword">tr</span>ên ngữ cảnh bên dưới. Trả lời ngắn gọn và <span class="hljs-keyword">s</span>úc tích. Nếu không chắc chắn, hã<span class="hljs-keyword">y</span> <span class="hljs-keyword">tr</span>ả lời <span class="hljs-string">&quot;Không chắc chắn về câu trả lời&quot;</span>.</code>

<code class="western hljs perl">Bối cảnh: Teplizumab có nguồn gốc từ <span class="hljs-keyword">m</span>ột công ty dược phẩ<span class="hljs-keyword">m</span> ở New Jersey tên là Ortho Pharmaceutical. Tại đó, các nhà khoa học đã tạo ra phiên bản đầu tiên của kháng thể, được gọi là OKT3. Ban đầu có nguồn gốc từ chuột, phân tử nà<span class="hljs-keyword">y</span> có khả năng liên kết với bề <span class="hljs-keyword">m</span>ặt tế bào T và hạn chế khả năng tiêu diệt tế bào của chúng. Nă<span class="hljs-keyword">m</span> <span class="hljs-number">1986</span>, nó được phê duyệt để giúp ngăn ngừa đào thải nội tạng sau ghép thận, <span class="hljs-keyword">tr</span>ở thành kháng thể điều <span class="hljs-keyword">tr</span>ị đầu tiên được phép <span class="hljs-keyword">s</span>ử dụng <span class="hljs-keyword">tr</span>ên người.</code>

<code class="western hljs ">Câu hỏi: OKT3 ban đầu có nguồn gốc từ đâu?</code>
<code class="western hljs ">Trả lời:</code></pre>

<p><em>Output:</em></p>

<pre class="western" style="margin-left: 1.25cm; margin-bottom: 0.5cm">
<code class="western">Chuột.</code></pre>

<p align="justify">Bối cảnh lấy từ <a href="https://www.nature.com/articles/d41586-023-00400-x" target="_blank">Nature</a>.</p>

<p align="justify"><b>Phân loại văn bản</b></p>

<p align="justify">Cho đến nay, bạn đã sử dụng các hướng dẫn đơn giản để thực hiện một tác vụ. Là một kỹ sư về lời nhắc, bạn cần cải thiện khả năng cung cấp chỉ dẫn tốt hơn. Nhưng chưa hết! Bạn cũng sẽ thấy rằng đối với các trường hợp sử dụng khó hơn, chỉ cung cấp chỉ dẫn thôi là chưa đủ. Đây là lúc bạn cần suy nghĩ kỹ hơn về ngữ cảnh và các yếu tố khác nhau mà bạn có thể sử dụng trong một lời nhắc. Các yếu tố khác bạn có thể cung cấp là dữ liệu đầu vào hoặc ví dụ.</p>

<p align="justify">Hãy thử chứng minh điều này bằng cách cung cấp một ví dụ về phân loại văn bản.</p>

<p><em>Prompt:</em></p>

<pre class="western" style="margin-left: 1.25cm">
<code class="western hljs ">Phân loại văn bản thành trung tính, tiêu cực hoặc tích cực.</code>

<code class="western hljs ">Văn bản: Tôi nghĩ đồ ăn ổn.</code></pre>

<p><em>Output:</em></p>

<pre class="western" style="text-align: justify; margin-left: 1.25cm; margin-bottom: 0.5cm">
<code class="western">Trung tính</code></pre>

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

<p align="justify">Bạn đã đưa ra chỉ dẫn phân loại văn bản và mô hình trả lời là ’<code class="western"><span style="background: transparent">Neutral’</span></code>, điều này là đúng. Điều này không có gì sai, nhưng giả sử điều bạn thực sự cần là mô hình đưa ra nhãn theo đúng định dạng bạn muốn. Vậy, thay vì <code class="western"><span style="background: transparent">Neutral</span></code>, bạn muốn nó trả về giá trị <code class="western"><span style="background: transparent">n</span></code><code class="western"><span style="background: transparent">eutral</span></code>. Làm thế nào để đạt được điều này? Có nhiều cách khác nhau để thực hiện. Ở đây, bạn quan tâm đến tính cụ thể, vì vậy bạn càng cung cấp nhiều thông tin cho lời nhắc thì kết quả càng tốt. Bạn có thể thử cung cấp các ví dụ để xác định hành vi chính xác. Hãy thử lại:</p>

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

<pre class="western" style="margin-left: 1.25cm">
<code class="western hljs "><span style="background: transparent">Phân loại văn bản thành trung tính, tiêu cực hoặc tích cực.</span></code>

<code class="western hljs "><span style="background: transparent">Văn bản: Tôi nghĩ kỳ nghỉ ổn.</span></code>
<code class="western hljs "><span style="background: transparent">Cảm xúc: trung tính</span></code>

<code class="western hljs "><span style="background: transparent">Văn bản: Tôi nghĩ đồ ăn ổn.</span></code>
<code class="western hljs "><span style="background: transparent">Cảm xúc:</span></code></pre>

<p><em><span style="background: transparent">Output:</span></em></p>

<pre class="western" style="margin-left: 1.25cm; margin-bottom: 0.5cm">
<code class="western hljs "><span style="background: transparent">trung tính</span></code></pre>

<p align="justify"><span style="background: transparent">Hoàn hảo! Lần này, mô hình trả về giá trị <code class="western">n</code><code class="western">eutral</code>, chính là nhãn cụ thể mà bạn đang tìm kiếm. Có vẻ như ví dụ được cung cấp trong lời nhắc đã giúp mô hình đưa ra kết quả cụ thể.</span></p>

<p align="justify">Để nêu bật lý do tại sao đôi khi việc cụ thể lại quan trọng, hãy xem ví dụ bên dưới và tìm ra vấn đề:</p>

<p><em>Prompt:</em></p>

<pre class="western" style="margin-left: 1.25cm">
<code class="western hljs ">Phân loại văn bản thành trung tính, tiêu cực hoặc tích cực.</code>

<code class="western hljs ">Văn bản: Tôi nghĩ kỳ nghỉ này ổn.</code>
<code class="western hljs ">Cảm xúc:</code></pre>

<p><em>Output:</em></p>

<pre class="western" style="text-align: justify; margin-left: 1.25cm; margin-bottom: 0.5cm">
<code class="western">Trung tính</code></pre>

<p align="justify">Vấn đề ở đây là gì? Gợi ý là, nhãn <code class="western"><span style="background: transparent">n</span></code><code class="western"><span style="background: transparent">eutral</span></code> được tạo ra hoàn toàn bị mô hình bỏ qua. Thay vào đó, mô hình đưa ra kết quả <code class="western"><span style="background: transparent">N</span></code><code class="western"><span style="background: transparent">eutral</span></code> vì nó có phần thiên vị nhãn đó. Nhưng hãy giả sử rằng thứ bạn thực sự muốn là <code class="western"><span style="background: transparent">n</span></code><code class="western"><span style="background: transparent">eutral</span></code>. Bạn sẽ khắc phục điều này như thế nào? Có lẽ bạn có thể thử thêm mô tả vào nhãn hoặc thêm ví dụ vào lời nhắc? Nếu bạn không chắc chắn, chúng ta sẽ thảo luận một vài ý tưởng trong các phần tiếp theo.</p>

<p align="justify"><b>Hội thoại</b></p>

<p align="justify">Có lẽ một trong những điều thú vị nhất bạn có thể đạt được với kỹ thuật nhắc là chỉ dẫn cho hệ thống LLM về cách hoạt động, ý định và bản sắc của nó. Điều này đặc biệt hữu ích khi bạn đang xây dựng các hệ thống hội thoại như chatbot dịch vụ khách hàng.</p>

<p align="justify">Ví dụ: hãy tạo một hệ thống hội thoại có khả năng tạo ra các câu trả lời mang tính kỹ thuật và khoa học hơn cho các câu hỏi. Lưu ý cách bạn hướng dẫn hệ thống cách hoạt động thông qua hướng dẫn. Điều này đôi khi được gọi là <i>việc nhắc vai trò</i>.</p>

<p><em>Prompt:</em></p>

<pre class="western" style="margin-left: 1.25cm">
<code class="western hljs perl">Sau đâ<span class="hljs-keyword">y</span> là cuộc <span class="hljs-keyword">tr</span>ò chuyện với <span class="hljs-keyword">m</span>ột <span class="hljs-keyword">tr</span>ợ lý nghiên cứu AI. Giọng điệu của <span class="hljs-keyword">tr</span>ợ lý mang tính kỹ thuật và khoa học.</code>

<code class="western hljs bash">Con người: X<span class="hljs-keyword">in</span> chào, bạn là ai?</code>
<code class="western hljs http"><span class="hljs-attribute">AI</span>: <span class="hljs-string">Xin chào! Tôi là trợ lý nghiên cứu AI. Hôm nay tôi có thể giúp gì cho bạn?</span></code>
<code class="western hljs ">Con người: Bạn có thể cho tôi biết về sự hình thành của hố đen không?</code>
<code class="western hljs makefile"><span class="hljs-title">AI:</span></code></pre>

<p><em>Output:</em></p>

<pre class="western" style="text-align: justify; margin-left: 1.25cm; margin-bottom: 0.5cm">
<code class="western">Chắc chắn rồi! Hố đen là những vùng không thời gian có lực hấp dẫn mạnh đến mức không gì, kể cả ánh sáng, có thể thoát ra khỏi nó. Chúng được tạo ra khi một ngôi sao cực lớn chết đi và lõi của nó sụp đổ vào chính nó, tạo thành một điểm kỳ dị có mật độ vô hạn. Lực hấp dẫn cực mạnh của điểm kỳ dị kéo tất cả vật chất và bức xạ xung quanh nó, tạo thành hố đen.</code></pre>

<p align="justify">Trợ lý nghiên cứu AI của chúng ta nghe có vẻ hơi chuyên môn quá, phải không? OK, hãy thay đổi hành vi này và hướng dẫn hệ thống đưa ra những câu trả lời dễ hiểu hơn.</p>

<p><em>Prompt:</em></p>

<pre class="western" style="margin-left: 1.25cm">
<code class="western hljs perl">Sau đâ<span class="hljs-keyword">y</span> là cuộc <span class="hljs-keyword">tr</span>ò chuyện với <span class="hljs-keyword">m</span>ột <span class="hljs-keyword">tr</span>ợ lý nghiên cứu AI. Câu <span class="hljs-keyword">tr</span>ả lời của <span class="hljs-keyword">tr</span>ợ lý phải dễ hiểu ngay cả với học sinh tiểu học.</code>

<code class="western hljs bash">Con người: X<span class="hljs-keyword">in</span> chào, bạn là ai?</code>
<code class="western hljs http"><span class="hljs-attribute">AI</span>: <span class="hljs-string">Xin chào! Tôi là trợ lý nghiên cứu AI. Hôm nay tôi có thể giúp gì cho bạn?</span></code>
<code class="western hljs ">Con người: Bạn có thể cho tôi biết về sự hình thành của hố đen không?</code><code class="western hljs "> </code>
<code class="western hljs makefile"><span class="hljs-title">AI:</span></code></pre>

<p><em>Output:</em></p>

<pre class="western" style="margin-left: 1.25cm; margin-bottom: 0.5cm">
<code class="western hljs ">Chắc chắn rồi! Hố đen được tạo ra khi một ngôi sao cực lớn cạn kiệt nhiên liệu và sụp đổ vào bên trong. Lực hấp dẫn của ngôi sao mạnh đến mức không gì, kể cả ánh sáng, có thể thoát khỏi lực hút của nó. Điều này tạo ra một điểm trong không-thời gian với lực hấp dẫn cực mạnh được gọi là hố đen.</code><code class="western hljs "> </code></pre>

<p align="justify">Bạn đã có một số tiến bộ. Bạn có thể tiếp tục cải thiện nó. Nếu bạn thêm nhiều ví dụ hơn, bạn có thể sẽ có được kết quả tốt hơn nữa.</p>

<p align="justify"><b>Tạo mã</b></p>

<p align="justify">Một ứng dụng mà LLM khá hiệu quả là tạo mã. Copilot là một ví dụ điển hình. Có rất nhiều tác vụ tạo mã mà bạn có thể thực hiện với các lời nhắc thông minh. Hãy cùng xem một vài ví dụ dưới đây.</p>

<p align="justify">Trước tiên, hãy thử một chương trình đơn giản chào đón người dùng.</p>

<p><em>Prompt:</em></p>

<pre class="western" style="margin-left: 1.25cm">
<code class="western hljs ">/*</code>
<code class="western hljs bash">Hỏi tên người dùng và nói <span class="hljs-string">&quot;Xin chào&quot;</span></code>
<code class="western hljs ">*/</code></pre>

<p><em>Output:</em></p>

<pre class="western" style="margin-left: 1.25cm">
<code class="western hljs bash"><span class="hljs-built_in">let</span> name = prompt(<span class="hljs-string">&quot;Tên bạn là gì?&quot;</span>);</code>
<code class="western hljs bash">console.log(`X<span class="hljs-keyword">in</span> chào, <span class="hljs-variable">${name}</span>!`);</code></pre>

<p align="justify">Lưu ý rằng bạn thậm chí không cần chỉ định ngôn ngữ sử dụng.</p>

<p align="justify">Hãy đổi hướng một chút. Ví dụ dưới đây cho thấy LLM có thể mạnh mẽ như thế nào nếu bạn đầu tư thêm một chút công sức vào việc thiết kế các lời nhắc.</p>

<p><em>Prompt:</em></p>

<pre class="western" style="margin-left: 1.25cm">
<code class="western hljs bash"><span class="hljs-string">&quot;&quot;</span><span class="hljs-string">&quot;</span></code>
<code class="western hljs apache"><span class="hljs-keyword">B</span>ảng departments, các cột =<span class="hljs-sqbracket"> &#91;DepartmentId, DepartmentName&#93;</span></code>
<code class="western hljs apache"><span class="hljs-keyword">B</span>ảng students, các cột =<span class="hljs-sqbracket"> &#91;DepartmentId, StudentId, StudentName&#93;</span></code>
<code class="western hljs cpp">Tạo một truy vấn MySQL cho tất cả <span class="hljs-built_in">sinh</span> viên trong Khoa Khoa học máy tính</code>
<code class="western hljs bash"><span class="hljs-string">&quot;&quot;</span><span class="hljs-string">&quot;</span></code></pre>

<p><em>Output:</em></p>

<pre class="western" style="margin-left: 1.25cm">
<code class="western hljs sql"><span class="hljs-operator"><span class="hljs-keyword">SELECT</span> StudentId, StudentName </span></code>
<code class="western hljs ">FROM students </code>
<code class="western hljs sql">WHERE DepartmentId IN (<span class="hljs-operator"><span class="hljs-keyword">SELECT</span> DepartmentId <span class="hljs-keyword">FROM</span> departments <span class="hljs-keyword">WHERE</span> DepartmentName = <span class="hljs-string">&#039;Computer Science&#039;</span>);</span></code></pre>

<p align="justify">Điều này rất ấn tượng. Trong trường hợp này, bạn đã cung cấp dữ liệu về lược đồ cơ sở dữ liệu và yêu cầu nó tạo ra một truy vấn MySQL hợp lệ.</p>

<p align="justify"><b>Suy luận</b></p>

<p align="justify">Có lẽ một trong những nhiệm vụ khó khăn nhất đối với một LLM hiện nay là nhiệm vụ đòi hỏi một số dạng suy luận. Suy luận là một trong những lĩnh vực thú vị nhất do các loại ứng dụng phức tạp có thể xuất hiện từ LLM.</p>

<p align="justify">Đã có một số cải tiến trong các bài tập liên quan đến năng lực toán học. Tuy nhiên, điều quan trọng cần lưu ý là các LLM hiện tại gặp khó khăn trong việc thực hiện các bài tập suy luận, do đó đòi hỏi các kỹ thuật viết lời nhắc. Chúng tôi sẽ đề cập đến các kỹ thuật nâng cao cấp này trong hướng dẫn tiếp theo. Trước mắt, chúng tôi sẽ trình bày một vài ví dụ cơ bản để thể hiện năng lực số học.</p>

<p><em>Prompt:</em></p>

<pre class="western" style="margin-left: 1.25cm; margin-bottom: 0.5cm">
<code class="western">9.000 * 9.000 bằng bao nhiêu?</code></pre>

<p><em>Output:</em></p>

<pre class="western" style="margin-left: 1.25cm; margin-bottom: 0.5cm">
<code class="western">81,000,000</code></pre>

<p>Hãy thử thứ gì đó khó hơn.</p>

<p><em>Prompt:</em></p>

<pre class="western" style="margin-left: 1.25cm">
<code class="western hljs ">Tổng các số lẻ trong nhóm này bằng một số chẵn: 15, 32, 5, 13, 82, 7, 1.</code><code class="western hljs "> </code>
<code class="western hljs http"><span class="hljs-attribute">A</span>: </code></pre>

<p><em>Output</em></p>

<pre class="western" style="margin-left: 1.25cm; margin-bottom: 0.5cm">
<code class="western">Không, tổng các số lẻ trong nhóm này bằng một số lẻ: 119.</code></pre>

<p>Không đúng! Hãy thử cải thiện bài toán này bằng cách cải thiện lời nhắc.</p>

<p><em>Prompt:</em></p>

<pre class="western" style="margin-left: 1.25cm">
<code class="western hljs ">Tổng các số lẻ trong nhóm này bằng một số chẵn: 15, 32, 5, 13, 82, 7, 1.</code><code class="western hljs "> </code>
<code class="western hljs ">Giải bài toán bằng cách chia nhỏ bài toán thành các bước. Đầu tiên, hãy xác định các số lẻ, cộng chúng lại và cho biết kết quả là số lẻ hay số chẵn.</code></pre>

<p><em>Output:</em></p>

<pre class="western" style="margin-left: 1.25cm">
<code class="western hljs ">Các số lẻ: 15, 5, 13, 7, 1</code>
<code class="western hljs http"><span class="hljs-attribute">Tổng</span>: <span class="hljs-string">41</span></code>
<code class="western hljs ">41 là một số lẻ.</code></pre>

<p><em><span style="font-style: normal"><span style="background: transparent">Tốt hơn nhiều rồi, phải không? Nhân tiện, chúng tôi đã thử nhiệm vụ này vài lần và đôi khi mô hình bị lỗi. Nếu bạn cung cấp hướng dẫn tốt hơn kết hợp với ví dụ, kết quả có thể sẽ chính xác hơn.</span></span></em></p>

<p align="justify">Trong phần tiếp theo, chúng tôi sẽ đề cập đến các khái niệm và kỹ thuật lập trình nhắc nhở nâng cao hơn nữa để cải thiện hiệu suất cho tất cả các nhiệm vụ này và cả những nhiệm vụ khó hơn.</p>

<p align="justify"><b>Sổ tay</b></p>

<p align="justify"><em><span style="font-style: normal"><span style="font-weight: normal"><span style="background: transparent">Nếu bạn muốn thực hành với các lời nhắc trên bằng Python, chúng tôi đã chuẩn bị một sổ tay để kiểm tra một số lời nhắc bằng cách sử dụng các mô hình OpenAI.</span></span></span></em></p>

<p align="justify"><span style="background: transparent"><em><span style="font-style: normal"><span style="font-weight: normal"><a href="https://giaoducmo.avnuc.vn/ai/huong-dan-ky-thuat-loi-nhac-gioi-thieu-1570.html">Về phần ‘Giới thiệu’</a> ………. <a href="https://giaoducmo.avnuc.vn/ai/huong-dan-ky-thuat-loi-nhac-gioi-thieu-meo-chung-cho-viec-thiet-ke-loi-nhac-1575.html">Phần trước</a> ………. Phần tiếp theo</span></span></em></span></p>

<p align="justify"><span style="background: rgb(255, 255, 0);">The previous section introduced a basic example of how to prompt LLMs.</span></p>

<p align="justify"><span style="background: rgb(255, 255, 0);">This section will provide more examples of how to use prompts to achieve different tasks and introduce key concepts along the way. Often, the best way to learn concepts is by going through examples. The few examples below illustrate how you can use well-crafted prompts to perform different types of tasks.</span></p>

<p align="justify"><span style="background: rgb(255, 255, 0);">Topics:</span></p>

<ul>
	<li>
	<p align="justify"><span style="background: rgb(255, 255, 0);"><a href="https://www.promptingguide.ai/introduction/examples#text-summarization">Text Summarization</a> </span></p>
	</li>
	<li>
	<p align="justify"><span style="background: rgb(255, 255, 0);"><a href="https://www.promptingguide.ai/introduction/examples#information-extraction">Information Extraction</a> </span></p>
	</li>
	<li>
	<p align="justify"><span style="background: rgb(255, 255, 0);"><a href="https://www.promptingguide.ai/introduction/examples#question-answering">Question Answering</a> </span></p>
	</li>
	<li>
	<p align="justify"><span style="background: rgb(255, 255, 0);"><a href="https://www.promptingguide.ai/introduction/examples#text-classification">Text Classification</a> </span></p>
	</li>
	<li>
	<p align="justify"><span style="background: rgb(255, 255, 0);"><a href="https://www.promptingguide.ai/introduction/examples#conversation">Conversation</a> </span></p>
	</li>
	<li>
	<p align="justify"><span style="background: rgb(255, 255, 0);"><a href="https://www.promptingguide.ai/introduction/examples#code-generation">Code Generation</a> </span></p>
	</li>
	<li>
	<p align="justify"><span style="background: rgb(255, 255, 0);"><a href="https://www.promptingguide.ai/introduction/examples#reasoning">Reasoning</a> </span></p>
	</li>
</ul>

<p align="justify"><span style="background: rgb(255, 255, 0);">Video: <a href="https://www.youtube.com/watch?v=TBhRC4Dath4">Basic Prompt Examples for LLMs</a></span></p>

<p align="justify"><a name="text-summarization"></a><b><span style="background: rgb(255, 255, 0);">Text Summarization</span></b></p>

<p align="justify"><span style="background: rgb(255, 255, 0);">One of the standard tasks in natural language generation is text summarization. Text summarization can include many different flavors and domains. In fact, one of the most promising applications of language models is the ability to summarize articles and concepts into quick and easy-to-read summaries. Let&#039;s try a basic summarization task using prompts.</span></p>

<p align="justify"><span style="background: rgb(255, 255, 0);">Let&#039;s say you are interested to learn about antibiotics, you could try a prompt like this:</span></p>

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

<pre class="western" style="margin-left: 1.25cm">
<code class="western"><span style="background: rgb(255, 255, 0);">Explain antibiotics</span></code>

<code class="western"><span style="background: rgb(255, 255, 0);">A:</span></code></pre>

<p><em><span style="background: rgb(255, 255, 0);">Output:</span></em></p>

<pre class="western" style="margin-left: 1.25cm; margin-bottom: 0.5cm">
<code class="western"><span style="background: rgb(255, 255, 0);">Antibiotics are a type of medication used to treat bacterial infections. They work by either killing the bacteria or preventing them from reproducing, allowing the body’s immune system to fight off the infection. Antibiotics are usually taken orally in the form of pills, capsules, or liquid solutions, or sometimes administered intravenously. They are not effective against viral infections, and using them inappropriately can lead to antibiotic resistance.</span></code></pre>

<p align="justify"><span style="background: rgb(255, 255, 0);">The &quot;A:&quot; is an explicit prompt format that you use in question answering. You used it here to tell the model that there is an answer expected further. In this example, it&#039;s not clear how this is useful vs not using it but we will leave it that for later examples. Let&#039;s just assume that this is too much information and you want to summarize it further. In fact, you can instruct the model to summarize into one sentence like so:</span></p>

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

<pre class="western" style="margin-left: 1.25cm">
<code class="western"><span style="background: rgb(255, 255, 0);">Antibiotics are a type of medication used to treat bacterial infections. They work by either killing the bacteria or preventing them from reproducing, allowing the body’s immune system to fight off the infection. Antibiotics are usually taken orally in the form of pills, capsules, or liquid solutions, or sometimes administered intravenously. They are not effective against viral infections, and using them inappropriately can lead to antibiotic resistance.</span></code>

<code class="western"><span style="background: rgb(255, 255, 0);">Explain the above in one sentence:</span></code></pre>

<p><em><span style="background: rgb(255, 255, 0);">Output:</span></em></p>

<pre class="western" style="margin-left: 1.25cm; margin-bottom: 0.5cm">
<code class="western"><span style="background: rgb(255, 255, 0);">Antibiotics are medications used to treat bacterial infections by either killing the bacteria or stopping them from reproducing, but they are not effective against viruses and overuse can lead to antibiotic resistance.</span></code></pre>

<p align="justify"><span style="background: rgb(255, 255, 0);">Without paying too much attention to the accuracy of the output above, which is something we will touch on in a later guide, the model tried to summarize the paragraph in one sentence. You can get clever with the instructions but we will leave that for a later chapter. Feel free to pause here and experiment to see if you get better results.</span></p>

<p align="justify"><a name="information-extraction"></a><b><span style="background: rgb(255, 255, 0);">Information Extraction</span></b></p>

<p align="justify"><span style="background: rgb(255, 255, 0);">While language models are trained to perform natural language generation and related tasks, it&#039;s also very capable of performing classification and a range of other natural language processing (NLP) tasks.</span></p>

<p align="justify"><span style="background: rgb(255, 255, 0);">Here is an example of a prompt that extracts information from a given paragraph.</span></p>

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

<pre class="western" style="margin-left: 1.25cm">
<code class="western"><span style="background: rgb(255, 255, 0);">Author-contribution statements and acknowledgements in research papers should state clearly and specifically whether, and to what extent, the authors used AI technologies such as ChatGPT in the preparation of their manuscript and analysis. They should also indicate which LLMs were used. This will alert editors and reviewers to scrutinize manuscripts more carefully for potential biases, inaccuracies and improper source crediting. Likewise, scientific journals should be transparent about their use of LLMs, for example when selecting submitted manuscripts.</span></code>

<code class="western"><span style="background: rgb(255, 255, 0);">Mention the large language model based product mentioned in the paragraph above:</span></code></pre>

<p><em><span style="background: rgb(255, 255, 0);">Output:</span></em></p>

<pre class="western" style="margin-left: 1.25cm; margin-bottom: 0.5cm">
<code class="western"><span style="background: rgb(255, 255, 0);">The large language model based product mentioned in the paragraph above is ChatGPT.</span></code></pre>

<p align="justify"><span style="background: rgb(255, 255, 0);">There are many ways you can improve the results above, but this is already very useful.</span></p>

<p align="justify"><span style="background: rgb(255, 255, 0);">By now it should be obvious that you can ask the model to perform different tasks by simply instructing it what to do. That&#039;s a powerful capability that AI product developers are already using to build powerful products and experiences.</span></p>

<p align="justify"><span style="background: rgb(255, 255, 0);">Paragraph source: <a href="https://www.nature.com/articles/d41586-023-00288-7" target="_blank">ChatGPT: five priorities for research</a></span></p>

<p align="justify"><a name="question-answering"></a><b><span style="background: rgb(255, 255, 0);">Question Answering</span></b></p>

<p align="justify"><span style="background: rgb(255, 255, 0);">One of the best ways to get the model to respond with specific answers is to improve the format of the prompt. As covered before, a prompt could combine instructions, context, input, and output indicators to get improved results. While these components are not required, it becomes a good practice as the more specific you are with instruction, the better results you will get. Below is an example of how this would look following a more structured prompt.</span></p>

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

<pre class="western" style="margin-left: 1.25cm">
<code class="western"><span style="background: rgb(255, 255, 0);">Answer the question based on the context below. Keep the answer short and concise. Respond &quot;Unsure about answer&quot; if not sure about the answer.</span></code>

<code class="western"><span style="background: rgb(255, 255, 0);">Context: Teplizumab traces its roots to a New Jersey drug company called Ortho Pharmaceutical. There, scientists generated an early version of the antibody, dubbed OKT3. Originally sourced from mice, the molecule was able to bind to the surface of T cells and limit their cell-killing potential. In 1986, it was approved to help prevent organ rejection after kidney transplants, making it the first therapeutic antibody allowed for human use.</span></code>

<code class="western"><span style="background: rgb(255, 255, 0);">Question: What was OKT3 originally sourced from?</span></code>

<code class="western"><span style="background: rgb(255, 255, 0);">Answer:</span></code></pre>

<p><em><span style="background: rgb(255, 255, 0);">Output:</span></em></p>

<pre class="western" style="margin-left: 1.25cm; margin-bottom: 0.5cm">
<code class="western"><span style="background: rgb(255, 255, 0);">Mice.</span></code></pre>

<p align="justify"><span style="background: rgb(255, 255, 0);">Context obtained from <a href="https://www.nature.com/articles/d41586-023-00400-x" target="_blank">Nature</a>.</span></p>

<p align="justify"><a name="text-classification"></a><b><span style="background: rgb(255, 255, 0);">Text Classification</span></b></p>

<p align="justify"><span style="background: rgb(255, 255, 0);">So far, you have used simple instructions to perform a task. As a prompt engineer, you need to get better at providing better instructions. But that&#039;s not all! You will also find that for harder use cases, just providing instructions won&#039;t be enough. This is where you need to think more about the context and the different elements you can use in a prompt. Other elements you can provide are </span><code class="western"><span style="background: rgb(255, 255, 0);">input data</span></code><span style="background: rgb(255, 255, 0);"> or </span><code class="western"><span style="background: rgb(255, 255, 0);">examples</span></code><span style="background: rgb(255, 255, 0);">.</span></p>

<p align="justify"><span style="background: rgb(255, 255, 0);">Let&#039;s try to demonstrate this by providing an example of text classification</span></p>

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

<pre class="western" style="margin-left: 1.25cm">
<code class="western"><span style="background: rgb(255, 255, 0);">Classify the text into neutral, negative or positive. </span></code>

<code class="western"><span style="background: rgb(255, 255, 0);">Text: I think the food was okay. </span></code>
<code class="western"><span style="background: rgb(255, 255, 0);">Sentiment:</span></code></pre>

<p><em><span style="background: rgb(255, 255, 0);">Output:</span></em></p>

<pre class="western" style="margin-left: 1.25cm; margin-bottom: 0.5cm">
<code class="western"><span style="background: rgb(255, 255, 0);">Neutral</span></code></pre>

<p align="justify"><span style="background: rgb(255, 255, 0);">You gave the instruction to classify the text and the model responded with </span><code class="western"><span style="background: rgb(255, 255, 0);">&#039;Neutral&#039;</span></code><span style="background: rgb(255, 255, 0);">, which is correct. Nothing is wrong with this but let&#039;s say that what you really need is for the model to give the label in the exact format you want. So instead of </span><code class="western"><span style="background: rgb(255, 255, 0);">Neutral</span></code><span style="background: rgb(255, 255, 0);">, you want it to return </span><code class="western"><span style="background: rgb(255, 255, 0);">neutral</span></code><span style="background: rgb(255, 255, 0);">. How do you achieve this? There are different ways to do this. You care about specificity here, so the more information you can provide the prompt, the better results. You can try providing examples to specify the correct behavior. Let&#039;s try again:</span></p>

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

<pre class="western" style="margin-left: 1.25cm">
<code class="western"><span style="background: rgb(255, 255, 0);">Classify the text into neutral, negative or positive. </span></code>

<code class="western"><span style="background: rgb(255, 255, 0);">Text: I think the vacation is okay.</span></code>
<code class="western"><span style="background: rgb(255, 255, 0);">Sentiment: neutral </span></code>

<code class="western"><span style="background: rgb(255, 255, 0);">Text: I think the food was okay. </span></code>
<code class="western"><span style="background: rgb(255, 255, 0);">Sentiment:</span></code></pre>

<p><em><span style="background: rgb(255, 255, 0);">Output:</span></em></p>

<pre class="western" style="margin-left: 1.25cm; margin-bottom: 0.5cm">
<code class="western"><span style="background: rgb(255, 255, 0);">neutral</span></code></pre>

<p align="justify"><span style="background: rgb(255, 255, 0);">Perfect! This time the model returned </span><code class="western"><span style="background: rgb(255, 255, 0);">neutral</span></code><span style="background: rgb(255, 255, 0);"> which is the specific label you were looking for. It seems that the example provided in the prompt helped the model to be specific in its output.</span></p>

<p align="justify"><span style="background: rgb(255, 255, 0);">To highlight why sometimes being specific is important, check out the example below and spot the problem:</span></p>

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

<pre class="western" style="margin-left: 1.25cm">
<code class="western"><span style="background: rgb(255, 255, 0);">Classify the text into nutral, negative or positive. </span></code>

<code class="western"><span style="background: rgb(255, 255, 0);">Text: I think the vacation is okay.</span></code>
<code class="western"><span style="background: rgb(255, 255, 0);">Sentiment:</span></code></pre>

<p><em><span style="background: rgb(255, 255, 0);">Output:</span></em></p>

<pre class="western" style="margin-left: 1.25cm; margin-bottom: 0.5cm">
<code class="western"><span style="background: rgb(255, 255, 0);">Neutral</span></code></pre>

<p align="justify"><span style="background: rgb(255, 255, 0);">What is the problem here? As a hint, the made-up </span><code class="western"><span style="background: rgb(255, 255, 0);">nutral</span></code><span style="background: rgb(255, 255, 0);"> label is completely ignored by the model. Instead, the model outputs </span><code class="western"><span style="background: rgb(255, 255, 0);">Neutral</span></code><span style="background: rgb(255, 255, 0);"> as it has some bias towards that label. But let&#039;s assume that what you really want is </span><code class="western"><span style="background: rgb(255, 255, 0);">nutral</span></code><span style="background: rgb(255, 255, 0);">. How would you fix this? Maybe you can try adding descriptions to the labels or add more examples to the prompt? If you are not sure, we will discuss a few ideas in the upcoming sections.</span></p>

<p align="justify"><a name="conversation"></a><b><span style="background: rgb(255, 255, 0);">Conversation</span></b></p>

<p align="justify"><span style="background: rgb(255, 255, 0);">Perhaps one of the more interesting things you can achieve with prompt engineering is instructing the LLM system on how to behave, its intent, and its identity. This is particularly useful when you are building conversational systems like customer service chatbots.</span></p>

<p align="justify"><span style="background: rgb(255, 255, 0);">For instance, let&#039;s create a conversational system that&#039;s able to generate more technical and scientific responses to questions. Note how you are explicitly telling it how to behave through the instruction. This is sometimes referred to as </span><em><span style="background: rgb(255, 255, 0);">role prompting</span></em><span style="background: rgb(255, 255, 0);">.</span></p>

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

<pre class="western" style="margin-left: 1.25cm">
<code class="western"><span style="background: rgb(255, 255, 0);">The following is a conversation with an AI research assistant. The assistant tone is technical and scientific.</span></code>

<code class="western"><span style="background: rgb(255, 255, 0);">Human: Hello, who are you?</span></code>
<code class="western"><span style="background: rgb(255, 255, 0);">AI: Greeting! I am an AI research assistant. How can I help you today?</span></code>
<code class="western"><span style="background: rgb(255, 255, 0);">Human: Can you tell me about the creation of blackholes?</span></code>
<code class="western"><span style="background: rgb(255, 255, 0);">AI:</span></code></pre>

<p><em><span style="background: rgb(255, 255, 0);">Output:</span></em></p>

<pre class="western" style="margin-left: 1.25cm; margin-bottom: 0.5cm">
<code class="western"><span style="background: rgb(255, 255, 0);">Sure! Black holes are regions of spacetime where the gravitational force is so strong that nothing, not even light, can escape from it. They are created when a very massive star dies and its core collapses in on itself, forming a singularity of infinite density. The intense gravity of the singularity pulls in all the matter and radiation around it, creating the black hole.</span></code></pre>

<p align="justify"><span style="background: rgb(255, 255, 0);">Our AI research assistant sounds a bit too technical, right? Okay, let&#039;s change this behavior and instruct the system to give more accessible answers.</span></p>

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

<pre class="western" style="margin-left: 1.25cm">
<code class="western"><span style="background: rgb(255, 255, 0);">The following is a conversation with an AI research assistant. The assistant answers should be easy to understand even by primary school students.</span></code>

<code class="western"><span style="background: rgb(255, 255, 0);">Human: Hello, who are you?</span></code>
<code class="western"><span style="background: rgb(255, 255, 0);">AI: Greeting! I am an AI research assistant. How can I help you today?</span></code>
<code class="western"><span style="background: rgb(255, 255, 0);">Human: Can you tell me about the creation of black holes?</span></code>
<code class="western"><span style="background: rgb(255, 255, 0);">AI: </span></code></pre>

<p><em><span style="background: rgb(255, 255, 0);">Output:</span></em></p>

<pre class="western" style="margin-left: 1.25cm; margin-bottom: 0.5cm">
<code class="western"><span style="background: rgb(255, 255, 0);">Sure! Black holes are created when a very massive star runs out of fuel and collapses in on itself. The gravity of the star is so strong that nothing, not even light, can escape its pull. This creates a point in space-time with an intense gravitational force called a black hole.</span></code></pre>

<p align="justify"><span style="background: rgb(255, 255, 0);">You made some progress. You can continue improving it. If you add more examples, you might get even better results.</span></p>

<p align="justify"><a name="code-generation"></a><b><span style="background: rgb(255, 255, 0);">Code Generation</span></b></p>

<p align="justify"><span style="background: rgb(255, 255, 0);">One application where LLMs are quite effective is code generation. Copilot is a great example of this. There are a vast number of code-generation tasks you can perform with clever prompts. Let&#039;s look at a few examples below.</span></p>

<p align="justify"><span style="background: rgb(255, 255, 0);">First, let&#039;s try a simple program that greets the user.</span></p>

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

<pre class="western" style="margin-left: 1.25cm">
<code class="western"><span style="background: rgb(255, 255, 0);">/*</span></code>
<code class="western"><span style="background: rgb(255, 255, 0);">Ask the user for their name and say &quot;Hello&quot;</span></code>
<code class="western"><span style="background: rgb(255, 255, 0);">*/</span></code></pre>

<p><em><span style="background: rgb(255, 255, 0);">Output:</span></em></p>

<pre class="western" style="margin-left: 1.25cm">
<code class="western"><span style="background: rgb(255, 255, 0);">let name = prompt(&quot;What is your name?&quot;);</span></code>
<code class="western"><span style="background: rgb(255, 255, 0);">console.log(`Hello, ${name}!`);</span></code></pre>

<p align="justify"><span style="background: rgb(255, 255, 0);">Notice that you didn&#039;t even need to specify the language to use.</span></p>

<p align="justify"><span style="background: rgb(255, 255, 0);">Let&#039;s switch levels a bit. The example below shows how powerful LLMs can be with a little more effort in designing the prompts.</span></p>

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

<pre class="western" style="margin-left: 1.25cm">
<code class="western"><span style="background: rgb(255, 255, 0);">&quot;&quot;&quot;</span></code>
<code class="western"><span style="background: rgb(255, 255, 0);">Table departments, columns = &#91;DepartmentId, DepartmentName&#93;</span></code>
<code class="western"><span style="background: rgb(255, 255, 0);">Table students, columns = &#91;DepartmentId, StudentId, StudentName&#93;</span></code>
<code class="western"><span style="background: rgb(255, 255, 0);">Create a MySQL query for all students in the Computer Science Department</span></code>
<code class="western"><span style="background: rgb(255, 255, 0);">&quot;&quot;&quot;</span></code></pre>

<p><em><span style="background: rgb(255, 255, 0);">Output:</span></em></p>

<pre class="western" style="margin-left: 1.25cm">
<code class="western"><span style="background: rgb(255, 255, 0);">SELECT StudentId, StudentName </span></code>
<code class="western"><span style="background: rgb(255, 255, 0);">FROM students </span></code>
<code class="western"><span style="background: rgb(255, 255, 0);">WHERE DepartmentId IN (SELECT DepartmentId FROM departments WHERE DepartmentName = &#039;Computer Science&#039;);</span></code></pre>

<p align="justify"><span style="background: rgb(255, 255, 0);">This is very impressive. In this case, you provided data about the database schema and asked it to generate a valid MySQL query.</span></p>

<p align="justify"><a name="reasoning"></a><b><span style="background: rgb(255, 255, 0);">Reasoning</span></b></p>

<p align="justify"><span style="background: rgb(255, 255, 0);">Perhaps one of the most difficult tasks for an LLM today is one that requires some form of reasoning. Reasoning is one of most interesting areas due to the types of complex applications that can emerge from LLMs.</span></p>

<p align="justify"><span style="background: rgb(255, 255, 0);">There have been some improvements in tasks involving mathematical capabilities. That said, it&#039;s important to note that current LLMs struggle to perform reasoning tasks so this requires even more advanced prompt engineering techniques. We will cover these advanced techniques in the next guide. For now, we will cover a few basic examples to show arithmetic capabilities.</span></p>

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

<pre class="western" style="margin-left: 1.25cm; margin-bottom: 0.5cm">
<code class="western"><span style="background: rgb(255, 255, 0);">What is 9,000 * 9,000?</span></code></pre>

<p><em><span style="background: rgb(255, 255, 0);">Output:</span></em></p>

<pre class="western" style="margin-left: 1.25cm; margin-bottom: 0.5cm">
<code class="western"><span style="background: rgb(255, 255, 0);">81,000,000</span></code></pre>

<p><span style="background: rgb(255, 255, 0);">Let&#039;s try something more difficult.</span></p>

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

<pre class="western" style="margin-left: 1.25cm">
<code class="western"><span style="background: rgb(255, 255, 0);">The odd numbers in this group add up to an even number: 15, 32, 5, 13, 82, 7, 1. </span></code>

<code class="western"><span style="background: rgb(255, 255, 0);">A: </span></code></pre>

<p><em><span style="background: rgb(255, 255, 0);">Output</span></em></p>

<pre class="western" style="margin-left: 1.25cm; margin-bottom: 0.5cm">
<code class="western"><span style="background: rgb(255, 255, 0);">No, the odd numbers in this group add up to an odd number: 119.</span></code></pre>

<p><span style="background: rgb(255, 255, 0);">That&#039;s incorrect! Let&#039;s try to improve this by improving the prompt.</span></p>

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

<pre class="western" style="margin-left: 1.25cm">
<code class="western"><span style="background: rgb(255, 255, 0);">The odd numbers in this group add up to an even number: 15, 32, 5, 13, 82, 7, 1. </span></code>

<code class="western"><span style="background: rgb(255, 255, 0);">Solve by breaking the problem into steps. First, identify the odd numbers, add them, and indicate whether the result is odd or even. </span></code></pre>

<p><em><span style="background: rgb(255, 255, 0);">Output:</span></em></p>

<pre class="western" style="margin-left: 1.25cm">
<code class="western"><span style="background: rgb(255, 255, 0);">Odd numbers: 15, 5, 13, 7, 1</span></code>
<code class="western"><span style="background: rgb(255, 255, 0);">Sum: 41 </span></code>
<code class="western"><span style="background: rgb(255, 255, 0);">41 is an odd number.</span></code></pre>

<p align="justify"><span style="background: rgb(255, 255, 0);">Much better, right? By the way, we tried this task a couple of times and the model sometimes fails. If you provide better instructions combined with examples, it might help get more accurate results.</span></p>

<p align="justify"><span style="background: rgb(255, 255, 0);">In the upcoming section, we will cover even more advanced prompt engineering concepts and techniques for improving performance on all these and more difficult tasks.</span></p>

<p align="justify"><a name="notebook"></a><b><span style="background: rgb(255, 255, 0);">Notebook</span></b></p>

<p align="justify"><span style="background: rgb(255, 255, 0);">If you want to practice with the prompts above using Python, we have prepared a notebook to test some of the prompts using the OpenAI models.</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-gioi-thieu-vi-du-ve-loi-nhac-7789.html" title="Hướng dẫn kỹ thuật lời nhắc. Giới thiệu. Ví dụ về lời nhắc">https://letrungnghia.mangvn.org/savefile/Education/huong-dan-ky-thuat-loi-nhac-gioi-thieu-vi-du-ve-loi-nhac-7789.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=z2qBd8IL" 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>