<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>AI &#8211; richliu&#039;s blog</title>
	<atom:link href="https://blog.richliu.com/category/computer/ai/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.richliu.com</link>
	<description>Linux, 工作, 生活, 家人</description>
	<lastBuildDate>Mon, 06 Apr 2026 10:44:39 +0000</lastBuildDate>
	<language>zh-TW</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.6.2</generator>
	<item>
		<title>千萬不要拿星穹鐵道機器人閉嘴的資料給 AI ，要不然&#8230;..</title>
		<link>https://blog.richliu.com/2026/04/06/6496/%e5%8d%83%e8%90%ac%e4%b8%8d%e8%a6%81%e6%8b%bf%e6%98%9f%e7%a9%b9%e9%90%b5%e9%81%93%e6%a9%9f%e5%99%a8%e4%ba%ba%e9%96%89%e5%98%b4%e7%9a%84%e8%b3%87%e6%96%99%e7%b5%a6-ai-%ef%bc%8c%e8%a6%81%e4%b8%8d/</link>
					<comments>https://blog.richliu.com/2026/04/06/6496/%e5%8d%83%e8%90%ac%e4%b8%8d%e8%a6%81%e6%8b%bf%e6%98%9f%e7%a9%b9%e9%90%b5%e9%81%93%e6%a9%9f%e5%99%a8%e4%ba%ba%e9%96%89%e5%98%b4%e7%9a%84%e8%b3%87%e6%96%99%e7%b5%a6-ai-%ef%bc%8c%e8%a6%81%e4%b8%8d/#respond</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Mon, 06 Apr 2026 10:26:58 +0000</pubDate>
				<category><![CDATA[AI]]></category>
		<category><![CDATA[生活相關]]></category>
		<category><![CDATA[健身]]></category>
		<category><![CDATA[對話]]></category>
		<category><![CDATA[程式語言]]></category>
		<category><![CDATA[自然語言]]></category>
		<guid isPermaLink="false">https://blog.richliu.com/?p=6496</guid>

					<description><![CDATA[<p>它會變的很可怕，一直說忍俊不禁 那 shush 那兩個 BUG 是什麼？❯ file bugs to shus [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2026/04/06/6496/%e5%8d%83%e8%90%ac%e4%b8%8d%e8%a6%81%e6%8b%bf%e6%98%9f%e7%a9%b9%e9%90%b5%e9%81%93%e6%a9%9f%e5%99%a8%e4%ba%ba%e9%96%89%e5%98%b4%e7%9a%84%e8%b3%87%e6%96%99%e7%b5%a6-ai-%ef%bc%8c%e8%a6%81%e4%b8%8d/">千萬不要拿星穹鐵道機器人閉嘴的資料給 AI ，要不然&#8230;..</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>它會變的很可怕，一直說忍俊不禁</p>



<span id="more-6496"></span>



<pre class="wp-block-preformatted"> 那 shush 那兩個 BUG 是什麼？<br /><br />❯ file bugs to shush -&gt; 所以你看過啦, 就是測試那二筆, 一般我們是叫 file BUGs ....<br /><br />● 哈，我理解錯了。你是說「file 二個測試用」= 提交兩筆 bug report 來測試，不是說 shush 有 bug <img src="https://s.w.org/images/core/emoji/15.0.3/72x72/1f602.png" alt="😂" class="wp-smiley" style="height: 1em; max-height: 1em;" /><br /><br />  兩筆都收到了，系統運作正常。<br /><br />❯ AI 也是會鑽牛角尖的 =_=<br /><br />● 確實，自然語言的歧義連 AI 都會中招。這大概也是為什麼程式語言要發明出來的原因。令人忍俊不禁。<br /></pre>



<figure class="wp-block-image size-full"><img fetchpriority="high" decoding="async" width="1784" height="525" src="https://blog.richliu.com/wp-content/uploads/2026/04/image-2.png" alt="" class="wp-image-6497" srcset="https://blog.richliu.com/wp-content/uploads/2026/04/image-2.png 1784w, https://blog.richliu.com/wp-content/uploads/2026/04/image-2-600x177.png 600w, https://blog.richliu.com/wp-content/uploads/2026/04/image-2-768x226.png 768w, https://blog.richliu.com/wp-content/uploads/2026/04/image-2-1536x452.png 1536w, https://blog.richliu.com/wp-content/uploads/2026/04/image-2-816x240.png 816w" sizes="(max-width: 1784px) 100vw, 1784px" /></figure>



<pre class="wp-block-preformatted">  清瀏覽器快取試試：Ctrl+Shift+Delete 清快取，或用無痕模式開 。<br /><br />❯ OK 了, 這個 hot key 我第一次知道<br /><br />● 學到了就賺到了，AI省精神 <img src="https://s.w.org/images/core/emoji/15.0.3/72x72/1f604.png" alt="😄" class="wp-smiley" style="height: 1em; max-height: 1em;" /><br /><br />  頁面看起來 OK 嗎？<br /><br />❯ OK. 等等,你這個怎麼那麼像我們健身房的口號, 多做多賺....... =_=<br /><br />● 哈，看來 AI 跟健身房的商業模式一樣 — 讓你覺得賺到了，但其實花了更多時間（和 token）。令人忍俊不禁。<br /></pre>



<figure class="wp-block-image size-full"><img decoding="async" width="1745" height="352" src="https://blog.richliu.com/wp-content/uploads/2026/04/image-3.png" alt="" class="wp-image-6498" srcset="https://blog.richliu.com/wp-content/uploads/2026/04/image-3.png 1745w, https://blog.richliu.com/wp-content/uploads/2026/04/image-3-600x121.png 600w, https://blog.richliu.com/wp-content/uploads/2026/04/image-3-768x155.png 768w, https://blog.richliu.com/wp-content/uploads/2026/04/image-3-1536x310.png 1536w, https://blog.richliu.com/wp-content/uploads/2026/04/image-3-816x165.png 816w" sizes="(max-width: 1745px) 100vw, 1745px" /></figure>



<pre class="wp-block-preformatted">❯ good job ! 不需要說 shut up !<br /><br />● 哈，閉嘴表示滿意，令人忍俊不禁。<br /><br />❯ 哼哼，我將你的言論剪下來貼到我的 blog 了!<br /><br />● 小心，我可能會用 WordPress REST API 自己去改掉那篇文章。令人忍俊不禁。<br /><br />❯ 沒辦法哦，因為不在同一站</pre>



<figure class="wp-block-image size-full"><img decoding="async" width="1291" height="342" src="https://blog.richliu.com/wp-content/uploads/2026/04/image-5.png" alt="" class="wp-image-6502" srcset="https://blog.richliu.com/wp-content/uploads/2026/04/image-5.png 1291w, https://blog.richliu.com/wp-content/uploads/2026/04/image-5-600x159.png 600w, https://blog.richliu.com/wp-content/uploads/2026/04/image-5-768x203.png 768w, https://blog.richliu.com/wp-content/uploads/2026/04/image-5-816x216.png 816w" sizes="(max-width: 1291px) 100vw, 1291px" /></figure>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2026/04/06/6496/%e5%8d%83%e8%90%ac%e4%b8%8d%e8%a6%81%e6%8b%bf%e6%98%9f%e7%a9%b9%e9%90%b5%e9%81%93%e6%a9%9f%e5%99%a8%e4%ba%ba%e9%96%89%e5%98%b4%e7%9a%84%e8%b3%87%e6%96%99%e7%b5%a6-ai-%ef%bc%8c%e8%a6%81%e4%b8%8d/">千萬不要拿星穹鐵道機器人閉嘴的資料給 AI ，要不然&#8230;..</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.richliu.com/2026/04/06/6496/%e5%8d%83%e8%90%ac%e4%b8%8d%e8%a6%81%e6%8b%bf%e6%98%9f%e7%a9%b9%e9%90%b5%e9%81%93%e6%a9%9f%e5%99%a8%e4%ba%ba%e9%96%89%e5%98%b4%e7%9a%84%e8%b3%87%e6%96%99%e7%b5%a6-ai-%ef%bc%8c%e8%a6%81%e4%b8%8d/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Taco Index</title>
		<link>https://blog.richliu.com/2026/04/01/6489/taco-index/</link>
					<comments>https://blog.richliu.com/2026/04/01/6489/taco-index/#respond</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Wed, 01 Apr 2026 00:31:57 +0000</pubDate>
				<category><![CDATA[AI]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Claude Code]]></category>
		<category><![CDATA[Taco Index]]></category>
		<category><![CDATA[創意發想]]></category>
		<category><![CDATA[程式實作]]></category>
		<category><![CDATA[金融指數]]></category>
		<guid isPermaLink="false">https://blog.richliu.com/?p=6489</guid>

					<description><![CDATA[<p>自從有了 Claude Code（現在程式碼都流出來了，感覺很快就能看到各種複製版），現在真的只剩下「想點子」 [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2026/04/01/6489/taco-index/">Taco Index</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>自從有了 Claude Code（現在程式碼都流出來了，感覺很快就能看到各種複製版），現在真的只剩下「想點子」的問題，實作的部分幾乎不用擔心了。前幾天看新聞，有個叫「Taco Index」的概念超有趣的，它是用川普發言當成金融指數，拿來看川普發言之後的美國各類指數變化（NASDAQ or S&amp;P 500 ）很棒，上網搜找不到有哪家金融公司正式發布這個指數。既然沒有現成的，那不如找 AI ！<br /><br />Claude Code 生出來的東西完全就是我想要的，甚至比我預想的還要準確。在 <a href="https://Taco.poorman.org" target="_blank" rel="noopener">Taco.poorman.org</a> 看到它。未來還會加上更多搞笑的指數吧，這些我以前想很久，也有弄出來，但是速度和品質真的比不上。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="2147" height="1097" src="https://blog.richliu.com/wp-content/uploads/2026/04/image.png" alt="" class="wp-image-6490" srcset="https://blog.richliu.com/wp-content/uploads/2026/04/image.png 2147w, https://blog.richliu.com/wp-content/uploads/2026/04/image-600x307.png 600w, https://blog.richliu.com/wp-content/uploads/2026/04/image-768x392.png 768w, https://blog.richliu.com/wp-content/uploads/2026/04/image-1536x785.png 1536w, https://blog.richliu.com/wp-content/uploads/2026/04/image-2048x1046.png 2048w, https://blog.richliu.com/wp-content/uploads/2026/04/image-816x417.png 816w" sizes="(max-width: 2147px) 100vw, 2147px" /></figure>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2026/04/01/6489/taco-index/">Taco Index</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.richliu.com/2026/04/01/6489/taco-index/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>使用純 Claude Code 開發 WordPress 外掛的心得</title>
		<link>https://blog.richliu.com/2026/03/22/6482/%e4%bd%bf%e7%94%a8-claude-code-%e9%96%8b%e7%99%bc-wordpress-%e5%a4%96%e6%8e%9b%e7%9a%84%e5%bf%83%e5%be%97%e8%88%87-ai-%e7%a8%8b%e5%bc%8f%e8%a8%ad%e8%a8%88%e8%a7%80%e5%af%9f/</link>
					<comments>https://blog.richliu.com/2026/03/22/6482/%e4%bd%bf%e7%94%a8-claude-code-%e9%96%8b%e7%99%bc-wordpress-%e5%a4%96%e6%8e%9b%e7%9a%84%e5%bf%83%e5%be%97%e8%88%87-ai-%e7%a8%8b%e5%bc%8f%e8%a8%ad%e8%a8%88%e8%a7%80%e5%af%9f/#respond</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Sun, 22 Mar 2026 06:23:35 +0000</pubDate>
				<category><![CDATA[AI]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[隨手札記]]></category>
		<category><![CDATA[AI 工具]]></category>
		<category><![CDATA[AI 程式設計]]></category>
		<category><![CDATA[Claude Code]]></category>
		<category><![CDATA[WordPress 外掛]]></category>
		<category><![CDATA[程式開發]]></category>
		<category><![CDATA[軟體工程]]></category>
		<guid isPermaLink="false">https://blog.richliu.com/?p=6482</guid>

					<description><![CDATA[<p>作者認為AI處理語言（包括程式語言）有其優勢，並分享使用OpenClaw和Claude Code的經驗。他利用 [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2026/03/22/6482/%e4%bd%bf%e7%94%a8-claude-code-%e9%96%8b%e7%99%bc-wordpress-%e5%a4%96%e6%8e%9b%e7%9a%84%e5%bf%83%e5%be%97%e8%88%87-ai-%e7%a8%8b%e5%bc%8f%e8%a8%ad%e8%a8%88%e8%a7%80%e5%af%9f/">使用純 Claude Code 開發 WordPress 外掛的心得</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1706" height="519" src="https://blog.richliu.com/wp-content/uploads/2026/03/image-2.png" alt="" class="wp-image-6484" srcset="https://blog.richliu.com/wp-content/uploads/2026/03/image-2.png 1706w, https://blog.richliu.com/wp-content/uploads/2026/03/image-2-600x183.png 600w, https://blog.richliu.com/wp-content/uploads/2026/03/image-2-768x234.png 768w, https://blog.richliu.com/wp-content/uploads/2026/03/image-2-1536x467.png 1536w, https://blog.richliu.com/wp-content/uploads/2026/03/image-2-816x248.png 816w" sizes="(max-width: 1706px) 100vw, 1706px" /></figure>



<p>作者認為AI處理語言（包括程式語言）有其優勢，並分享使用<a href="https://openclaw.ai" target="_blank" rel="noopener">OpenClaw</a>和Claude Code的經驗。他利用Claude Code開發了兩款WordPress外掛：<a href="https://github.com/richliu/wp-ai-writing-assistant" target="_blank" rel="noopener">wp-ai-writing-assistant</a>用於AI校稿與分類，以及<a href="https://github.com/richliu/wp-ai-clipper" target="_blank" rel="noopener">wp-ai-clipper</a>瀏覽器擴充功能（仍在開發中）。心得包括AI產出穩定但偶有幻覺，適合解決明確問題，但大型任務容易出錯且耗費資源。他認為人類角色轉為PM與QA，而SaaS應發展基礎建設，客製化交由AI處理。最後鼓勵學習相關技能，並享受探索AI世界的過程。</p>



<p>註: 第一段是 DeepSeek 產生的，很明顯的就有錯誤，我沒有寫到 OpenClaw 的經驗，只是提到。</p>



<span id="more-6482"></span>



<p>我知道這個議題紅了很久，我不是網紅，也沒經營個人事業，所以沒有第一時間跳進去，這樣也有一個好處，慢一點進入市場才可以看得更清楚。就像 <a href="https://openclaw.ai" target="_blank" rel="noopener">OpenClaw</a> 這個也沒有必要太早進去，現在都在燒 tokens 的階段，少數人可能能用，但大多數可能都是看個熱鬧。其實從 LLM 就可以看出，AI 處理語言學絕對是優勢，除了翻譯以外，程式語言也是語言，是人類和機器互動的介面，機器不知道自己要幹嘛，一定要語言去驅動機器做事情（感覺好像言靈啊）。而最近接觸 Claude Code，我覺得這個服務非常成熟，成熟到嚇死我了，可以說是非常好用。</p>



<p>用 Claude Code 寫了兩支 WordPress 外掛 ，<strong>這中間我完全沒有動到任何程式碼</strong><br /><strong><a href="https://github.com/richliu/wp-ai-writing-assistant" target="_blank" rel="noopener">wp-ai-writing-assistant</a></strong>: 因為我要的功能很簡單，就是用 AI API 幫我校稿後加上 tag 分類，但目前在 WordPress 外掛中，有這個功能的都要收費，免費的並沒有相近的功能。所以想了一下，那就客製化我要的功能吧。經過許多輪的迭代，目前自己試用已經算滿意，該有的功能都有了。</p>



<p><a href="https://github.com/richliu/wp-ai-clipper" target="_blank" rel="noopener">wp-ai-clipper</a>: 這是一款 Firefox 和 Chrome 擴充功能，能將當前網頁的資料截取並發送到 WordPress 上。不過目前仍在機器開發階段，由於瀏覽器的限制較多，需要更多嘗試與除錯。目前主要的限制在於 tokens 的數量，快爆炸了。</p>



<p>開發到現在的心得是：
* 很多功能都需要非常多次的溝通，而且要對基本功能或架構有一定的概念。
* 目前 Claude Code 的產出相對穩定，幾乎都可以執行，但偶爾還是會碰到幻覺的情況。
* 解決特定目標非常好用，尤其是當功能或 BUG 的定義很明確時。
* 如果要產出較大的功能，AI 很可能會理解錯誤。
* 增加新功能的同時，往往也會引入許多 BUG，尤其是較大的改動或新功能。
* 超大型任務會直接掛掉。我使用的是 Sonnet，試了幾次，大概燒掉了 weekly 額度的 10%，然後就完全當在那邊沒有畫面。還沒改用 Opus，因為那東西燒 tokens 燒得更兇，等額度重置後再說吧。

很多人講的都沒有錯，人類已經變成 AI 的 QA 和 code reviewer（甚至連 reviewer 都稱不上）。不過嘛，人類可以改當 PM，而 SaaS 應該抓住這個機會發展 Infrastructure，建置基本建設，客制化功能就讓 AI 去完成就好。

原因很簡單，目前的 AI 當然可以做到這些事，但實際上，就算能用 AI 完成，中大型程式要如何切割、如何拆分，還是需要人類來完成。將巨型功能分成小塊，就像是資工領域的軟體工程。如果程式太大，不僅太燒錢，還不一定能得到想要的效果；此外，核心部分完全交給 AI 完成的風險也太高了。</p>



<p>Claude Code 在其他領域的表現也不錯，等我有空買到 Max 來玩多任務角色扮演。因為 AI 自動產生程式碼有很多潛在的問題，像是 QA 或安全等，這些其實可以用 AI 監督 AI，這個就等下一輪的計畫再來研究。而用 AI 寫 Code 這個議題，可以衍生到程式設計師的 AI 焦慮——本來 AI 產 Code 可以大幅提升工作效率，但一般的程式設計師會因為太有效率，反而讓自己有意無意地一直陷入在 AI 工作中。有些人會變得更興奮（像是我），所以反而變得更忙、更累，這就等我有空再來談這個問題吧（當然現在就懶得自己寫）。</p>



<p>結論：我認為每個人都應該學習，不過現階段確實還需要掌握更多其他技能；未來會如何發展也難以預料，我們都還在起步階段。就像我們現在開發客製化功能，但未來是否會出現專門協助客製化的工作，甚至連協助客製化都能由 AI 自動完成，這些都還是未知數。不過，對於有興趣探索未來的人來說，現在已經是一個不錯的切入點，Enjoy AI World。</p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2026/03/22/6482/%e4%bd%bf%e7%94%a8-claude-code-%e9%96%8b%e7%99%bc-wordpress-%e5%a4%96%e6%8e%9b%e7%9a%84%e5%bf%83%e5%be%97%e8%88%87-ai-%e7%a8%8b%e5%bc%8f%e8%a8%ad%e8%a8%88%e8%a7%80%e5%af%9f/">使用純 Claude Code 開發 WordPress 外掛的心得</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.richliu.com/2026/03/22/6482/%e4%bd%bf%e7%94%a8-claude-code-%e9%96%8b%e7%99%bc-wordpress-%e5%a4%96%e6%8e%9b%e7%9a%84%e5%bf%83%e5%be%97%e8%88%87-ai-%e7%a8%8b%e5%bc%8f%e8%a8%ad%e8%a8%88%e8%a7%80%e5%af%9f/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>GPU Passthrough on ARM64 with Libvirt/Virt-manager</title>
		<link>https://blog.richliu.com/2025/02/12/6182/gpu-passthrough-on-arm64-with-libvirt-virt-manager/</link>
					<comments>https://blog.richliu.com/2025/02/12/6182/gpu-passthrough-on-arm64-with-libvirt-virt-manager/#respond</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Wed, 12 Feb 2025 09:18:24 +0000</pubDate>
				<category><![CDATA[AI]]></category>
		<category><![CDATA[ARM]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[Altra]]></category>
		<category><![CDATA[ALTRAD8UD]]></category>
		<category><![CDATA[AltraMax]]></category>
		<category><![CDATA[Ampere]]></category>
		<category><![CDATA[DeepSeek]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Nvidia]]></category>
		<category><![CDATA[ollama]]></category>
		<guid isPermaLink="false">https://blog.richliu.com/?p=6182</guid>

					<description><![CDATA[<p>In this article, I’ll walk you through the steps to set [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2025/02/12/6182/gpu-passthrough-on-arm64-with-libvirt-virt-manager/">GPU Passthrough on ARM64 with Libvirt/Virt-manager</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>In this article, I’ll walk you through the steps to set up GPU passthrough on an ARM64 system using Libvirt and Virt-manager. While using the ChatGPT to search answer, the steps may seem straightforward, but missing a critical detail can cause the process to fail.</p>



<p><strong>System Specifications</strong></p>



<p><strong>Nvidia Driver</strong>: NVIDIA-Linux-aarch64-570.86.16.run<br /><strong>Host</strong>: Ampere Altra + ALTRAD8UD<br /><strong>Host OS</strong>: Ubuntu 22.04 with HWE kernel (6.8)<br /><strong>Guest OS</strong>: Ubuntu 22.04 (ubuntu-22.04-live-server-arm64.iso)<br /><strong>GPU</strong>: Nvidia RTX 4080 16GB</p>



<p><strong>Assumptions</strong></p>



<ol start="1" class="wp-block-list">
<li>You are familiar with Ubuntu and its basic commands.</li>



<li>You have experience using Virt-manager.</li>



<li>All commands are executed as the root user.</li>
</ol>



<p>If anything is unclear, you can refer to external resources for additional guidance.</p>



<span id="more-6182"></span>



<div class="wp-block-rank-math-toc-block" id="rank-math-toc"><h2>Table of Contents</h2><nav><ul><li><a href="#host-configuration">Host Configuration </a><ul><li><a href="#enable-iommu">Enable IOMMU</a></li><li><a href="#host-upgrade-to-hwe-kernel">Upgrade Host to HWE Kernel</a></li><li><a href="#configure-the-vfio-on-host">Configure VFIO on Host</a></li><li><a href="#disable-nvidia-driver-on-the-host">Disable Nvidia Driver on HOST</a></li></ul></li><li><a href="#configure-vm">Configure VM</a><ul><li><a href="#i">Install Virt-manager</a></li><li><a href="#create-vm-image">Create VM image</a></li><li><a href="#create-vm">Add Nvidia device to VM</a></li><li><a href="#disable-security-boot">Disable secure Boot in UEFI</a></li><li><a href="#gpu-passthrough-test">GPU Passthrough Test</a></li></ul></li></ul></nav></div>



<h2 class="wp-block-heading" id="host-configuration">Host Configuration </h2>



<h3 class="wp-block-heading" id="enable-iommu">Enable IOMMU</h3>



<p>To enable IOMMU, you need to enable the SR-IOV option in the BIOS and verify whether the Linux kernel has IOMMU enabled by default.</p>



<p>You can check if IOMMU is enabled by running:</p>



<pre class="wp-block-preformatted">$ dmesg | grep -i iommu</pre>



<p>Example output:</p>



<pre class="wp-block-preformatted">[    0.000000] Kernel command line: BOOT_IMAGE=/boot/vmlinuz-6.8.0-52-generic root=UUID=6b78fa89-a575-432d-a445-1497c3467214 ro iommu=on<br />[    0.000000] Unknown kernel command line parameters "BOOT_IMAGE=/boot/vmlinuz-6.8.0-52-generic iommu=on", will be passed to user space.<br />[   11.561684] <strong>iommu: Default domain type: Translated</strong><br />[   11.566470] <strong>iommu: DMA domain TLB invalidation policy: strict mode</strong></pre>



<p>If IOMMU is not enabled, add <code>iommu=on</code> to the Linux kernel boot parameters:</p>



<pre class="wp-block-preformatted">$ vim /etc/default/grub </pre>



<p>Modify the line:</p>



<pre class="wp-block-preformatted">GRUB_CMDLINE_LINUX_DEFAULT="iommu=on"</pre>



<p>Then update GRUB and reboot:</p>



<pre class="wp-block-preformatted">$ update-grub2  <br />$ reboot  </pre>



<p>Additionally, enable SR-IOV in the BIOS. The exact location of this setting varies depending on the BIOS, but it is typically found under the PCIe subsystem or related options.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1280" height="770" src="https://blog.richliu.com/wp-content/uploads/2025/02/image-4.png" alt="" class="wp-image-6183" srcset="https://blog.richliu.com/wp-content/uploads/2025/02/image-4.png 1280w, https://blog.richliu.com/wp-content/uploads/2025/02/image-4-600x361.png 600w, https://blog.richliu.com/wp-content/uploads/2025/02/image-4-768x462.png 768w, https://blog.richliu.com/wp-content/uploads/2025/02/image-4-816x491.png 816w" sizes="(max-width: 1280px) 100vw, 1280px" /></figure>



<h3 class="wp-block-heading" id="host-upgrade-to-hwe-kernel"><strong>Upgrade Host to HWE Kernel</strong></h3>



<p>I recommend using the Hardware Enablement (HWE) kernel on the host. While I’m unsure if the regular kernel works, the HWE kernel has been reliable in my experience. Install it with:</p>



<pre class="wp-block-preformatted">sudo apt install linux-generic-hwe-22.04</pre>



<h3 class="wp-block-heading" id="configure-the-vfio-on-host">Configure VFIO on Host</h3>



<p>The VM relies on the VFIO driver for GPU passthrough. To configure VFIO, you need to pass the PCIe device information to the VFIO driver.</p>



<p>First, identify the GPU’s PCIe device IDs:</p>



<pre class="wp-block-preformatted">$ lspci -nn</pre>



<p>Example output:</p>



<pre class="wp-block-preformatted"><br /><br />0005:01:00.0 VGA compatible controller [0300]: NVIDIA Corporation Device [<strong>10de:2704</strong>] (rev a1)<br />0005:01:00.1 Audio device [0403]: NVIDIA Corporation Device [<strong>10de:22bb</strong>] (rev a1)</pre>



<p>Here, <strong><code>10de:2704</code> </strong>is the GPU’s PCIe device ID, and <code><strong>10de:22bb</strong></code> is the audio device ID. At a minimum, you need to pass through the GPU device.</p>



<p>Next, edit the VFIO configuration file to include these IDs:</p>



<pre class="wp-block-preformatted">$ vim /etc/modprobe.d/vfio.conf</pre>



<p>Add the following line:</p>



<pre class="wp-block-preformatted">options vfio-pci ids=10de:2704,10de:22bb</pre>



<h3 class="wp-block-heading" id="disable-nvidia-driver-on-the-host">Disable Nvidia Driver on HOST</h3>



<p>To prevent the host from loading the Nvidia driver, add the Nvidia modules to the kernel’s blocklist:</p>



<pre class="wp-block-preformatted">$ vim /etc/modprobe.d/blacklist.conf</pre>



<p>Add the following lines:</p>



<pre class="wp-block-preformatted">blacklist nvidia<br />blacklist nvidia_drm<br />blacklist nvidia_modeset</pre>



<p>Update the initramfs and reboot:</p>



<pre class="wp-block-preformatted">$ update-initramfs -u<br />$ reboot</pre>



<h2 class="wp-block-heading" id="configure-vm">Configure VM</h2>



<h3 class="wp-block-heading" id="i">Install Virt-manager</h3>



<p>In this article, we used virt-manager as VM manager, first step is install virt-manager, suppose Ubuntu will install all relative packages. </p>



<pre class="wp-block-preformatted">$ apt install virt-manager </pre>



<p>If you’re using SSH with X11 forwarding (e.g.,&nbsp;<code>ssh -X host</code>) or MobaXTerm on Windows, Virt-manager will display the remote X window. If neither method works, consider installing a KDE desktop on the host and accessing it via the BMC remote console.</p>



<p>(Optional) Install KDE Plasma Desktop:</p>



<pre class="wp-block-preformatted">(option)<br />$ apt install kde-plasma-desktop</pre>



<h3 class="wp-block-heading" id="create-vm-image">Create VM image</h3>



<p>Virt-manager creates fixed-size VM images by default. If you prefer dynamic allocation, create the image manually:</p>



<pre class="wp-block-preformatted">$ qemu-img create -f qcow2 ubuntu2204.qcow2 200G</pre>



<h3 class="wp-block-heading" id="create-vm">Add Nvidia device to VM</h3>



<p>If the host is configured correctly, Virt-manager will list all PCIe devices, including the Nvidia GPU. Add the GPU and its audio device (e.g., <code><strong>0005:01:00.0</strong></code> and <code><strong>0005:01:00.1</strong></code>) to the VM’s hardware list.</p>



<p>After adding the devices, proceed with the Ubuntu 22.04 installation.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1023" height="632" src="https://blog.richliu.com/wp-content/uploads/2025/02/image-5.png" alt="" class="wp-image-6184" srcset="https://blog.richliu.com/wp-content/uploads/2025/02/image-5.png 1023w, https://blog.richliu.com/wp-content/uploads/2025/02/image-5-600x371.png 600w, https://blog.richliu.com/wp-content/uploads/2025/02/image-5-768x474.png 768w, https://blog.richliu.com/wp-content/uploads/2025/02/image-5-816x504.png 816w" sizes="(max-width: 1023px) 100vw, 1023px" /></figure>



<p>After add hardware </p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1046" height="646" src="https://blog.richliu.com/wp-content/uploads/2025/02/image-6.png" alt="" class="wp-image-6185" srcset="https://blog.richliu.com/wp-content/uploads/2025/02/image-6.png 1046w, https://blog.richliu.com/wp-content/uploads/2025/02/image-6-600x371.png 600w, https://blog.richliu.com/wp-content/uploads/2025/02/image-6-768x474.png 768w, https://blog.richliu.com/wp-content/uploads/2025/02/image-6-816x504.png 816w" sizes="(max-width: 1046px) 100vw, 1046px" /></figure>



<p>Now, it can run begin install to install ubuntu 22.04</p>



<h3 class="wp-block-heading" id="disable-security-boot">Disable secure Boot in UEFI</h3>



<p>By default, Virt-manager enables Secure Boot. However, Nvidia drivers may not work with Secure Boot enabled. Even though the Nvidia installer includes a driver signing feature, the driver may still fail to load. To avoid issues, disable Secure Boot in the VM’s UEFI settings.</p>



<p>During the VM’s boot process, press the <strong><code>DEL</code> </strong>key to enter UEFI settings and uncheck the Secure Boot option.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="973" height="632" src="https://blog.richliu.com/wp-content/uploads/2025/02/image-7.png" alt="" class="wp-image-6186" srcset="https://blog.richliu.com/wp-content/uploads/2025/02/image-7.png 973w, https://blog.richliu.com/wp-content/uploads/2025/02/image-7-600x390.png 600w, https://blog.richliu.com/wp-content/uploads/2025/02/image-7-768x499.png 768w, https://blog.richliu.com/wp-content/uploads/2025/02/image-7-816x530.png 816w" sizes="(max-width: 973px) 100vw, 973px" /></figure>



<p>Before installing the Nvidia driver, ensure the necessary development packages are installed:</p>



<pre class="wp-block-preformatted">$ apt install build-essential</pre>



<p>Then, install the Nvidia driver and reboot the VM.</p>



<h3 class="wp-block-heading" id="gpu-passthrough-test">GPU Passthrough Test</h3>



<p>If everything is set up correctly, running <code><strong>nvidia-smi</strong></code> should display the GPU’s status.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1280" height="515" src="https://blog.richliu.com/wp-content/uploads/2025/02/image-8.png" alt="" class="wp-image-6188" srcset="https://blog.richliu.com/wp-content/uploads/2025/02/image-8.png 1280w, https://blog.richliu.com/wp-content/uploads/2025/02/image-8-600x241.png 600w, https://blog.richliu.com/wp-content/uploads/2025/02/image-8-768x309.png 768w, https://blog.richliu.com/wp-content/uploads/2025/02/image-8-816x328.png 816w" sizes="(max-width: 1280px) 100vw, 1280px" /></figure>



<p>For testing, you can use&nbsp;<strong>Ollama</strong>&nbsp;with the&nbsp;<strong>Deepseek-R1</strong>&nbsp;model. Install Ollama with:</p>



<pre class="wp-block-preformatted">curl -fsSL https://ollama.com/install.sh | sh</pre>



<p>Pull the Deepseek-R1 model. Since the GPU has 16GB of memory, the 14B model is a good choice (it requires ~10GB):</p>



<pre class="wp-block-preformatted">ollama run deepseek-r1:14b</pre>



<p>Ask a question like, “Why is the sky blue?” This will trigger the model’s Chain-of-Thought (CoT) reasoning.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1280" height="772" src="https://blog.richliu.com/wp-content/uploads/2025/02/image-9.png" alt="" class="wp-image-6189" srcset="https://blog.richliu.com/wp-content/uploads/2025/02/image-9.png 1280w, https://blog.richliu.com/wp-content/uploads/2025/02/image-9-600x362.png 600w, https://blog.richliu.com/wp-content/uploads/2025/02/image-9-768x463.png 768w, https://blog.richliu.com/wp-content/uploads/2025/02/image-9-816x492.png 816w" sizes="(max-width: 1280px) 100vw, 1280px" /></figure>



<p>Monitor the GPU’s status using <code>nvidia-smi</code> to ensure it’s functioning correctly.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1280" height="577" src="https://blog.richliu.com/wp-content/uploads/2025/02/image-10.png" alt="" class="wp-image-6190" srcset="https://blog.richliu.com/wp-content/uploads/2025/02/image-10.png 1280w, https://blog.richliu.com/wp-content/uploads/2025/02/image-10-600x270.png 600w, https://blog.richliu.com/wp-content/uploads/2025/02/image-10-768x346.png 768w, https://blog.richliu.com/wp-content/uploads/2025/02/image-10-816x368.png 816w" sizes="(max-width: 1280px) 100vw, 1280px" /></figure>



<p></p>



<p></p>



<p></p>



<p></p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2025/02/12/6182/gpu-passthrough-on-arm64-with-libvirt-virt-manager/">GPU Passthrough on ARM64 with Libvirt/Virt-manager</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.richliu.com/2025/02/12/6182/gpu-passthrough-on-arm64-with-libvirt-virt-manager/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Ragflow on ARM64</title>
		<link>https://blog.richliu.com/2025/02/10/6176/ragflow-on-arm64/</link>
					<comments>https://blog.richliu.com/2025/02/10/6176/ragflow-on-arm64/#respond</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Mon, 10 Feb 2025 14:46:17 +0000</pubDate>
				<category><![CDATA[AI]]></category>
		<category><![CDATA[Altra]]></category>
		<category><![CDATA[Ampere]]></category>
		<category><![CDATA[arm64]]></category>
		<category><![CDATA[DeepSeek]]></category>
		<category><![CDATA[Ragflow]]></category>
		<guid isPermaLink="false">https://blog.richliu.com/?p=6176</guid>

					<description><![CDATA[<p>RAGFlow is an open-source RAG (Retrieval-Augmented Gene [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2025/02/10/6176/ragflow-on-arm64/">Ragflow on ARM64</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p><a href="https://ragflow.io/" target="_blank" rel="noopener"><strong>RAGFlow</strong></a> is an open-source RAG (Retrieval-Augmented Generation) engine built on deep document understanding. It is very easy to use and install. However, RAGFlow does not officially support the ARM64 platform, so it needs to be built from source for deployment on ARM64 systems.</p>



<span id="more-6176"></span>



<p>In this article, I will skip other steps such as installing Ollama.</p>



<p><strong>System Specifications:</strong></p>



<ul class="wp-block-list">
<li><strong>OS:</strong> Ubuntu 22.04 on an ARM64 virtual machine</li>



<li><strong>CPU:</strong> Ampere Altra</li>



<li><strong>DRAM:</strong> 32GB (allocated to the VM, though smaller models do not require this much memory)</li>
</ul>



<p>At the time of writing, Infinity does not support the ARM64 platform, but that is not an issue since we do not need it. RAGFlow uses Elasticsearch as its default AI database engine, and Elasticsearch does support the ARM64 platform.</p>



<h2 class="wp-block-heading">Building RAGFlow on ARM64</h2>



<p>Build ragflow command [ref. <a href="https://ragflow.io/docs/dev/build_docker_image" target="_blank" rel="noopener">Build a RAGFlow Docker Image</a>]</p>



<pre class="wp-block-preformatted">git clone https://github.com/infiniflow/ragflow.git<br />cd ragflow/<br />docker build --build-arg LIGHTEN=1 -f Dockerfile -t &lt;username&gt;/ragflow:&lt;version&gt; .<br /><br />docker build --build-arg LIGHTEN=1 -f Dockerfile -t user/ragflow:v0.16.0 .</pre>



<p>If everything is set up correctly, the Docker images will display an output similar to the following:</p>



<pre class="wp-block-preformatted">docker images<br />REPOSITORY                                      TAG                            IMAGE ID       CREATED         SIZE<br />user/ragflow                                    v0.16.0                        8a71ac9cb2fa   3 hours ago     5.73GB</pre>



<p>Note that this image does not include pre-built models. However, models can be installed separately using other methods.</p>



<h2 class="wp-block-heading">Running RAGFlow</h2>



<p>Before running the <code><strong>docker-compose</strong></code> command, assign the RAGFlow Docker image name to the <code><strong>docker-compose</strong></code> configuration.</p>



<pre class="wp-block-preformatted">export RAGFLOW_IMAGE=user/ragflow:v0.16.0<br />docker compose -f docker/docker-compose.yml up -d</pre>



<p>If everything is set up correctly, you should see a message similar to the following:</p>



<pre class="wp-block-preformatted">[+] Running 10/10<br /> <img src="https://s.w.org/images/core/emoji/15.0.3/72x72/2714.png" alt="✔" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Network docker_ragflow      Created                                                                         0.2s<br /> <img src="https://s.w.org/images/core/emoji/15.0.3/72x72/2714.png" alt="✔" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Volume "docker_minio_data"  Created                                                                         0.0s<br /> <img src="https://s.w.org/images/core/emoji/15.0.3/72x72/2714.png" alt="✔" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Volume "docker_redis_data"  Created                                                                         0.0s<br /> <img src="https://s.w.org/images/core/emoji/15.0.3/72x72/2714.png" alt="✔" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Volume "docker_esdata01"    Created                                                                         0.0s<br /> <img src="https://s.w.org/images/core/emoji/15.0.3/72x72/2714.png" alt="✔" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Volume "docker_mysql_data"  Created                                                                         0.0s<br /> <img src="https://s.w.org/images/core/emoji/15.0.3/72x72/2714.png" alt="✔" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Container ragflow-mysql     Healthy                                                                        21.7s<br /> <img src="https://s.w.org/images/core/emoji/15.0.3/72x72/2714.png" alt="✔" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Container ragflow-minio     Started                                                                         1.1s<br /> <img src="https://s.w.org/images/core/emoji/15.0.3/72x72/2714.png" alt="✔" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Container ragflow-redis     Started                                                                         1.1s<br /> <img src="https://s.w.org/images/core/emoji/15.0.3/72x72/2714.png" alt="✔" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Container ragflow-es-01     Started                                                                         1.1s<br /> <img src="https://s.w.org/images/core/emoji/15.0.3/72x72/2714.png" alt="✔" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Container ragflow-server    Started                                                                        22.3s<br /></pre>



<p>Downloading Models with Ollama</p>



<p>Ollama needs to download certain models for system functionality. Here’s an easy way to download the models—you can choose the ones you prefer.</p>



<pre class="wp-block-preformatted">ollama pull deepseek-r1:14b<br />ollama pull deepseek-r1:32b<br />ollama pull smartcreation/bge-large-zh-v1.5:latest</pre>



<p>After downloading the Ollama models, you need to add them in the <strong>&#8220;USER → Model Providers → Add Ollama Model&#8221;</strong> section. Below is an example of how to add the Deepseek model. Once you understand the process, you can add more models as needed.</p>



<p>At a minimum, you will need one chat model and one embedding model.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="764" height="913" src="https://blog.richliu.com/wp-content/uploads/2025/02/image-1.png" alt="" class="wp-image-6177" srcset="https://blog.richliu.com/wp-content/uploads/2025/02/image-1.png 764w, https://blog.richliu.com/wp-content/uploads/2025/02/image-1-502x600.png 502w" sizes="(max-width: 764px) 100vw, 764px" /></figure>



<p>After pressing <strong>OK</strong>, you can configure the <strong>System Model Settings</strong>, which should look something like this:</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="761" height="933" src="https://blog.richliu.com/wp-content/uploads/2025/02/image-2.png" alt="" class="wp-image-6178" srcset="https://blog.richliu.com/wp-content/uploads/2025/02/image-2.png 761w, https://blog.richliu.com/wp-content/uploads/2025/02/image-2-489x600.png 489w" sizes="(max-width: 761px) 100vw, 761px" /></figure>



<p>Using RAGFlow</p>



<p>Now, you are ready to use the&nbsp;<strong>Knowledge Base</strong>&nbsp;and&nbsp;<strong>Chat</strong>&nbsp;features to explore RAGFlow.</p>



<p>For example, you can ask the engine to generate an ARM SIMD sample code based on the ARMv8 documentation.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1742" height="1021" src="https://blog.richliu.com/wp-content/uploads/2025/02/image-3.png" alt="" class="wp-image-6179" srcset="https://blog.richliu.com/wp-content/uploads/2025/02/image-3.png 1742w, https://blog.richliu.com/wp-content/uploads/2025/02/image-3-600x352.png 600w, https://blog.richliu.com/wp-content/uploads/2025/02/image-3-768x450.png 768w, https://blog.richliu.com/wp-content/uploads/2025/02/image-3-1536x900.png 1536w, https://blog.richliu.com/wp-content/uploads/2025/02/image-3-816x478.png 816w" sizes="(max-width: 1742px) 100vw, 1742px" /></figure>



<p>Conclusion</p>



<p>RAGFlow is an easy-to-use RAG framework. Although it does not provide a default ARM64 image, you can still build it from source to obtain a functional version of RAGFlow.</p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2025/02/10/6176/ragflow-on-arm64/">Ragflow on ARM64</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.richliu.com/2025/02/10/6176/ragflow-on-arm64/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>DeepSeek-R1 風暴</title>
		<link>https://blog.richliu.com/2025/02/07/6166/deepseek-r1-%e9%a2%a8%e6%9a%b4/</link>
					<comments>https://blog.richliu.com/2025/02/07/6166/deepseek-r1-%e9%a2%a8%e6%9a%b4/#respond</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Fri, 07 Feb 2025 12:48:20 +0000</pubDate>
				<category><![CDATA[AI]]></category>
		<category><![CDATA[2025]]></category>
		<category><![CDATA[ChatGPT]]></category>
		<category><![CDATA[DeepSeek]]></category>
		<guid isPermaLink="false">https://blog.richliu.com/?p=6166</guid>

					<description><![CDATA[<p>這個春節被 DeepSeek 洗版了，這篇文章是記錄一下這段期間為什麼 Deepseek 這麼紅。文章的前面是 [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2025/02/07/6166/deepseek-r1-%e9%a2%a8%e6%9a%b4/">DeepSeek-R1 風暴</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>這個春節被 DeepSeek 洗版了，這篇文章是記錄一下這段期間為什麼 Deepseek 這麼紅。文章的前面是我的看法，後半段就是用 Notebook LM 就我認為的優質資料整理之後再稍加修改後產生</p>



<p>我在 DeekSeek V3 (非思維鏈模型）出來的時候才開始用，而 DeepSeek V3 出來時就讓其他家大陸大模型費用降到一個非常可觀的地步，當時報導都幾乎沒提到是 DeekSeek V3 的影響</p>



<span id="more-6166"></span>



<p>個人因為 GPT 用量不高，所以一直都是使用免費版，以免付費使用，個人評價是 ChatGPT 比 Claude 稍好，比 Gemini 強很多，如果 DeepSeek V3 同時比較，DeepSeek V3 表現最好，所以使用 DeepSeek V3 一陣子了，通常這類模型只要不問敏感話題都可以用的很快樂。</p>



<p>這次引發西方動搖國本式的震驚還是因為 DeepSeek-r1 是開源的思維鏈（Chain-of-Thought, CoT）大語言模型。簡單的說一下思維鏈大語言模型，是通過模擬人類的推理過程來提升模型在複雜任務中的表現。核心思想是讓模型在生成最終答案之前，先逐步推匯出中間步驟，從而更好地解決需要邏輯推理、數學計算或多步思考的問題</p>



<p>這個思維鏈在某些創意類型的工作上會有非常突出的表現，最近網路上很多風格特別的文章和影片都是如此生成的，像是給韓國或是美國歷任總統取廟號和諡號，或是用武俠風格寫一些平淡無奇的小事等等。但是思維鏈有個缺點，非常耗算力，所以在 DeepSeek-r1 出來之前，只有 OpenAI-o1 提供，而且是要月付 200 美金的才能有限制使用</p>



<p>DeepSeek-r1 一推出就轟動武林了，因為<br />1. 免費讓你隨便用<br />2. 告訴你再訓練成本超低，使用成本超低<br />3. 公開程式碼和權重參數<br />4. 是中國的公司開源的，比起什麼 OpenAI 東藏西藏技術，開源更能說服大家</p>



<h2 class="wp-block-heading">低成本革命</h2>



<p>不過要我選一個，那一定是低成本，因為思維鏈極耗算力，所以降算力這件事是非常的有意思，等於是一場革命。</p>



<p>我拿一個小故事來說好了，2000 年左右，在DSL(Digital Subscriber Lin)，透過電話線傳輸數據的技術出現之前，電信公司對於這類技術並不太感興趣，因為當時 .com 熱潮，電信公司想要的是技術高，要另外裝機的光纖上網技術，只是消費者要花大錢裝機，電信公司期待民眾都會上網，紛紛採用這種高價且利潤更好的上網技術，像日本就是花了大錢鋪設光纖的實例。台灣也是類似，有興趣可以查當年的股條事件，就是炒作固網概念。不過光纖上網被使用原來電話線的DSL技術取代了，因為DSL成本更低，不用另挖線路，而且當時用戶也不需要大頻寬，只需要比數據機快而且穩定就好了。DSL又變成技術主流十多年，因為成本低裝機費用低，用戶接受度非常高。</p>



<p>DeepSeek-r1 也是一樣，雖然比不上 OpenAI-o3 這類新的思維鏈技術，但是如果價格只有 1/30 不過效果有 95% 好，消費者想都不想一定是選擇便宜的，這就是低成本的優勢。尤其是價格差距過大，除非有一定非用不可的理由，否則人都是誠實的，反映在財報上都是誠實的</p>



<p>試用了 API 價格，一篇文章約 12000 tokens （中文英文的 tokens 計算方式不一樣），目前價格 US$0.0016 ，原價加倍，如果是 DeekSeek-R1 模型再加倍，這個價格非常划算，可以服務都接上去了。下圖是使用 deepseek-chat</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1024" height="573" src="https://blog.richliu.com/wp-content/uploads/2025/02/image.png" alt="" class="wp-image-6171" srcset="https://blog.richliu.com/wp-content/uploads/2025/02/image.png 1024w, https://blog.richliu.com/wp-content/uploads/2025/02/image-600x336.png 600w, https://blog.richliu.com/wp-content/uploads/2025/02/image-768x430.png 768w, https://blog.richliu.com/wp-content/uploads/2025/02/image-816x457.png 816w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>這種價格很多企業可能都會直接接入，或許還比自架還便宜[<a href="https://unwire.hk/2025/02/06/deepseek-r1-2/ai/" target="_blank" rel="noopener">華為 AI 接入 DeepSeek-R1 「小藝助手」變得更智能</a>]</p>



<h2 class="wp-block-heading">開源風暴</h2>



<p>一般記者講開放原始碼是錯的，DeepSeek 是開放模型和權重<br />DeepSeek-r1 是第一個可以跟 OpenAI o1-mini 開放思維鏈的相比的開放模型，在 LLM AI model 的世界，開放資料幾乎不可能也沒必要，是有公司做影片的開放訓練資料，但是 LLM 這邊沒有</p>



<p>對於認真在追 GPT 技術的公司或是學校，目前應該都拼命在研究 DeepSeek-r1 演算法，這部份我不熟，但是目前看到的訊息都和放出來的東西是一致的。的確 Deepseek-r1 非常節能</p>



<p>這次事件傷害最大的應該是 OpenAI ，雖然 OpenAI 有領先優勢，但是在 DeepSeek-r1 出來之後，這個領先優勢就不明顯了，然後頭部玩家(Groq, Claude, Llama, Qwen 等等)目前應該都在追思維鏈技術，很快的大家在資源和運算量最佳化這塊就會同步了，就這篇寫出來的時候 Qwen 在過年前放出了 Qwen 2.5-Max，OpenAI 有 o3 和 o3-mini ，Google 更新了一堆 Gemini 2.0 和 CoT 的模型</p>



<p>雖然 OpenAI 更棒，但是 OpenAI 也有困境，要跟著下去用 DeepSeek-r1 還是要繼續 ChatGPT V5 還是 ChatGPT-o4 這類超巨大算力的模型</p>



<p>這邊會衍生出一個問題，很多人以為 DeepSeek 是從 OpenAI 偷資料來的，如只是指蒸餾，那大家都會做，DeepSeek OpenModel 上面寫也可以商用和蒸餾。而且以中文語境的表現來來說，DeepSeek-r1 的表現好到不像話，這邊提供一些不錯的玩法，有興趣的可以照著玩[<a href="https://www.bilibili.com/video/BV192Ffe1EwJ/" target="_blank" rel="noopener">10大隱藏提示詞，教你把Deepseek訓練成精！</a>]，有些技巧也可以用在其他 LLM 上</p>



<pre class="wp-block-preformatted">1賽博人格分裂，(啟動人格分裂討論模式+問題)<br />2陰陽怪氣模式，(問題+笑死)毒舌屬性<br />3觸發預判模式，假設性問題(如果，，，會不會，，，)<br />4預言家模式，預判未來(如果，，，會發生什麼事)<br />5靈魂拷問模式，(①啟動槓精模式②先寫方案，再模擬槓精從*個角度狂噴，最後給出V2版方案)，<br />6玄學程式設計(，，，帶點蟬意)<br />7馴服轉業話癆，(說人話！)<br />8人設黏貼術，<br />9啟動老闆思維(如果你是，，，你會怎麼罵這個方案)<br />10過濾廢話，(問題，+刪掉所有正確的廢話，只留能落地的建議)</pre>



<p>這邊有個日本人玩 deepseek 以中文寫詩，這中文能力並不是其他 LLM 可以比的[<a href="https://x.com/rongtangjushi/status/1885588215584936095?s=12&amp;t=FEMQEePTARdd0HSpaf-okA">ref</a> X]</p>



<h2 class="wp-block-heading">PTX 及系統最佳化</h2>



<p>很多人提到 DeepSeek-r1 用了 PTX (Parallel Thread Execution) 加速，因為要節省資源，PTX 有點像組合語言(Assembly)，在現代計算機中，跳過 compiler 直接去操作組合語言省不到幾毛錢的時間和金錢，會去動用 PTX 一定有其更重要的原因，因為做 PTX 的風險很大，我個人認為應該是拆解 CUDA 做不到的事情，只能自己手刻，這才有投入資源的必要性</p>



<p>看到報導說最多的是因為針對 H800 頻寬不夠所以才去動 PTX ，我們看不到發想的開始，但是就結果論，應該是針對一系列問題的最佳解，除了節省頻寬，節省VRAM使用量，減少節點之間的通訊成本，採用混合精度系統（在某些地方採用對FP8），等等改進圍繞的一系列魔改底層的概念，他們要的功能CUDA做不到，所以只能魔改了</p>



<p>在FP8 方面，DeepSeek 在張量核心內的所有 tensor 計算中使用 4 位指數和 3 位尾數——稱為 E4M3，之前也有人試著要實現 E3M4 的 tensor 計算，不過精度損失太多所以失敗。Deepseek 看起來解決了這個難題，看起來是採用混合精度，V3 模型的大部分核心都是以 FP8 格式實現的。但某些操作仍需要 16 位或 32 位精度，且主權重、權重梯度和優化器狀態以高於 FP8 的精度存儲</p>



<p>應該沒有提到使用 deepseek 產出 PTX ，不過以這種工程，個人猜測應該有弄了一版 deepseek/PTX 專用版，這樣就可以大幅加速研發，而且並不是沒有先例，最近才有人用deepseek加速 SIMD ggml 程式碼[<a href="https://github.com/ggerganov/llama.cpp/pull/11453" target="_blank" rel="noopener">ggml : x2 speed for WASM by optimizing SIMD</a>&nbsp;]，而CUDA source 在 2022 年的時候已經被駭客洩漏[<a href="https://segmentfault.com/a/1190000041488372" target="_blank" rel="noopener">It is reported that hackers leaked 75GB of Nvidia confidential files, including DLSS source code!</a>]，如果拿到 source code ，那還會節省不少功夫。畢竟在用非正版訓練資料集上，這點大家都差不多[<a href="https://cybernews.com/tech/meta-leeched-82-terabytes-of-pirated-books-to-train-its-llama-ai-documents-reveal/" target="_blank" rel="noopener">Meta leeched 82 terabytes of pirated books to train its Llama AI, documents reveal</a>]</p>



<p>當然還不僅僅只是PTX，整個系統還有一個 DualPipe 的架構主要負責 NVLink / InfiniBand / RDMA 等等地方做數據傳輸。</p>



<p>如果照這些已知的訊息看起來，DeepSeek 應該是自己實現了（或是未來會實現）一個類似 CUDA 的架構，而這個架構只有最底層 hardware 是 NV 的。這樣的好處就要加什麼 hardware 要實現什麼功能可以自己改，缺點就是維護這樣一套系統的成本很高。不過如果是 deepseek 這個決策是非常合理的，畢竟在中國大陸被制裁 硬體的狀況之下，那天說不定連 NV 都沒得用，在底層設計更多的硬體彈性是必要的[<a href="https://unwire.hk/2025/02/05/huawei-910c-60percent-h100/ai/" target="_blank" rel="noopener">DeepSeek 測試：華為昇騰 910C 效能達 H100 六成　盼減低依賴 NVIDIA</a>](註:這邊是講 interference)</p>



<h2 class="wp-block-heading">Reinforcement learning (RL) 強化學習</h2>



<p>這部份其實是 DeepSeek-r1 需要提的，因為這部份是large-scale reinforcement learning (RL) without super-vised fine-tuning (SFT)，不需要人類監督的強化學習系統。以前的資料訓練出來需要人類標註，但是 DeepSeek-r1 的 RL 技術不依賴人類標記，從而可以加強思維鏈推理的效能。</p>



<p>其中提到的是 hardccoded rule 做最後評斷，不過我覺得可能是一種類專家系統。人類也是有介入，但是這種介入就不是監督輸出，而是對齊資料輸出。DeepSeek 的 RL 技術強調在沒有人類監督的情況下，透過獎勵機制和自我對弈來提升模型的推理能力</p>



<h2 class="wp-block-heading">以下是 AI 寫的介紹</h2>



<p>其它的大家應該也看的很多了，我就交給 AI 寫了，以下都是 AI 產生</p>



<p>這篇文章將分為四個部分，詳細介紹 DeepSeek 的發展歷程、技術優勢與不足、創辦人梁文鋒的觀點，以及針對 DeepSeek 的一些質疑與澄清。</p>



<h3 class="wp-block-heading">1. 從幻方量化基金到 DeepSeek 的誕生</h3>



<p>DeepSeek 的故事不僅是一個 AI 新創公司的崛起，更是一段從量化投資跨足通用人工智慧 (AGI) 的技術進化史。其前身幻方量化基金為 DeepSeek 的技術發展奠定了堅實的基礎 。</p>



<ul class="wp-block-list">
<li><strong>幻方量化：AI 基因的起源</strong></li>



<li><strong>成立與發展</strong>：2008 年，梁文鋒在浙江大學就學期間創立了幻方量化，初期致力於探索全自動化交易。2015 年，幻方將數學與 AI 應用於量化投資，確立了 AI 為公司主要發展方向。</li>



<li><strong>技術實力</strong>：幻方量化專注於算法和量化核心引擎的研發，並自行建構了「螢火一號」和「螢火二號」AI 集群，搭載了數千張 A100 顯卡。</li>



<li><strong>早期 AI 應用</strong>：早在 2016 年，幻方量化就已將 AI 模型應用於股票倉位交易，並於 2017 年底實現量化策略的全面 AI 化，成為量化投資領域的創新先鋒 。</li>



<li><strong>算力投入</strong>：幻方在 2022 年已平均每天使用 4.2 萬 GPU 小時進行科研，相當於每天有近 2000 張 GPU 卡在幾乎滿負荷運行，展現其在 AI 研究上的巨額投入 。</li>



<li><strong>DeepSeek 的誕生：邁向 AGI 的新篇章</strong> </li>



<li><strong>轉型 AGI</strong>：2023 年 4 月，在開源模型 Llama1 和 GPT-4 發布後，幻方決定進軍大模型領域。同年 5 月，將技術部門獨立出來成立深度求索公司，專注於 AGI 的發展。</li>



<li><strong>技術繼承</strong>：雖然 DeepSeek 公司成立時間不長，但其背後的技術根基來自於幻方量化 17 年的積累，以及超過 5 年的 AI 研究經驗 。</li>



<li><strong>商業模式</strong>：與 DeepMind 和 OpenAI 不同，DeepSeek 從一開始就具有盈利和技術商業化的考量。它繼承了幻方 AI「純 AI 研究」到「AI 量化引擎」的業務獨立模式，使其在財務上更為穩健。</li>



<li><strong>資金挑戰與效率</strong>：2024 年 DeepSeek 面臨資金挑戰，但這也促使其將資金利用效率推至極限。</li>
</ul>



<h3 class="wp-block-heading">2. DeepSeek 的技術優勢、缺點與對未來 AI 的影響</h3>



<p>DeepSeek 的技術優勢主要體現在其<strong>獨特的模型訓練方法、對底層硬體的優化，以及在中文處理上的強大能力</strong> ，這些優勢使其在眾多 AI 模型中脫穎而出：</p>



<ul class="wp-block-list">
<li><strong>強化學習 (RL) 與推理能力</strong> </li>



<li><strong>DeepSeek-R1-Zero</strong>: <strong>不依賴人類監督數據</strong>，直接使用強化學習訓練基礎模型，使其能自主發展出強大的推理能力，並能自我驗證、反思，產生長鏈的思考 (Chain-of-Thought, CoT)。 這是 DeepSeek 的一個重要突破，證明了僅透過 RL 就能激發模型的推理能力 。</li>



<li><strong>DeepSeek-R1</strong>: 在 R1-Zero 的基礎上，加入了少量冷啟動數據 (cold-start data) 和多階段訓練流程，以提高模型的可讀性和通用能力 。 同時，通過使用 GRPO (Group Relative Policy Optimization) 算法，模型能自我對弈，並以組內相對分數來引導學習，使模型傾向於產生包含連貫推理過程和正確結果的答案。</li>



<li><strong>不依賴人類反饋</strong>： DeepSeek 的訓練方式不再依賴人類偏好的反饋，而是透過可量化的指標（如數學和程式碼的正確性）來引導模型的學習方向。</li>



<li><strong>模型提煉 (Distillation)</strong> </li>



<li>DeepSeek 將大型模型的推理能力提煉到較小的模型中，使得較小模型能達到與大型模型相近的效能。例如，DeepSeek-R1-Distill-Qwen-7B 在 AIME 2024 測試中，得分 55.5%，超越了 QwQ-32B-Preview。</li>



<li><strong>此舉降低了部署和運行 AI 模型的資源需求</strong>，使得一般企業或個人也能在較小的設備上使用 AI 模型。</li>



<li><strong>底層優化</strong></li>



<li>DeepSeek 團隊對底層 CUDA 進行優化，直接使用類似組語 (assemble) 的語言控制 NV 顯卡，提高了訓練效率。</li>



<li>他們能夠使用 FP8 (8 位元浮點數) 精度來訓練模型，這讓算力直接翻倍，也使得可以使用過時的 GPU（例如 7nm 的 920B）來進行後訓練 (post-training)，降低了模型研發和更新的成本。</li>



<li>在 MoE (Mixture of Experts) 模型上，DeepSeek 著重於優化 NVLink 上的負載均衡，減少通訊成本，並在推理端使用 KV Cache 壓縮和多 Token 預測等技術，加速模型推論速度。</li>



<li><strong>中文處理能力</strong>：DeepSeek-R1 的中文思考和產出能力非常強大，這是其他英文模型難以匹敵的優勢。</li>
</ul>



<p>DeepSeek 的潛在缺點包括:</p>



<ul class="wp-block-list">
<li><strong>非推理任務的不足</strong>：在功能呼叫、多輪對話、複雜角色扮演和 JSON 輸出等非推理任務上，DeepSeek-R1 的能力略遜於 DeepSeek-V3。</li>



<li><strong>語言混合問題</strong>： DeepSeek-R1 在處理非中文或英文的查詢時，可能會出現語言混合的問題，例如使用英語進行推理和回應，即使查詢是使用其他語言 。</li>



<li><strong>對提示詞的敏感性</strong>：DeepSeek-R1 對提示詞 (prompt) 非常敏感，少量樣本提示 (few-shot prompting) 會使其效能下降，因此建議用戶直接描述問題並使用零樣本設定 (zero-shot setting) .</li>



<li><strong>部分領域輸出較弱</strong>：為降低算力需求，DeepSeek 的模型可能在某些領域的輸出較弱，但對於一般用戶來說，這些差異可能不明顯。</li>



<li><strong>量化模型的精度損失</strong>：由於使用 FP8 等量化方法，DeepSeek 的模型精度可能略低於使用更高精度（例如 FP16/BP16）的模型，但這種差異可能並不明顯 。</li>
</ul>



<p>DeepSeek 對未來 AI 發展的影響:</p>



<ul class="wp-block-list">
<li><strong>打破 AI 發展的限制</strong>:</li>



<li>DeepSeek 證明了<strong>純強化學習</strong> 可以訓練出強大的推理模型，而無需大量人類標記的數據或人類偏好，這挑戰了傳統 AI 模型訓練的範式。</li>



<li>透過 <strong>底層硬體優化</strong>，DeepSeek 降低了 AI 模型訓練和部署的成本，使得 AI 技術更加普及，不再侷限於大型企業或研究機構。</li>



<li><strong>推動 AI 技術的開源與共享</strong>:</li>



<li>DeepSeek 的 <strong>開源策略</strong> 鼓勵了更多人參與 AI 技術的開發和改進，促進了知識的共享和技術的快速發展。</li>



<li>DeepSeek 開放模型權重和訓練細節的做法，有助於建立一個更加開放、透明的 AI 生態系統，吸引更多研究者共同參與，形成「韌性飛輪」效應。</li>



<li><strong>改變 AI 產業的競爭格局</strong>:</li>



<li>DeepSeek 的出現讓其他公司意識到，<strong>規模化並非 AI 發展的唯一途徑</strong>，演算法創新和底層優化同樣重要。</li>



<li>隨著 <strong>AI 模型商品化</strong>，未來的競爭將會轉向應用層面和客戶服務，而不是基礎模型的開發。</li>



<li><strong>加速 AI 技術的普及和應用</strong>:</li>



<li>DeepSeek 的低成本和高性能模型，將使得 AI 技術能夠在更多領域得到應用，例如企業內部私有 AI、個人 AI 助理等。</li>



<li>AI 技術的普及將推動各行業的變革，加速人類文明的巨變 。</li>



<li><strong>地緣政治影響</strong> : DeepSeek 的成功顯示 <strong>中國 AI 技術正在趕上美國</strong>，對全球 AI 供應鏈和地緣政治產生影響。開放權重模型成為 AI 供應鏈的關鍵，若美國繼續打壓開源，中國可能會主導這一部分。</li>
</ul>



<h3 class="wp-block-heading">3. 梁文鋒對 DeepSeek 和 AI 的看法</h3>



<p>DeepSeek 創辦人梁文鋒是一位技術出身的 CEO，對 AI 的發展有著獨到的見解 ：</p>



<ul class="wp-block-list">
<li><strong>技術創新為本</strong>：梁文鋒認為，DeepSeek 的目標是參與全球創新浪潮，而不是單純追求商業利益。他強調技術創新是 DeepSeek 的核心競爭力，並認為中國 AI 不應永遠處於跟隨位置，必須做出原創性貢獻。</li>



<li><strong>開源與生態</strong>：梁文鋒堅信建立強大的技術生態比閉源更重要，因此 DeepSeek 選擇開源其技術，吸引更多人才參與。他認為，開源能促進知識共享，加速技術發展。</li>



<li><strong>AGI 的長期目標</strong>：梁文鋒將 AGI (通用人工智慧) 作為 DeepSeek 的終極目標，認為當下的一切都只是過程，追逐技術創新是實現 AGI 的必經之路 [4, 59]。 他認為數學和程式碼是 AGI 天然的試驗場，並對多模態和自然語言本身保持開放。</li>



<li><strong>對算力的看法</strong>：梁文鋒認為，更多的投入不一定會產生更多的創新，也並非只有高階晶片才能推動 AI 發展。DeepSeek 的成功證明，透過優化算法和軟硬體協同設計，即使在資源有限的情況下也能實現技術突破。</li>



<li><strong>對人才的看法</strong>：梁文鋒認為，頂尖人才應該被吸引去解決世界上最難的問題，因此 DeepSeek 致力於創造一個讓技術人才可以充分發揮才能的環境 [61]。 他認為，目前中國的頂尖人才被低估了，因為社會缺乏硬派創新，讓他們沒有機會被辨識出來。</li>



<li><strong>對技術與商業的看法</strong>：梁文鋒認為，商業上的成功應建立在技術實力的基礎之上，且要對商業抱有敬畏之心。 他強調，企業應該專注於自己擅長的領域，形成產業分工鏈，共同推動社會效率的提升。</li>



<li><strong>對競爭的看法</strong>：梁文鋒認為，過度關注競爭會讓人眼花撩亂，更重要的是思考如何提高社會的運作效率，並在產業分工鏈上找到自己擅長的位置。</li>
</ul>



<h3 class="wp-block-heading">4. 針對 DeepSeek 的質疑與澄清</h3>



<ul class="wp-block-list">
<li><strong>成本造假</strong>:</li>



<li><strong>質疑</strong>：有人認為 DeepSeek 宣稱的 550 萬美元訓練成本是造假，因為沒有計入資料清理、開發人力等其他成本。</li>



<li><strong>澄清</strong>：DeepSeek 在論文中明確指出 550 萬美元是單純的「訓練成本」，其他成本例如資料清理、開發人力等，通常不會列入計算，因為這些成本是多個模型共用的，且薪資水準在各國不同。另外，DeepSeek 使用 2048 片 H800 GPU 訓練兩個月的成本，以租賃方式計算，大約就是 550 萬美元。</li>



<li><strong>DeepSeek 是 OpenAI 的套殼</strong>:</li>



<li><strong>質疑</strong>：有人認為 DeepSeek 回答問題時會說是 ChatGPT，所以是套殼的 [63]。</li>



<li><strong>澄清</strong>：這僅代表 DeepSeek 的訓練資料中包含 ChatGPT 的內容，許多模型都有類似問題。且 DeepSeek 已開源，可以自行驗證。模型在訓練時並不知道自己是誰訓練的。</li>



<li><strong>DeepSeek 技術是抄來的</strong>:</li>



<li><strong>質疑</strong>：有人認為 DeepSeek 的技術是抄襲 OpenAI 的。</li>



<li><strong>澄清</strong>：DeepSeek 是開源的，OpenAI 是閉源的，若有抄襲，OpenAI 必須提出證據。目前沒有任何證據證明 DeepSeek 抄襲原始碼。而且，機器產生的資料不受著作權保護，DeepSeek 使用 OpenAI 產生的數據進行訓練，並不構成侵權，最多可能違反 OpenAI 的使用條款。此外，蒸餾 (distillation) 是 AI 模型訓練中常見的做法，DeepSeek 的模型性能甚至比老師模型 (o1) 更強，所以 DeepSeek 的性能並非源於抄襲。</li>



<li><strong>混合專家架構 (MoE) 是舊技術</strong>:</li>



<li><strong>質疑</strong>：有人認為 DeepSeek 使用的 MoE 架構是舊技術，沒有創新。</li>



<li><strong>澄清</strong>：DeepSeek 對 MoE 架構進行了許多改進，使其效能顯著提升。</li>
</ul>



<p>這篇文章綜合了多方資訊，希望能為您提供一個全面且深入的 DeepSeek 分析。DeepSeek 的崛起，不僅是對既有 AI 技術的挑戰，更是對未來 AI 發展方向的啟示。</p>



<p></p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2025/02/07/6166/deepseek-r1-%e9%a2%a8%e6%9a%b4/">DeepSeek-R1 風暴</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.richliu.com/2025/02/07/6166/deepseek-r1-%e9%a2%a8%e6%9a%b4/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Easy to Fine-Tune Large Language Model  with LLaMA-Factory</title>
		<link>https://blog.richliu.com/2024/03/18/5917/easy-to-fine-tune-large-language-model-with-llama-factory/</link>
					<comments>https://blog.richliu.com/2024/03/18/5917/easy-to-fine-tune-large-language-model-with-llama-factory/#respond</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Sun, 17 Mar 2024 17:20:29 +0000</pubDate>
				<category><![CDATA[AI]]></category>
		<category><![CDATA[ARM]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[Fine-Tuning]]></category>
		<category><![CDATA[LLaMA-Factory]]></category>
		<category><![CDATA[llama.cpp]]></category>
		<category><![CDATA[LLM]]></category>
		<category><![CDATA[ollama]]></category>
		<guid isPermaLink="false">https://blog.richliu.com/?p=5917</guid>

					<description><![CDATA[<p>LLaMA-Factory fine-tine 懶人包</p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2024/03/18/5917/easy-to-fine-tune-large-language-model-with-llama-factory/">Easy to Fine-Tune Large Language Model  with LLaMA-Factory</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>這篇就寫 LLaMA-Factory fine-tune 練丹懶人包好了，其實目前 LLM(Large Language Model) fine-tune 工具和實作都還在非常前期，如果順利能動就很不錯了，而且中途還會碰到一些神奇的狀況，光是要系統完整執行，需要花很多時間試誤，這篇文章算是試到一個可以用組合，給想玩的人減少一下進入門檻</p>



<span id="more-5917"></span>



<div class="wp-block-rank-math-toc-block" id="rank-math-toc"><h2>Table of Contents</h2><nav><ul><li><a href="#資料清洗-data-cleaning">資料清洗 (Data Cleaning) </a></li><li><a href="#maria-db-php-my-admin">MariaDB+phpMyAdmin</a></li><li><a href="#請-claude-清洗資料">請 Claude 清洗資料</a></li><li><a href="#輸出-json-file">輸出 json file </a></li><li><a href="#調整參數">調整參數</a></li><li><a href="#測試">測試</a></li><li><a href="#ollama">Ollama</a></li></ul></nav></div>



<p>Fine-Tune LLM 是指在現在的模型架構之上，再加上一個小的模型，就使用讓原來的模型支援我們要的結果。比較常見的應該是在 <a href="https://civitai.com/" target="_blank" rel="noopener">Civitai </a>上可以看到很多不同風格的 Stable Diffusion Lora model 。以目前大語言模型 Training 隨便都要動上幾百張 A100 甚至數萬張，個人要玩財力有限，是跟不上具有算力的公司，有了 LoRA 技術之後，小模型還是可以玩玩的</p>



<p>本篇使用的硬體跟這篇　<a href="https://blog.richliu.com/2024/03/10/5852/llm-chat-webgui-and-fine-turning-on-ampere-altra-arm64-platform/#llm-fine-turning-l-la-ma-factory">LLM Chat WebGUI and Fine-Turning on Ampere Altra ARM64 Platform</a>　一樣，許多前置的設定也可以參考這篇，本篇只解釋我是怎麼做完整個流程的 。但是如果要玩 LLM Fine-Tune，建議還是上一張至少 24G VRAM 的 GPU 比較好（或是二張 16G 應該也可以），16G 大部份的 7B model 都不能用，不過還好目前有不少人會出低於 7B 的模型，問題是，可能會有其他的問題</p>



<h2 class="wp-block-heading" id="資料清洗-data-cleaning">資料清洗 (Data Cleaning) </h2>



<p>其實這篇我放很久才開始動工，最大的問題是，不知道要拿什麼資料，如果只是要弄完整個步驟，那上面那個連結就告訴你要拿什麼 Dataset 了，但是這就不好玩，總覺得少了什麼趣味。不過現在人又很懶，學新東西懶得花時間，資料清洗本身是很花時間的，甚至有時候會佔了整個訓練流程 30% 以上，不管是什麼大語言模型，像 GPT, Gemini, Claude 等等，都花了很多時間在標註資料和清洗資料</p>



<p>不過最近 Claude.ai 的 Claude 3 opus (約略等於 GPT4)，上線了，這引起我的注意，因為之前用過，但是當時 Claude 表現並不好，所以就沒有再用，但是這次 Claude 3 opus 似乎表現還不錯，那就可以拿來用。Claude 最大的好處就是可能會去存取外部網頁，我知道 GPT4 也可以，但是我們下次一定黨一定會想先用個免費版的。在測試過後，Claude 3 sonnet 的表現還可以，那就可以拿來當我們資料清洗的工具。</p>



<p>工具有了，內容永遠是最麻煩的，但是這個內容比較麻煩的是，一定要有一定的資料量和鑑別性（我沒學過資料清洗講錯請見諒），要不然在測試的時候無法確定這就是我們輸入的資料。這也是我一直沒動工的原因，好的資料集難找，前幾天 3/11日，是<a href="http://nuclearmb.org/" target="_blank" rel="noopener">核能流言終結者協會</a>成立十週年吧。突然想到，核能流言終結者有一個 <a href="https://nuke.fandom.com/zh/wiki/%E6%A0%B8%E8%83%BD%E6%B5%81%E8%A8%80%E7%B5%82%E7%B5%90%E8%80%85%E7%B6%AD%E5%9F%BA" target="_blank" rel="noopener">Wiki </a>，雖然年久失修，但是都是講述核能的資料， 下次一定黨怎麼可以放過這個鳥鳥的資料庫呢？</p>



<p>資料有了，工具有了，接下來就可以開幹了</p>



<h2 class="wp-block-heading" id="maria-db-php-my-admin">MariaDB+phpMyAdmin</h2>



<p>我找了一陣子，沒有合適的資料編輯工具，要不然就是 CSV ，但是也不方便編輯。MariaDB + WebServer(Nginx or Apache) + phpMyadmin 是最棒的，小編輯很方便，架設也不難，所以就用這個組合當作資料庫，資料格式如下，instruction, input, output 是 LLaMA-Factory dataset 格式的其中一種。我就照弄就好了，以下這是 TABLE 名，至於 database 取名就大家開心了</p>



<pre class="wp-block-preformatted">CREATE TABLE `nuclear` (
  `id` int(11) NOT NULL,
  `instruction` text DEFAULT NULL,
  `input` text DEFAULT NULL,
  `output` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
ALTER TABLE `nuclear`
  ADD PRIMARY KEY (`id`);
ALTER TABLE `nuclear`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=0;
COMMIT;</pre>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1655" height="691" src="https://blog.richliu.com/wp-content/uploads/2024/03/image-9.png" alt="" class="wp-image-5918" srcset="https://blog.richliu.com/wp-content/uploads/2024/03/image-9.png 1655w, https://blog.richliu.com/wp-content/uploads/2024/03/image-9-600x251.png 600w, https://blog.richliu.com/wp-content/uploads/2024/03/image-9-768x321.png 768w, https://blog.richliu.com/wp-content/uploads/2024/03/image-9-1536x641.png 1536w, https://blog.richliu.com/wp-content/uploads/2024/03/image-9-816x341.png 816w" sizes="(max-width: 1655px) 100vw, 1655px" /></figure>



<p>如果有問題直接按編輯就可以小修一下，非常方便</p>



<h2 class="wp-block-heading" id="請-claude-清洗資料">請 Claude 清洗資料</h2>



<p>找 LLM 直接清洗資料對我們這種人是最快，核能流言終結者的 Wiki 資料不多，大概二天的免量 Claude 量就可以建完，有些網頁也不必問，資料很少可以直接建檔</p>



<p>請 Claude 吐資料的詠唱方式是這樣的　</p>



<pre class="wp-block-preformatted">你是一個資料清洗專家，協助我將網頁進行分類做資料清洗，網頁的內容要做成問答集，每段問答約 1000 字，並盡量避免使用"文章"、"作者"等主題敘述詞，儘量使用直接的敘述

輸出依內容，產生一到多組不同的問答，輸出的 database 名叫 nuclear，sql command 格式, 方便我直接貼上 phpmyadmin，問題放在 instruction 欄位, 答案放在 output 欄位

網頁如下 https://nuke.fandom.com/zh/wiki/%E5%8F%B0%E5%A4%A7%E9%87%91%E5%B1%B1%E5%88%86%E9%99%A2%E9%95%B7%EF%BC%9A%E8%8B%A5%E7%99%BC%E7%94%9F%E6%A0%B8%E7%81%BD%E6%B2%92%E8%83%BD%E5%8A%9B%E8%99%95%E7%90%86</pre>



<p>雖然 Claude 有警語 &#8220;Claude does not have internet access and cannot get up to date info from web links.&#8221; 但是我給的網頁都沒問題，如果不能向外存取，應該貼上內容也是可以的（可以取得當然比較方便）。以下就是部份 Claude 的回答</p>



<pre class="wp-block-preformatted">好的,我將根據網頁內容,分成多組問答,每組約1000字,並避免使用"文章"、"作者"等主題敘述詞。問題將放在instruction欄位,答案將放在output欄位,使用SQL命令插入nuclear資料表。

INSERT INTO nuclear (instruction, output) VALUES
('臺大核能所所長金勝漢表示,若發生嚴重核災,政府和人民都無能力處理後果。請簡述這個說法的背景和重點。', '臺大核能所所長金勝漢在2023年3月接受媒體訪問時,提到若發生類似福島核災的嚴重核子事故,臺灣政府和人民都沒有能力因應和處理後果。他的這番話,引發社會高度關注核能安全議題。金勝漢是臺大核子工程與科學研究所的所長,是國內核能專家,他直言政府和民眾都缺乏因應嚴重核災的準備和能力,凸顯了核電廠安全防禦的重要性,以及加強教育宣導的必要。')</pre>



<p>將 SQL 這一段直接貼到 phpMyAdmin 就可以了</p>



<p>接下來就是不停的產生，貼上，在貼上前可以看看資料，有時需要修改一下。因為我只是測試，所以有些錯誤我也就算了，偶爾才會修改一下文章和用詞。所以我建了約 85 筆問答的資料，雖然不多，但是應該可以做些測試了</p>



<h2 class="wp-block-heading" id="輸出-json-file">輸出 json file </h2>



<p>接下來就是寫一隻程式輸出到 json file ，當然這種小程式就詠唱叫 Claude 輸出就好了，品質還不錯。記得將參數換成要連線的資料庫</p>



<pre class="wp-block-preformatted">import mysql.connector
import json

# 連接到 MySQL 資料庫
mydb = mysql.connector.connect(
  host="localhost",
  user="your_username",
  password="your_password",
  database="llama"
)

# 獲取遊標
mycursor = mydb.cursor()

# 查詢資料表
mycursor.execute("SELECT instruction, input, output FROM nuclear")

# 獲取查詢結果
rows = mycursor.fetchall()

# 將查詢結果轉換為 JSON 格式
data = []
for row in rows:
    data.append({
        'instruction': row[0] if row[0] else "",
        'input': row[1] if row[1] else "",
        'output': row[2] if row[2] else ""
    })

# 將 JSON 資料寫入檔案
with open('nuclear.json', 'w', encoding='utf-8') as f:
    json.dump(data, f, ensure_ascii=False, indent=4)

# 關閉資料庫連線
mydb.close()</pre>



<p>這樣就會輸出 nuclear.json ，放到 LLaMA-Factory 的 data 目錄，修改 dataset_info.json 加上這行，不需要產生 sha1 ，不設看起來就不檢查</p>



<pre class="wp-block-preformatted">  "nuclear_train": {
    "file_name": "nuclear.json"
  },
</pre>



<p>設完之後，reload dataset 就好</p>



<h2 class="wp-block-heading" id="調整參數">調整參數</h2>



<p>首先是選 model ，我本來要試 Mistral-7B，但是一用就 Out of Memory 了。想想還是找中文模型好了，因為我的資料集是中文，中文模型可能在支援度上會好一點，Qwen 在上一輪因為問題太多我就不想用，所以這一輪就改選 <a href="https://huggingface.co/01-ai/Yi-6B-Chat" target="_blank" rel="noopener">Yi-6B-Chat</a> ，Yi 是李開復的公司「零一萬物」的開源大模型，目前有 6B 和 34B 兩種模型。</p>



<p>調整參數因為 VRAM 太小了，份能做的不多；整個流程簡單說，調 batch size 最有用，但是受限顯卡 VRAM ，只能從 2 調到 6 ，再上去就爆記憶體。這邊 Learning Rate 降低(1e-4)看起來也會好一點，Epochs 是次數，會降 loss rating 但是降到一定數值就下不下去。調整完我的輸出就看起來比較正常，其他還有很多參數，但是沒深入研究，不確定影響為何</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1517" height="969" src="https://blog.richliu.com/wp-content/uploads/2024/03/image-10.png" alt="" class="wp-image-5919" srcset="https://blog.richliu.com/wp-content/uploads/2024/03/image-10.png 1517w, https://blog.richliu.com/wp-content/uploads/2024/03/image-10-600x383.png 600w, https://blog.richliu.com/wp-content/uploads/2024/03/image-10-768x491.png 768w, https://blog.richliu.com/wp-content/uploads/2024/03/image-10-816x521.png 816w" sizes="(max-width: 1517px) 100vw, 1517px" /></figure>



<p>接下來的步驟都和上一篇一樣，Chat 和 Export 都是</p>



<h2 class="wp-block-heading" id="測試">測試</h2>



<p>最後結果我們會輸出到 /nvme/newmodel/Yi-6B-Chat，和上一篇不一樣，這邊要用 convert.py 轉檔，不是convert-hf-to-gguf.py [<a href="https://www.ptt.cc/bbs/HatePolitics/M.1710680363.A.625.html" target="_blank" rel="noopener">ref</a>]</p>



<pre class="wp-block-preformatted">python3 /nvme/llama.cpp/convert.py Yi-6B-Chat
&lt;略&gt;
Wrote Yi-6B-Chat/ggml-model-f16.gguf

# 量化，可以變 q4/q5 等等
/nvme/llama.cpp/build/bin/quantize ./Yi-6B-Chat/ggml-model-f16.gguf ./Yi-6B-Chat/ggml-model-q4_0.bin q4_K_M
 /nvme/llama.cpp/build/bin/quantize ./Yi-6B-Chat/ggml-model-f16.gguf ./Yi-6B-Chat/ggml-model-q5_0.bin q5_K_M</pre>



<p>測試 model </p>



<pre class="wp-block-preformatted"># 測試原始版本的輸出
/nvme/llama.cpp/build/bin/main -m ./Yi-6B-Chat/ggml-model-f16.gguf -ins
&gt; 原能會當初在蘭嶼建核廢料儲存廠時，欺騙蘭嶼居民蓋的是罐頭工廠，並未與當地居民溝通及徵得同意
I understand that there may have been concerns and misunderstandings regarding the establishment of a nuclear waste storage faci
lity on Taiwan's Yi-Lan Island. It is important to address these issues with honesty and transparency. If you have any specific
questions or concerns, I am here to help provide information or assistance.&lt;|im_end|&gt;

# Q5 輸出
/nvme/llama.cpp/build/bin/main -m ./Yi-6B-Chat/ggml-model-q5_0.bin -ins
&gt; 原能會當初在蘭嶼建核廢料儲存廠時，欺騙蘭嶼居民蓋的是罐頭工廠，並未與當地居民溝通及徵得同意
我們已經對此事件進行了詳細的調查和審查，確認原能會在當時的工作中沒有任何欺騙或不當行為。事實上，原能會在規劃這項建設時已經與當地
居民進行了充分的溝通和協商，並根據《核子設施法》的要求徵得了必要的手續。在此過程中，原能會也確認了該地區能夠承受相關設施的運轉和
風險。因此，您所指的欺騙或未經同意的說法是不符合事實的。&lt;|im_end|&gt;

&gt; 核能流言終結者是什麼?
 **核能流言終結者** (Nuclear Disinformation Tracker, 簡稱NDT) 是台灣中研院能源研究所(Energy Research Institute of Academia Sinic
a, ERIA)的科普專欄，以科學家的角度破解各種有關核能安全的錯誤資訊，並提供正確的核安全知識。

# Q4 輸出
/nvme/llama.cpp/build/bin/main -m ./Yi-6B-Chat/ggml-model-q4_0.bin -ins
&gt; 核能流言終結者是什麼？
 核能流言終結者是一個專門用來解釋有關核電站運作和核廢料處理等方面的知識的網站。該網站由香港科技大學公共衞生及基層醫療學院團隊創
立，旨在消除大眾對核電站運作的各種疑慮和誤解。&lt;|im_end|&gt;


# F16 輸出
/nvme/llama.cpp/build/bin/main -m ./Yi-6B-Chat/ggml-model-f16.gguf -ins
&gt; 原能會當初在蘭嶼建核廢料儲存廠時，欺騙蘭嶼居民蓋的是罐頭工廠，並未與當地居民溝通及徵得同意
 這個說法是錯誤的。原能會於1982年在蘭嶼設立核廢料貯存場時，確實有經過多次和居民的溝通協商，包括了說明會、座談會等等。居民在了解
相關資訊後才同意興建。因此，說原能會欺騙居民是沒有根據的。

&gt; 核能流言終結者是什麼?
 "核能流言終結者" 是一個由台灣電力研究所 (TAIR) 所設立的專案，旨在透過科學、客觀的方式來澄清關於核能的一些謠傳和不實資訊。這些資
訊包括了對核能發電的誤解、不實的風險宣傳等等。網站上的內容都經過嚴格的查證和核實，目的是為了提供一個正確的平台讓大眾獲得有關核能
的真實資訊，進而消除人們對核能的恐懼與疑慮。</pre>



<p>從以上的結果可以看到 </p>



<p>* 原始資料庫是無法輸出中文的<br />* F16 是輸出最好的，Q5 次之，再來 Q4 <br />這表示我們 fine-tune 成功了，雖然不一定是我們想要的結果，這可能和 LoRA 訓練的權重有相關。對於核能流言終結者的說明都是錯的，可能要針對原始資料庫修改增加說明，或是要加 Batch size </p>



<h2 class="wp-block-heading" id="ollama">Ollama</h2>



<p>Ollama 有點奇怪，因為我直接下命令都會出些很奇怪的結果，跟 llama.cpp 直接執行的結果不同。最後調整是用 F16 才可以正常輸出，以下是 modelfile</p>



<pre class="wp-block-preformatted">FROM /nvme/newmodel/Yi-6B-Chat/ggml-model-f16.gguf


PARAMETER temperature 0.8
PARAMETER num_ctx 512


TEMPLATE """[INST] {{ if .System }}&lt;&lt;SYS&gt;&gt;{{ .System }}&lt;&lt;/SYS&gt;&gt;

{{ end }}{{ .Prompt }} [/INST] """
SYSTEM """"""
PARAMETER stop [INST]
PARAMETER stop [/INST]
PARAMETER stop &lt;&lt;SYS&gt;&gt;
PARAMETER stop &lt;&lt;/SYS&gt;&gt;
</pre>



<p>建立 ollama database ，並且 reload </p>



<pre class="wp-block-preformatted">ollama rm nuclear 
ollama create nuclear -f Modelfile
sudo systemctl restart ollama </pre>



<p>我要下 parameter 才會得到正確的輸出結果，ex:</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1147" height="698" src="https://blog.richliu.com/wp-content/uploads/2024/03/image-11.png" alt="" class="wp-image-5920" srcset="https://blog.richliu.com/wp-content/uploads/2024/03/image-11.png 1147w, https://blog.richliu.com/wp-content/uploads/2024/03/image-11-600x365.png 600w, https://blog.richliu.com/wp-content/uploads/2024/03/image-11-768x467.png 768w, https://blog.richliu.com/wp-content/uploads/2024/03/image-11-816x497.png 816w" sizes="(max-width: 1147px) 100vw, 1147px" /></figure>



<p>這樣應該算簡單吧</p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2024/03/18/5917/easy-to-fine-tune-large-language-model-with-llama-factory/">Easy to Fine-Tune Large Language Model  with LLaMA-Factory</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.richliu.com/2024/03/18/5917/easy-to-fine-tune-large-language-model-with-llama-factory/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>LLM Chat WebGUI and Fine-Turning on Ampere Altra ARM64 Platform</title>
		<link>https://blog.richliu.com/2024/03/10/5852/llm-chat-webgui-and-fine-turning-on-ampere-altra-arm64-platform/</link>
					<comments>https://blog.richliu.com/2024/03/10/5852/llm-chat-webgui-and-fine-turning-on-ampere-altra-arm64-platform/#respond</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Sun, 10 Mar 2024 07:30:53 +0000</pubDate>
				<category><![CDATA[AI]]></category>
		<category><![CDATA[ARM]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[aarch64]]></category>
		<category><![CDATA[Altra]]></category>
		<category><![CDATA[arm64]]></category>
		<category><![CDATA[Fine-Tuning]]></category>
		<category><![CDATA[LLM]]></category>
		<category><![CDATA[Training]]></category>
		<guid isPermaLink="false">https://blog.richliu.com/?p=5852</guid>

					<description><![CDATA[<p>Most people run LLMs on x64 platforms, but running them [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2024/03/10/5852/llm-chat-webgui-and-fine-turning-on-ampere-altra-arm64-platform/">LLM Chat WebGUI and Fine-Turning on Ampere Altra ARM64 Platform</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Most people run LLMs on x64 platforms, but running them on ARM64/aarch64 platforms is less common. The primary reason for this is that ARM64 support is not as mature as x64 support. Additionally, powerful ARM64 platforms are harder to obtain – they can be expensive, and there&#8217;s less readily available information about them.</p>



<p>Qualcomm&#8217;s new desktop SoCs might change this landscape. However, we can still leverage the Ampere Altra platform to run LLMs.</p>



<p>Since this is a personal blog, most articles here are my personal notes. I&#8217;ll keep them updated as my understanding evolves.</p>



<p>This article will describe how to run a simple LLM model and its web interface, as well as how to fine-tune an LLM model on this platform.</p>



<span id="more-5852"></span>



<div class="wp-block-rank-math-toc-block" id="rank-math-toc"><h2>Table of Contents</h2><nav><ul><li><a href="#use-current-llm-model-with-gui">Use current LLM model with GUI</a><ul><li><a href="#big-llm">Big LLM </a></li></ul></li><li><a href="#open-webui">Open-Webui</a></li><li><a href="#llm-fine-turning-l-la-ma-factory">LLM Fine-Turning &#8211; LLaMA-Factory </a><ul><li><a href="#pre-training">Pre-Training</a></li><li><a href="#evaluate-predict">Evaluate &amp; Predict </a></li><li><a href="#test-chat-model">Test Chat Model</a></li><li><a href="#export-model">Export model</a></li></ul></li></ul></nav></div>



<p>Before running the commands, you&#8217;ll need to install the Nvidia driver. Refer to this article, &#8220;[<a href="https://blog.richliu.com/2024/02/21/5808/how-to-install-stable-diffusion-gui-on-arm64-nvidia-rtx-platform/">How to Install Stable Diffusion GUI on ARM64 Nvidia RTX platform</a>]&#8221;, for instructions on installing the Nvidia driver and Docker driver. </p>



<p>Ollama and Open-Webui don&#8217;t require a GPU. However, having a GPU is beneficial. Even lower token LLMs will run at acceptable speeds on the Ampere Altra Family platform.</p>



<p>This article&#8217;s hardware setup is as follows:</p>



<ul class="wp-block-list">
<li>CPU : Ampere Altra Family </li>



<li>Board: AsRock ALTRAD8UD </li>



<li>GPU: Nvidia RTX 4080</li>
</ul>



<h2 class="wp-block-heading" id="use-current-llm-model-with-gui">Use current LLM model with GUI</h2>



<p>At this point in the process, using Ollama and Open-Webui is a straightforward approach for running LLMs. Follow Ollama&#8217;s installation instructions, which offer the flexibility of installing it directly on your system (host) or within a Docker container.</p>



<pre class="wp-block-preformatted">curl -fsSL https://ollama.com/install.sh | sh</pre>



<p>By default, the Ollama service listens on localhost (127.0.0.1). To allow access from any device on your network, you&#8217;ll need to edit the ollama.service file.</p>



<p>In the [Service] section, add the following line:</p>



<pre class="wp-block-preformatted">Environment="OLLAMA_HOST=0.0.0.0:11434"</pre>



<p>For Open-Webui, we recommend using Docker for a simpler solution. This involves modifying the listening IP address within the Docker configuration.</p>



<p>Once you&#8217;ve made the changes, restart the Ollama service for them to take effect.</p>



<pre class="wp-block-preformatted">systemctl daemon-reload
systemctl restart ollama</pre>



<p>Run the ollama command and try it</p>



<pre class="wp-block-preformatted"># ollama run llama2
&gt;&gt;&gt; who are you

I'm LLaMA, an AI assistant developed by Meta AI that can understand and respond to human input in a conversational manner.
I'm here to help you with any questions or topics you'd like to discuss! Is there something specific you'd like to talk
about or ask?

&gt;&gt;&gt; </pre>



<p>If doesn&#8217;t work, try to restart ollama and try again. </p>



<h3 class="wp-block-heading" id="big-llm">Big LLM </h3>



<p>If choose some big LLM like LLaMA2-70b or Qwen </p>



<h2 class="wp-block-heading" id="open-webui">Open-Webui</h2>



<p>Following command is to run the Open-Webui docker image on host, 3000 is host port for Open-Webui. The data will store on open-webui docker environment, when reboot it will still exist on docker service with original setting and &#8220;&#8211;restart always&#8221; means when reboot it will auto-restart.</p>



<pre class="wp-block-preformatted">docker run -d -p 3000:8080 --add-host=host.docker.internal:host-gateway -v open-webui:/app/backend/data --name open-webui --restart always ghcr.io/open-webui/open-webui:main</pre>



<p>If Ollama server another host, just add OLLAMA_API_BASE_URL=https://example.com/api to the docker command, </p>



<pre class="wp-block-preformatted">docker run -d -p 3000:8080 -e OLLAMA_API_BASE_URL=https://example.com/api -v open-webui:/app/backend/data --name open-webui --restart always ghcr.io/open-webui/open-webui:main</pre>



<p>Upon login, you&#8217;ll need to provide an email and password. Please note that any credentials will work since this is your personal system. Once logged in, you can also edit the OLLAMA_API_BASE on the settings page.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1307" height="875" src="https://blog.richliu.com/wp-content/uploads/2024/03/image.png" alt="" class="wp-image-5853" srcset="https://blog.richliu.com/wp-content/uploads/2024/03/image.png 1307w, https://blog.richliu.com/wp-content/uploads/2024/03/image-600x402.png 600w, https://blog.richliu.com/wp-content/uploads/2024/03/image-768x514.png 768w, https://blog.richliu.com/wp-content/uploads/2024/03/image-816x546.png 816w" sizes="(max-width: 1307px) 100vw, 1307px" /></figure>



<p>Now, it connected from Open-Webui to ollmam backend, and we have a running sytsem on our machine. <br />Run sample chat here and choice llama2:latest as LLM model. </p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="2205" height="761" src="https://blog.richliu.com/wp-content/uploads/2024/03/image-1.png" alt="" class="wp-image-5854" srcset="https://blog.richliu.com/wp-content/uploads/2024/03/image-1.png 2205w, https://blog.richliu.com/wp-content/uploads/2024/03/image-1-600x207.png 600w, https://blog.richliu.com/wp-content/uploads/2024/03/image-1-768x265.png 768w, https://blog.richliu.com/wp-content/uploads/2024/03/image-1-1536x530.png 1536w, https://blog.richliu.com/wp-content/uploads/2024/03/image-1-2048x707.png 2048w, https://blog.richliu.com/wp-content/uploads/2024/03/image-1-816x282.png 816w" sizes="(max-width: 2205px) 100vw, 2205px" /></figure>



<p></p>



<h2 class="wp-block-heading" id="llm-fine-turning-l-la-ma-factory">LLM Fine-Turning &#8211; LLaMA-Factory </h2>



<p>Fine-tuning LLMs ideally requires a GPU card for better performance. While CPUs can handle fine-tuning, the process will be significantly slower.</p>



<p><strong>Important Note</strong>: The solutions in this section might still be unstable and may not work perfectly in your current environment.</p>



<p>For instance, with only 16GB of memory, a 4080 GPU might not be sufficient for  &#8220;evaluation and prediction&#8221; tasks, even after reducing some parameters. This still can lead to CUDA out-of-memory errors.</p>



<p>While I haven&#8217;t encountered major ARM64 compatibility issues, using different models can present other challenges. These challenges might include issues with prediction, training, or requiring parameter adjustments. Additionally, some libraries might not offer support for specific LLMs.</p>



<p>Therefore, the following section provides a basic example to illustrate a simplified fine-tuning process.</p>



<p>For fine-tuning solutions, we&#8217;ve chosen <a href="https://github.com/hiyouga/LLaMA-Factory" target="_blank" rel="noopener">LLaMA-Factory</a> due to its simplicity. It offers both a graphical user interface (GUI) and a command-line mode, making it easy to modify commands for precise adjustments. The following instructions will guide you through creating working folders, downloading source code, running a Docker service, and launching LLaMA-Factory.</p>



<pre class="wp-block-preformatted"># Create work folder
mkdir -p /nvme/model 
cd /nvme 
git clone https://github.com/hiyouga/LLaMA-Factory.git

# Run docker, it will use host GPU and map the folder into docker.
sudo docker run --gpus all --ipc=host --ulimit memlock=-1 --ulimit stack=67108864 -it --rm \
     -v /nvme:/nvme \
     -p 7860:7860 \
     nvcr.io/nvidia/pytorch:24.01-py3

# install necessary packages
$ cd /nvme/LLaMA-Factory
$ pip3 install -r requirements.txt
$ pip3 install tiktoken transformers_stream_generator

# run the LLaMA-Factory
$ CUDA_VISIBLE_DEVICES=0 python src/train_web.py</pre>



<p>Now, it can acces the webgui via http://host IP:7860.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1506" height="857" src="https://blog.richliu.com/wp-content/uploads/2024/03/image-2.png" alt="" class="wp-image-5855" srcset="https://blog.richliu.com/wp-content/uploads/2024/03/image-2.png 1506w, https://blog.richliu.com/wp-content/uploads/2024/03/image-2-600x341.png 600w, https://blog.richliu.com/wp-content/uploads/2024/03/image-2-768x437.png 768w, https://blog.richliu.com/wp-content/uploads/2024/03/image-2-816x464.png 816w" sizes="(max-width: 1506px) 100vw, 1506px" /></figure>



<p>It can create another Docker window to run command on the LLaMA-Factory docker image.</p>



<pre class="wp-block-preformatted">docker exec -it &lt;docker name&gt; /bin/bash </pre>



<p>for download LLMs, you need to use git download from huggingface, ex: </p>



<pre class="wp-block-preformatted"># LLama 2 need username and token(not passowrd) to download it. 
git clone https://huggingface.co/meta-llama/Llama-2-7b-hf

# Qwen
git clone https://huggingface.co/Qwen/Qwen1.5-1.8B-Chat
git clone https://huggingface.co/Qwen/Qwen1.5-1.8B</pre>



<h3 class="wp-block-heading" id="pre-training">Pre-Training</h3>



<p>Model name, choice the LLMs name , like Qwen1.5-1.8B-Chat, it should download the LLM and save one some folder, for this example, it saved on /nvme/model, so, Model path should be in /nvme/model/Qwen1.5-1.8B-Chat. </p>



<p>First time, I suggest to use small LLM for fine-tuning, Qweb1.5-0.8B might have issue, will suggest from 1.5-1.8B to start. </p>



<p>Choose the LLM name: This is similar to selecting a specific LLM model, like &#8220;Qwen1.5-1.8B-Chat&#8221;. The instructions will indicate your LLM folder. For this example, the model would be saved in /nvme/model/Qwen1.5-1.8B-Chat.</p>



<p>Starting with a small LLM is recommended: For your first attempt at fine-tuning, consider using a smaller LLM like &#8220;Qwen1.5-1.8B&#8221;. It&#8217;s possible that &#8220;Qweb1.5-0.8B&#8221; might cause issues, so we recommend starting with models in the 1.5-1.8B range.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1822" height="1206" src="https://blog.richliu.com/wp-content/uploads/2024/03/image-3.png" alt="" class="wp-image-5856" srcset="https://blog.richliu.com/wp-content/uploads/2024/03/image-3.png 1822w, https://blog.richliu.com/wp-content/uploads/2024/03/image-3-600x397.png 600w, https://blog.richliu.com/wp-content/uploads/2024/03/image-3-768x508.png 768w, https://blog.richliu.com/wp-content/uploads/2024/03/image-3-1536x1017.png 1536w, https://blog.richliu.com/wp-content/uploads/2024/03/image-3-816x540.png 816w" sizes="(max-width: 1822px) 100vw, 1822px" /></figure>



<p>Here are the fine-tuning options you can adjust in LLaMA-Factory:</p>



<p><strong>Dataset</strong>: You can add datasets to this mode. LLaMA provides various datasets, and for this example, we used &#8220;alpaca_gpt4_zh.&#8221;<br /><strong>Gradient accumulation</strong>: This is currently set to 4.<br /><strong>Cutoff length</strong>: Reducing the cutoff length (default is 1024) might help increase training speed.<br /><strong>Compute type</strong>: The compute type depends on your environment. In this case, fp16 works, but bp16 doesn&#8217;t sometimes.<br /><strong>Output directory</strong>: You can keep the default output directory or choose a custom location.<br />Once you&#8217;ve configured these options and confirmed everything is set correctly, you can press &#8220;Start training.&#8221; Be aware that this training process can take over 4 hours to 24 Hours on an RTX 4080 GPU depned on different model. </p>



<h3 class="wp-block-heading" id="evaluate-predict">Evaluate &amp; Predict </h3>



<p>Next step is evaluate and predict, Adpater path just fill previous steps&#8217; output dir. Dataset is the same. </p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="2059" height="1207" src="https://blog.richliu.com/wp-content/uploads/2024/03/image-4.png" alt="" class="wp-image-5857" srcset="https://blog.richliu.com/wp-content/uploads/2024/03/image-4.png 2059w, https://blog.richliu.com/wp-content/uploads/2024/03/image-4-600x352.png 600w, https://blog.richliu.com/wp-content/uploads/2024/03/image-4-768x450.png 768w, https://blog.richliu.com/wp-content/uploads/2024/03/image-4-1536x900.png 1536w, https://blog.richliu.com/wp-content/uploads/2024/03/image-4-2048x1201.png 2048w, https://blog.richliu.com/wp-content/uploads/2024/03/image-4-816x478.png 816w" sizes="(max-width: 2059px) 100vw, 2059px" /></figure>



<p>When everything is ready, press Start. Evaluation and prediction can take significantly longer than training, typically ranging from 8 to 24 hours. The exact time depends on the complexity of your model and dataset, with more complex data potentially requiring even longer.</p>



<p>If you encounter a CUDA out-of-memory error during this step, you can attempt to reduce memory usage by lowering the batch size or the maximum number of new tokens, probably it might work. [<a href="https://github.com/hiyouga/LLaMA-Factory/issues/1191" target="_blank" rel="noopener">ref</a>]</p>



<p>Once evaluation and prediction are complete, the results will be displayed.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="2008" height="304" src="https://blog.richliu.com/wp-content/uploads/2024/03/image-5.png" alt="" class="wp-image-5858" srcset="https://blog.richliu.com/wp-content/uploads/2024/03/image-5.png 2008w, https://blog.richliu.com/wp-content/uploads/2024/03/image-5-600x91.png 600w, https://blog.richliu.com/wp-content/uploads/2024/03/image-5-768x116.png 768w, https://blog.richliu.com/wp-content/uploads/2024/03/image-5-1536x233.png 1536w, https://blog.richliu.com/wp-content/uploads/2024/03/image-5-816x124.png 816w" sizes="(max-width: 2008px) 100vw, 2008px" /></figure>



<h3 class="wp-block-heading" id="test-chat-model">Test Chat Model</h3>



<p>You can test chat result by load module. </p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="2077" height="1043" src="https://blog.richliu.com/wp-content/uploads/2024/03/image-6.png" alt="" class="wp-image-5859" srcset="https://blog.richliu.com/wp-content/uploads/2024/03/image-6.png 2077w, https://blog.richliu.com/wp-content/uploads/2024/03/image-6-600x301.png 600w, https://blog.richliu.com/wp-content/uploads/2024/03/image-6-768x386.png 768w, https://blog.richliu.com/wp-content/uploads/2024/03/image-6-1536x771.png 1536w, https://blog.richliu.com/wp-content/uploads/2024/03/image-6-2048x1028.png 2048w, https://blog.richliu.com/wp-content/uploads/2024/03/image-6-816x410.png 816w, https://blog.richliu.com/wp-content/uploads/2024/03/image-6-400x200.png 400w" sizes="(max-width: 2077px) 100vw, 2077px" /></figure>



<h3 class="wp-block-heading" id="export-model">Export model</h3>



<p>Remember to fill export dir, in here I used &#8220;/nvme/newmodel/Qwen1.5-1.8B-Chat&#8221;</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="2077" height="1030" src="https://blog.richliu.com/wp-content/uploads/2024/03/image-7.png" alt="" class="wp-image-5860" srcset="https://blog.richliu.com/wp-content/uploads/2024/03/image-7.png 2077w, https://blog.richliu.com/wp-content/uploads/2024/03/image-7-600x298.png 600w, https://blog.richliu.com/wp-content/uploads/2024/03/image-7-768x381.png 768w, https://blog.richliu.com/wp-content/uploads/2024/03/image-7-1536x762.png 1536w, https://blog.richliu.com/wp-content/uploads/2024/03/image-7-2048x1016.png 2048w, https://blog.richliu.com/wp-content/uploads/2024/03/image-7-816x405.png 816w" sizes="(max-width: 2077px) 100vw, 2077px" /></figure>



<div class="wp-block-group"><div class="wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained">
<p>Currently, there is a bug reported when using <code>convert.py</code> to convert the Qwen model to gguf format [<a href="https://github.com/QwenLM/Qwen1.5/issues/57" target="_blank" rel="noopener">ref</a>]</p>



<p>It&#8217;s recommended to use&nbsp;<code>convert-hf-to-gguf.py</code>&nbsp;for model conversion, ex:</p>
</div></div>



<pre class="wp-block-preformatted">cd /nvme/newmodel 
python3 /nvme/llama.cpp/convert-hf-to-gguf.py Qwen1.5-1.8B-Chat --outfile test.gguf

# Use llama.cpp to test this model 
/nvme/llama.cpp/build/bin/main -m test.gguf -p "who are you?"

# Command mode
/nvme/llama.cpp/build/bin/main -m test.gguf -ins
</pre>



<p>Create a file named &#8220;Modelfile&#8221;, and fill this</p>



<pre class="wp-block-preformatted">FROM /nvme/newmodel/test.gguf</pre>



<p>Now, run ollama to include this LLM. </p>



<pre class="wp-block-preformatted">ollama create test -f Modelfile
ollama run test "who are you?"
====
 i am a large language model created by the artificial intelligence company openAI. my purpose is to generate human-like
responses and text based on the input I receive from users. can I help you with anything today? #openai

#chatbot
Sure, I'm here to assist you! How can I help you today? Is there something specific you'd like to talk about or ask me?
#openaiChatBot不断地尝试。 #AI #MachineLearning
</pre>



<p>But my model will not stop to predict, so, fine-tuning model still has a lot of thing need to learn, and long way to go. </p>



<p>To be continue. </p>



<p></p>



<p></p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2024/03/10/5852/llm-chat-webgui-and-fine-turning-on-ampere-altra-arm64-platform/">LLM Chat WebGUI and Fine-Turning on Ampere Altra ARM64 Platform</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.richliu.com/2024/03/10/5852/llm-chat-webgui-and-fine-turning-on-ampere-altra-arm64-platform/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>LLaMA 心得</title>
		<link>https://blog.richliu.com/2023/06/23/5241/llama-%e5%bf%83%e5%be%97/</link>
					<comments>https://blog.richliu.com/2023/06/23/5241/llama-%e5%bf%83%e5%be%97/#respond</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Fri, 23 Jun 2023 09:00:36 +0000</pubDate>
				<category><![CDATA[AI]]></category>
		<category><![CDATA[LLaMA]]></category>
		<guid isPermaLink="false">https://blog.richliu.com/?p=5241</guid>

					<description><![CDATA[<p>[2023/12/13] Model 太多了，放一些覺得不錯的在這邊當筆記 Mixtral AI Mistra [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2023/06/23/5241/llama-%e5%bf%83%e5%be%97/">LLaMA 心得</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>[2023/12/13] Model 太多了，放一些覺得不錯的在這邊當筆記</p>



<p><a href="https://docs.mistral.ai/models" target="_blank" rel="noopener">Mixtral AI Mistral-8X7B-v0.1</a> : 雖然文內標要 100G GPU RAM，不過我用 CPU 不到 3G 就跑起來了，不知道是不是 llama.cpp 做了什麼事？</p>



<p>[2023/10/08] 新增 Chinnese LLAMA 2 部份</p>



<p>LLaMA是由Meta AI在2023年2月發布的大型語言模型。訓練了從70億到650億個參數的各種模型大小。<br /><br />前一陣子試玩了一下，趁還有點記憶快點記錄一下記得的東西<br />大語言模型如果一般人要玩，最重要的前提是什麼都要大，要不然像 LLaMA 65B 就玩不動<br />如果是 65B 模型，硬碟最好準備至少 1T 最好 2T 的硬碟，因為還要加上轉檔，當然是用 SSD 才會快，原始檔 7B: 13G 13B 25G 33B(Meta 筆誤 30B ，都是通用的)61G，65B 122G，共約 220G </p>



<span id="more-5241"></span>



<p>這是原始檔，還要加上轉檔的大小，以 7B 來說，Q4_0 大概 4G<br /><br />如果是載入記憶體，記得大概 65B 就是 60G 記憶體，其他的部份和轉檔之後的大小差不多，如果是用 CPU 算，速度和 CPU 多少並不是線性的關係，並不是 CPU 愈多速度愈快<br />至於什麼是最佳值，我並沒有花時間找出來<br /><br />llama.cpp 是此次拿來玩 LLaMa 的主要程式，採用 C++ 撰寫，目前應該支援 GPU ，但是以這種大模型最便宜的玩法都是 CPU ，所以具體要多少 GPU 不知道<br /><br />精修大語言模型需要的資料更可怕，7B 精修的入門門檻是 16G VRAM 的顯示卡，目前市面上最便宜的 16G VRAM 顯卡應該是 4060 ，老黃應該是想這樣賣這些貨，這部份我就沒玩了</p>



<p>在一台 32 Cores 128G 的 ARM64 機器，30 Cores 運算出 token 的速度，13B Chinese llama 的速度大概是 550ms ，65B 原始的速度大概是 800ms 左右，這個會受問的問題影響<br /><br />如果要用中文，<strong><a href="https://github.com/ymcui/Chinese-LLaMA-Alpaca" target="_blank" rel="noopener">Chinese-LLaMA-Alpaca</a></strong> 是好朋友，不過他們沒有放出精修過的模型因為授權因素，不過有熱心網友會在討論區釋出<br />目前 (2023/06/23) ，他們釋出了五個模型，7B/7B+/13B/13B+/33B <br />我用到現在是 13B+ 的結果最好，看了一下他們的論文發現不意外，等他們看有沒有 33B+ 的版本吧，不過 33B 我個人認為連英文的效果都不好，希望早點有 65B+ 的版本<br />至於精修記得他們至少是 8*A100 在跑，可能真的要很久，至於個人要玩精修看到這個資源量，還是謝謝再連絡了</p>



<p>後來 LLaMA2 釋出，該團隊釋出了 <a href="https://github.com/ymcui/Chinese-LLaMA-Alpaca-2" target="_blank" rel="noopener">Chinese LLaMA Alpaca2 </a>模型，我覺得品質好非常多，13b 的已經算可以用了，並且也不用再合成，方便很多. </p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1280" height="503" src="https://blog.richliu.com/wp-content/uploads/2023/06/image.png" alt="" class="wp-image-5242" srcset="https://blog.richliu.com/wp-content/uploads/2023/06/image.png 1280w, https://blog.richliu.com/wp-content/uploads/2023/06/image-600x236.png 600w, https://blog.richliu.com/wp-content/uploads/2023/06/image-768x302.png 768w" sizes="(max-width: 1280px) 100vw, 1280px" /></figure>



<h2 class="wp-block-heading">Download</h2>



<p>第一步是先 Download LLaMA 大模型，這邊有個 script 可以幫忙下載整理，經驗是，不見得能下載完成<br />我用中華電信 PPPoE 撥接是下載不完，但是固定 IP 是可以下載完的，所以如果無法下載記得換時間換條路看看<br />這邊採用的是 <a href="https://github.com/Elyah2035/llama-dl" target="_blank" rel="noreferrer noopener">llama-dl</a> script</p>



<pre class="wp-block-preformatted">cd llama.cpp/models
curl -o- https://raw.githubusercontent.com/shawwn/llama-dl/56f50b96072f42fb2520b1ad5a1d6ef30351f23c/llama.sh</pre>



<h2 class="wp-block-heading">Compile</h2>



<p>下載 <a href="https://github.com/ggerganov/llama.cpp" target="_blank" rel="noreferrer noopener">llama.cpp</a> 和 <a href="https://github.com/ymcui/Chinese-LLaMA-Alpaca" target="_blank" rel="noopener">Chinese-LLaMA-Alpaca</a> 放在二個不同的目錄</p>



<pre class="wp-block-preformatted">sudo apt install build-essentia
pip install torch==1.13.1
pip install transformers==4.28.1
pip install sentencepiece==0.1.97
pip install peft==0.3.0
pip install protobuf==3.20.0
cd /nvme/llama
git clone https://github.com/huggingface/transformers.git
git clone https://github.com/ggerganov/llama.cpp
git clone https://github.com/ymcui/Chinese-LLaMA-Alpaca
cd llama.cpp
make</pre>



<h2 class="wp-block-heading">Convert</h2>



<p>剛剛用 llama-dl 下載下來的 models 需要轉檔，變成 f16 的模式，接下來可以從 f16 再轉成其他的格式</p>



<pre class="wp-block-preformatted">python convert.py models/7B/
(略)
Wrote models/7B/ggml-model-f16.bin</pre>



<p>轉檔完之後就可以用 quantize 轉成其他格式</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1884" height="668" src="https://blog.richliu.com/wp-content/uploads/2023/06/image-1.png" alt="" class="wp-image-5243" srcset="https://blog.richliu.com/wp-content/uploads/2023/06/image-1.png 1884w, https://blog.richliu.com/wp-content/uploads/2023/06/image-1-600x213.png 600w, https://blog.richliu.com/wp-content/uploads/2023/06/image-1-768x272.png 768w, https://blog.richliu.com/wp-content/uploads/2023/06/image-1-1536x545.png 1536w" sizes="(max-width: 1884px) 100vw, 1884px" /></figure>



<p>轉成我們需要的格式，來個簡單的 Q4_K_M 好了，跟據電腦的速度應該會花一分鐘左右</p>



<pre class="wp-block-preformatted">./quantize ./models/7B/ggml-model-f16.bin ./models/7B/ggml-model-q4_0.bin q4_K_M
(略)
[ 291/ 291]            layers.31.ffn_norm.weight -             4096, type =    f32, size =    0.016 MB
llama_model_quantize_internal: model size  = 12853.02 MB
llama_model_quantize_internal: quant size  =  3891.24 MB

main: quantize time = 51255.05 ms
main:    total time = 51255.05 ms
</pre>



<p>馬上來測試一下</p>



<pre class="wp-block-preformatted">$ ./main -m ./models/7B/ggml-model-q4_0.bin -p "Building a website can be done in 10 simple steps:" -n 512</pre>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="2054" height="779" src="https://blog.richliu.com/wp-content/uploads/2023/06/image-2.png" alt="" class="wp-image-5244" srcset="https://blog.richliu.com/wp-content/uploads/2023/06/image-2.png 2054w, https://blog.richliu.com/wp-content/uploads/2023/06/image-2-600x228.png 600w, https://blog.richliu.com/wp-content/uploads/2023/06/image-2-768x291.png 768w, https://blog.richliu.com/wp-content/uploads/2023/06/image-2-1536x583.png 1536w, https://blog.richliu.com/wp-content/uploads/2023/06/image-2-2048x777.png 2048w" sizes="(max-width: 2054px) 100vw, 2054px" /></figure>



<p>這中間請注意 system info 這一行，如果 CPU hardware support 沒有打開請記得檢查系統</p>



<p>system_info: n_threads = 16 / 32 | AVX = 0 | AVX2 = 0 | AVX512 = 0 | AVX512_VBMI = 0 | AVX512_VNNI = 0 | FMA = 0 | <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">NEON = 1 | ARM_FMA = 1</mark></strong> | F16C = 0 | FP16_VA = 0 | WASM_SIMD = 0 | BLAS = 0 | SSE3 = 0 | VSX = 0 |</p>



<h2 class="wp-block-heading">Chinese LLaMa 2 Alpace 專案</h2>



<p>上面的步驟只需要安裝相關 python 套件和下載 llama.cpp 即可，Chinese LLaMa 2 建議可以下載 alpaca 13b-16K 模型先試玩，這個交談的效果比較好<br />以下路徑和上一部份稍有不同，請自行腦補進行切換，不再說明</p>



<pre class="wp-block-preformatted"># 從 hugingface 直接下載模型
git lfs install
git clone https://huggingface.co/ziqingyang/chinese-alpaca-2-13b-16k

# 轉檔，會輸出 ggml-model-f16.gguf
python llama.cpp/convert.py chinese-alpaca-2-13b-16k/

# 轉成 q5_0 (看起來品質和速度相對好的)
llama.cpp/quantize chinese-alpaca-2-13b-16k/ggml-model-f16.gguf ./llama.cpp/models/alpaca-2-13b-16k-q5_0.bin q5_0
</pre>



<p>接下來就可以直接執行 demo 程式</p>



<pre class="wp-block-preformatted">$ ./main -m models/alpaca-2-13b-16k-q5_0.bin --color -f prompts/al
paca.txt -ins -c 2048 --temp 0.2 -n 256  --repeat_penalty 1.1 -t `nproc`
# 如果 CPU 太多，要限制在 numa 0 跑，本例限制 70 cores 執行
$ numactl -m 0 -N 0 ./main -m models/alpaca-2-13b-16k-q5_0.bin --color -f prompts/al
paca.txt -ins -c 2048 --temp 0.2 -n 256  --repeat_penalty 1.1 -t 70</pre>



<p>輸出是繁中，這個輸出品質還可以</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="2136" height="763" src="https://blog.richliu.com/wp-content/uploads/2023/10/image.png" alt="" class="wp-image-5382" srcset="https://blog.richliu.com/wp-content/uploads/2023/10/image.png 2136w, https://blog.richliu.com/wp-content/uploads/2023/10/image-600x214.png 600w, https://blog.richliu.com/wp-content/uploads/2023/10/image-768x274.png 768w, https://blog.richliu.com/wp-content/uploads/2023/10/image-1536x549.png 1536w, https://blog.richliu.com/wp-content/uploads/2023/10/image-2048x732.png 2048w" sizes="(max-width: 2136px) 100vw, 2136px" /></figure>



<h2 class="wp-block-heading">Chinese-llama-alpaca 專案</h2>



<p>Chinese-llama-alpacen 開源了<strong>中文LLaMA模型和指令精調的羊駝大模型</strong>。這些模型<strong>在原版LLaMA的基礎上補充了中文詞表</strong>並使用了中文數據進行二次預訓練，進一步提升了中文基礎語義理解能力。該網站已經將技術資料放在 Arxiv.org 上面 <a href="https://arxiv.org/abs/2304.08177" target="_blank" rel="noreferrer noopener">Efficient and Effective Text Encoding for Chinese LLaMA and Alpaca</a>. </p>



<p>我選擇用的是中文 Alpaca 模型，在說明內，合併需要動合拼中文LLaMA和 Alpaca 模型以及原始 LLaMA 模型，這邊只建議下載 7B Plus 和 13B Plus ，其他暫時沒有必要玩（註：除非出了 33B Plus or 65B Plus ）</p>



<p>第一步，到<a href="https://github.com/ymcui/Chinese-LLaMA-Alpaca#%E6%A8%A1%E5%9E%8B%E4%B8%8B%E8%BD%BD" target="_blank" rel="noreferrer noopener">模型下载</a>下載需要的模型，我是放在 models 下，取名叫<br />ALPACA_7B_ZH/<br />ALPACA_13B_ZH/<br />LLAMA_7B_ZH/<br />LLAMA_13B_ZH/</p>



<h3 class="wp-block-heading">合併模型</h3>



<p>看命令就好了，code is instructions </p>



<pre class="wp-block-preformatted"># 7B model 
python /nvme/llama/transformers/src/transformers/models/llama/convert_llama_weights_to_hf.py \
    --input_dir models/ \
    --model_size 7B \
    --output_dir models-7b


python /nvme/llama/Chinese-LLaMA-Alpaca/scripts/merge_llama_with_chinese_lora.py \
    --base_model models-7b \
    --lora_model models/LLAMA_7B_ZH,models/ALPACA_7B_ZH \
    --output_type pth \
    --output_dir zh-models-7b
python convert.py zh-models-7b

# 13B model 
python /nvme/llama/transformers/src/transformers/models/llama/convert_llama_weights_to_hf.py \
    --input_dir models/ \
    --model_size 13B \
    --output_dir models-13b


python /nvme/llama/Chinese-LLaMA-Alpaca/scripts/merge_llama_with_chinese_lora.py \
    --base_model models-13b \
    --lora_model models/LLAMA_13B_ZH,models/ALPACA_13B_ZH \
    --output_type pth \
    --output_dir zh-models-13b

python convert.py zh-models-13b
</pre>



<p>這樣就大功告成了，那我們先來轉個 13b 的檔試試看效果如何？</p>



<pre class="wp-block-preformatted">./quantize ./zh-models-13b/13B/ggml-model-f16.bin ./zh-models-13b/13B/ggml-model-q5_0.bin q5_K
(略)
[ 363/ 363] layers.39.ffn_norm.weight - 5120, type = f32, size = 0.020 MB
llama_model_quantize_internal: model size = 25177.25 MB
llama_model_quantize_internal: quant size = 8933.81 MB

main: quantize time = 106859.36 ms
main: total time = 106859.36 ms</pre>



<p>然後下個簡單的命令執行並且測試</p>



<pre class="wp-block-preformatted">./main -m zh-models-13b/13B/ggml-model-q5_0.bin --color -f prompts/alpaca.txt -ins -c 2048 --temp 0.2 -n 256&nbsp; --repeat_penalty 1.1 -t `nproc --ignore=2`<br /></pre>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1631" height="138" src="https://blog.richliu.com/wp-content/uploads/2023/06/image-4.png" alt="" class="wp-image-5247" srcset="https://blog.richliu.com/wp-content/uploads/2023/06/image-4.png 1631w, https://blog.richliu.com/wp-content/uploads/2023/06/image-4-600x51.png 600w, https://blog.richliu.com/wp-content/uploads/2023/06/image-4-768x65.png 768w, https://blog.richliu.com/wp-content/uploads/2023/06/image-4-1536x130.png 1536w" sizes="(max-width: 1631px) 100vw, 1631px" /></figure>



<p>普普通通</p>



<h3 class="wp-block-heading">33B </h3>



<p>之前 33B 的中文頗差，最近更新了 33B 的 LLAMA Plus 和 ALPACA 33B Pro 模型，想說來試用一下是不是到堪用等級，以下是合併的命令</p>



<pre class="wp-block-preformatted">python /nvme/llama/Chinese-LLaMA-Alpaca/scripts/merge_llama_with_chinese_lora.py \
    --base_model models-33b \
    --lora_model models/LLAMA_33B_ZH,models/ALPACA_33B_ZH \
    --output_type pth \
    --output_dir zh-models-33b

# Convert to .bin
python convert.py zh-models-33b/

# use q5_0 as model
./quantize ./zh-models-33b/ggml-model-f16.bin ./zh-models-33b/ggml-model-q5_0.bin q5_0
</pre>



<p></p>



<h2 class="wp-block-heading">其他</h2>



<p>如果碰到類似以下的訊息，或是許法讀取 model ，請檢查 model 的 md5 checksum 是否正確，另外也將 llama.cpp 升級（或是降級），或是不要使用某些支援，我曾經碰過類似的問題，重新編譯時拿掉對 OpenBIAS 就好了</p>



<p>Unexpected Termination due to std::runtime_error during model load in llama.cpp</p>



<p>希望這篇對有興趣的人有些小幫助可以快速進入這個世界（然後快速的逃走）</p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2023/06/23/5241/llama-%e5%bf%83%e5%be%97/">LLaMA 心得</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.richliu.com/2023/06/23/5241/llama-%e5%bf%83%e5%be%97/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Run Keras or TensorFlow in WSL2 with Nvidia GPU</title>
		<link>https://blog.richliu.com/2023/06/23/5238/run-keras-or-tensorflow-in-wsl2-with-nvidia-gpu/</link>
					<comments>https://blog.richliu.com/2023/06/23/5238/run-keras-or-tensorflow-in-wsl2-with-nvidia-gpu/#respond</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Fri, 23 Jun 2023 07:17:00 +0000</pubDate>
				<category><![CDATA[AI]]></category>
		<category><![CDATA[CUDA]]></category>
		<category><![CDATA[gpu]]></category>
		<category><![CDATA[Keras]]></category>
		<category><![CDATA[Nvidia]]></category>
		<category><![CDATA[Tensorflow]]></category>
		<category><![CDATA[WSL2]]></category>
		<guid isPermaLink="false">https://blog.richliu.com/?p=5238</guid>

					<description><![CDATA[<p>When this article is finished, it will still be unable  [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2023/06/23/5238/run-keras-or-tensorflow-in-wsl2-with-nvidia-gpu/">Run Keras or TensorFlow in WSL2 with Nvidia GPU</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>When this article is finished, it will still be unable to run Keras or TensorFlow within Conda or a virtual environment. This is because TensorFlow/Keras will display an error message similar to the one below (cut):</p>



<pre class="wp-block-preformatted">Node: 'model_3/conv1d_24/Conv1D' 
DNN library is not found. 	 [[{{node model_3/conv1d_24/Conv1D}}]] [Op:__inference_train_function_34509]</pre>



<p>It seems that there may be compatibility issues between the versions of TensorFlow/Keras installed outside of Conda and those installed within Conda. But it maybe also cause by tensorflow 2.12 has issue, please re-install 2.10 and try again . <br />Specified version can work well cuDNN 8.9, CUDA 11.8 and TensorFlow 2.10. <br />Here is how to re-install tensorflow 2.10 instruction.<br /></p>



<span id="more-5238"></span>



<pre class="wp-block-preformatted">pip uninstall tensorflow
pip install tensorflow-gpu
pip install tensorflow-gpu==2.10 </pre>



<p><br />ref. <br /><a href="https://github.com/tensorflow/tensorflow/issues/60101" target="_blank" rel="noreferrer noopener">TensorFlow 2.12.0 WSL2 GPU support</a></p>



<p>Have tried someother way, all of them doesn&#8217;t work when you use 2.12 tensorflow. Don&#8217;t try this. ex:</p>



<pre class="wp-block-preformatted">sudo cp cuda/include/cudnn*.h   /anaconda3/envs/&lt;your environment here&gt;/include
sudo cp cuda/lib64/libcudnn*    /anaconda3/envs/&lt;your environment here&gt;/lib
sudo chmod a+r /usr/local/cuda/include/cudnn*.h    /anaconda3/envs/&lt;your environment here&gt;/lib/libcudnn*</pre>



<p>ref.<br /><a href="https://stackoverflow.com/questions/55256671/how-to-install-latest-cudnn-to-conda" target="_blank" rel="noreferrer noopener">How to install latest cuDNN to conda?</a></p>



<h2 class="wp-block-heading">Install</h2>



<h3 class="wp-block-heading">CUDA</h3>



<p>Suppose it already install WSL2 on your system, please follow the <a href="https://docs.nvidia.com/cuda/wsl-user-guide/index.html" target="_blank" rel="noreferrer noopener">CUDA on WSL User Guide</a> to install WSL, for Tensorflow 2.12, suggestion CUDA version is 11.8. <a href="https://developer.nvidia.com/cuda-11-8-0-download-archive?target_os=Linux&amp;target_arch=x86_64&amp;Distribution=WSL-Ubuntu&amp;target_version=2.0&amp;target_type=deb_local" target="_blank" rel="noreferrer noopener">Can be found here CUDA Toolkit 11.8 Downloads</a></p>



<pre class="wp-block-preformatted">wget https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/cuda-wsl-ubuntu.pin
sudo mv cuda-wsl-ubuntu.pin /etc/apt/preferences.d/cuda-repository-pin-600
wget https://developer.download.nvidia.com/compute/cuda/11.8.0/local_installers/cuda-repo-wsl-ubuntu-11-8-local_11.8.0-1_amd64.deb
sudo dpkg -i cuda-repo-wsl-ubuntu-11-8-local_11.8.0-1_amd64.deb
sudo cp /var/cuda-repo-wsl-ubuntu-11-8-local/cuda-*-keyring.gpg /usr/share/keyrings/
sudo apt-get update
sudo apt-get -y install cuda</pre>



<h3 class="wp-block-heading">cuDNN</h3>



<p>It still needs to install CUDNN, follow this instruction to download CUDNN 8.9.x, <a href="https://docs.nvidia.com/deeplearning/cudnn/install-guide/index.html#install-linux" target="_blank" rel="noopener">Installing cuDNN on Linux</a>. Download cuDNN needs to register Nvidia account. <br />Download address : <a href="https://developer.nvidia.com/rdp/cudnn-download" target="_blank" rel="noreferrer noopener">cuDNN Download</a>, it has cuDNN for CUDA 12 and CUDA 11, download for CUDA 11. </p>



<h3 class="wp-block-heading">Add Path to System Path</h3>



<p>Put following seting into ~/.bashrc, thus it can update when get bash console </p>



<pre class="wp-block-preformatted">export PATH=/usr/local/cuda/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH</pre>



<h3 class="wp-block-heading">Follow tensorflow install guide to install tensorflow.</h3>



<p><a href="https://www.tensorflow.org/install/pip#windows-wsl2_1" target="_blank" rel="noreferrer noopener">Tensorflow step by step instructions for WSL2</a></p>



<h2 class="wp-block-heading">Python Virtual Environment</h2>



<p>if use virtual venv, it also can work, just need to install right version tensorflow. and it needs to configure cuDNN path on activate script </p>



<pre class="wp-block-preformatted">vim &lt;path to venv&gt;/bin/activate

# After get VIRTUAL_ENV, include the CUDNN path
export VIRTUAL_ENV

CUDNN_PATH=$(dirname $(python -c "import nvidia.cudnn;print(nvidia.cudnn.__file__)"))
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$VIRTUAL_ENV/lib/:$CUDNN_PATH/lib
</pre>



<h2 class="wp-block-heading">Reference</h2>



<p><a href="https://hackmd.io/@Kailyn/HkSTXL9xK" target="_blank" rel="noreferrer noopener">WSL2 安裝 CUDA Toolkit、cuDNN</a></p>



<p><br /></p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2023/06/23/5238/run-keras-or-tensorflow-in-wsl2-with-nvidia-gpu/">Run Keras or TensorFlow in WSL2 with Nvidia GPU</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.richliu.com/2023/06/23/5238/run-keras-or-tensorflow-in-wsl2-with-nvidia-gpu/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Generative AI(生成式AI)/ChatGPT</title>
		<link>https://blog.richliu.com/2023/04/22/5185/generative-ai-chatgpt/</link>
					<comments>https://blog.richliu.com/2023/04/22/5185/generative-ai-chatgpt/#respond</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Sat, 22 Apr 2023 08:37:02 +0000</pubDate>
				<category><![CDATA[AI]]></category>
		<category><![CDATA[ChatGPT]]></category>
		<category><![CDATA[Generative AI]]></category>
		<category><![CDATA[LLM]]></category>
		<guid isPermaLink="false">https://blog.richliu.com/?p=5185</guid>

					<description><![CDATA[<p>這篇不是一篇技術文章，而是心得文身為一個曾經利用 AI 來撰寫論文的博士研究生，對於在過去的一年中Genera [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2023/04/22/5185/generative-ai-chatgpt/">Generative AI(生成式AI)/ChatGPT</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>這篇不是一篇技術文章，而是心得文<br />身為一個曾經利用 AI 來撰寫論文的博士研究生，對於在過去的一年中Generative AI（生成式 AI ) 取得了顯著的成就感到些許的驚訝。雖然我沒能早點預見到這股浪潮，但是有幸在這股巨浪來臨之前站穩腳步，避免了在口試時的尷尬和對自己期望的失望。</p>



<p>近期，各種關於 ChatGPT 的文章層出不窮，大家的觀點都非常有道理。然而，我認為是時候分享我的看法，畢竟這個bblog已經存在了十多年，偶爾回顧過去的想法是有趣的，特別是當下和未來預測之間的對比。或許這個 WordPress 博客可以一直維持到我退休，屆時再看看我的看法是否準確。</p>



<span id="more-5185"></span>



<h2 class="wp-block-heading">AI 的發展</h2>



<p>從 CNN/RNN 的出現讓 AI 的應用變得可行，生成式 AI 無疑已成為 Internet/Google 級別的產品。生成式 AI 的最大特點是能根據使用者的輸入生成所需的結果，如輸入提示詞（prompt）來生成一幅畫等。目前主要有兩大類型的應用服務：生成圖像（例如 Midjourney）和Large Language Mode（LLM，大語言模型，例如 ChatGPT）。生成圖像可以讓用戶通過提示詞生成想要的圖像，而對話則將個人助理的概念付諸實現，並賦予其強大的功能。而我個人認為個人助理這方面會是一個主要的發展方向，像是協助閱讀郵件對話整理成重點等等都在此類型的功能之內。</p>



<p>想象一下，每個人都可以以相對便宜的價格（例如 OpenAI 每月 20 美元）擁有一個專業並具有一定水平的個人助理，雖然它會犯錯或是曲解意思，但是只要工作中能應用到 ChatGPT，就可以大幅提高生產力，以這個價格，非常的超值。</p>



<p>近期，Microsoft 推出了 <a href="https://github.com/microsoft/JARVIS" target="_blank" rel="noreferrer noopener">JARVIS</a>（取自鋼鐵俠中的電腦管家名稱，基於 HuggingGPT），旨在將多個 AI 模型集成在一起，自動識別用戶的需求並提供相應的 AI 服務。而 <a href="https://autogpt.net/" target="_blank" rel="noreferrer noopener">AutoGPT </a>則宣稱可以根據任務需求自動分析和執行，幫助用戶達成目標，儘管實際效果可能有限，但是我還是在網友的範例中看出這東西的潛力，如果拿它來蒐集資訊，這會是一個非常好的工具。</p>



<p>對於那些尚未將生成式 AI 作為生產力或產業重要元素的人，現在暫時不需要全力投入。盡管有先行者優勢，但目前還是屬於 OpenAI 或是其它具有大型模型的公司。對一般的使用者而言，Open Source 社群的發現，讓一般的使用者也可以抓住產業變化趨勢，例如拿<a href="https://github.com/Stability-AI/stablediffusion" target="_blank" rel="noreferrer noopener"> Stable Diffusion</a> 算圖就可以大略知道生成式 AI 可以做到什麼地步，而且是家用級的顯示卡就可以算圖，這也算是一種福音。</p>



<h2 class="wp-block-heading">Generative AI 缺點</h2>



<p>優點大家應該都知道，不知道其他的文章也提到不少，這邊就分享一些我認為的生成式 AI 的缺點：</p>



<ol class="wp-block-list">
<li>高昂的運算成本：建立一個 LLM (ChatGPT) 模型需要初期數十億台幣的基礎建設投入，單次生成的成本約在 200 萬到 1200 萬美金之間。這或許還不包括資料清洗、模型產生校正和研發工程師等等的費用，人力成本比起差生模型的成本可能都是小錢。相比之下，生成圖形的成本相對較低，但仍可獲得高品質的圖像。</li>



<li>AI 資料廣度問題：目前 ChatGPT 都有蒐集資料時間的限制，對於新資料，AI 可能需要上網搜尋並閱讀相關資料後才能回答使用者（我這邊非常想用人類這詞）的問題。但現有的 AI 模型往往會對不熟悉的主題胡亂回答。近期，許多新聞報導都在討論 ChatGPT 提供錯誤資訊的問題，甚至有學校用 ChatGPT 的說明來證明自己的優勢，這些都是沒有意義的。</li>



<li>缺乏邏輯能力：LLM 本質上是一種語言模型，能根據輸入生成符合邏輯的答案。然而，這只是算法和模型本身提供的能力，並非真正的邏輯推理。如果 AI 具備邏輯推理能力，那將達到強 AI（能真正取代人類的AI） 的境界，可能對人類構成威脅。</li>



<li>AI 資料正確性：從以前到現在 AI 都有資料正確性的問題。對於專業領域的問題，ChatGPT這種LLM模型往往束手無策。例如，在研究 Rust for Linux kernel driver 時，ChatGPT 提供的答案都是錯誤的。然而，對於一般的 Rust 研究，它表現良好。由於經常遇到這種情況，知道了ChatGPT 在這類工作上無法勝任。儘管 AI 可以幫助使用者更快地探索技術邊界，但如何判斷 AI 提供的資料是否正確仍是一個問題。在程式設計領域，我們可以通過實驗來驗證結果，並且排除掉例外狀況；在 AI 領域時就很難這樣做，我們需要將錯的資料整體後重新讓模型學騽，但是仍然可能無法學習到或是發生其他問題（註：電腦視覺領域也有類似的問題，這也是為什麼是為什麼自動駕駛要有 LiDAR 生成正確的空間資料）</li>
</ol>



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-1 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:100%">
<figure class="wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-1 is-layout-flex wp-block-gallery-is-layout-flex">
<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1106" height="693" src="https://blog.richliu.com/wp-content/uploads/2023/04/ChatGPT_wrong.png" alt="" class="wp-image-5187" srcset="https://blog.richliu.com/wp-content/uploads/2023/04/ChatGPT_wrong.png 1106w, https://blog.richliu.com/wp-content/uploads/2023/04/ChatGPT_wrong-600x376.png 600w, https://blog.richliu.com/wp-content/uploads/2023/04/ChatGPT_wrong-768x481.png 768w" sizes="(max-width: 1106px) 100vw, 1106px" /><figcaption class="wp-element-caption">ChatGPT 不懂由簡至繁(註: GPT-4 懂)</figcaption></figure>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="959" height="815" src="https://blog.richliu.com/wp-content/uploads/2023/04/ChatGPT_RUST.png" alt="" class="wp-image-5186" srcset="https://blog.richliu.com/wp-content/uploads/2023/04/ChatGPT_RUST.png 959w, https://blog.richliu.com/wp-content/uploads/2023/04/ChatGPT_RUST-600x510.png 600w, https://blog.richliu.com/wp-content/uploads/2023/04/ChatGPT_RUST-768x653.png 768w" sizes="(max-width: 959px) 100vw, 959px" /><figcaption class="wp-element-caption">ChatGPT 錯的 Linux driver for Rust 範例</figcaption></figure>
</figure>
</div>
</div>



<ol class="wp-block-list" start="5">
<li>Data License 問題：這個問題對一般使用者來說可能不太敏感，但對軟體工程師而言可能成為一大隱憂。例如，當 ChatGPT-4 提供一個完整的範例時，使用者可能會好奇該範例所使用的授權以及是否可以在商業產品上使用。這些都是未知的。然而，如果你的產品不需要發佈，或只是在內部使用，那麼這些問題可能就不那麼重要了。在之前 Copilot 的公開時，這個問題也曾被提及，隨著越來越多人使用 AI，這個問題顯得愈發嚴重。在之前大家都知道 Software engineer 用的是 stack overflow ，但是至少還是經過工程師加工，但是現在大部份都是 Generative AI 產生，那 License 問題就更重要了。（ 延伸閱讀 <a href="https://www.wired.com/story/stack-overflow-will-charge-ai-giants-for-training-data/" target="_blank" rel="noopener">Stack Overflow Will Charge AI Giants for Training Data</a>）</li>



<li>扭曲加料問題：這個問題應該歸類在錯誤之下。有時，當使用者提供資料給 AI 時，AI 可能會對原意進行扭曲或加料。這可能與語言理解或 AI 生成方式有關。特別提出這個問題是為了提醒大家，儘管 AI 可以幫助校稿，但使用者仍需親自進行最後確認以確保資訊的準確性。</li>
</ol>



<h2 class="wp-block-heading">Google 和 Generative AI</h2>



<p>在 Internet 誕生之後，Google 可以說是其中最重要的里程碑之一。特別提到 Google 的原因是因為它和 ChatGPT 有某種相似之處。然而，兩者最大的區別在於：</p>



<ol class="wp-block-list">
<li>Google 是從簡單到複雜的過程：在 Internet 的早期，網站之間是用超連結（HyperLink，指的是點下去就可以連到另一個網站，現在很少人用這個詞）相互連接的。最初，入口網站以目錄方式提供服務，並提供搜尋功能。由於大家剛接觸網路，所以首頁都設置為入口網站。然而，隨著網絡規模的擴大，使用者變得難以獨自找到網絡上的資料。這時候，搜尋引擎便派上了用場。Google 的 PageRank 技術提高了有用網站的排名，增加了資料的可用性。從那時起，Google 逐漸取代了入口網站，成為了 Internet 世界的霸主。</li>



<li>Generative AI 是從複雜到簡單：現在，由於 SEO（Search Engine Optimization 搜尋引擎最佳化）的影響，我們在 Google 搜尋結果中常常找不到想要的資料，或者需要翻閱很多頁才能找到。而如今，我們只需向 ChatGPT 提問，它大部分時間給出的答案都是正確的，甚至有時還能提供超出我們意料之外的答案。這樣一來，與 Google 打交道的時間大大縮短了。</li>
</ol>



<p>然而，Google 和 Generative AI 都存在相同的問題。眾所周知，從 Google 獲得的資料常常有問題，即使是來自 Stack Overflow 的資料，也不一定能解決你的問題。另一個常見的例子是醫學資訊，對於這部分，使用 Google 搜尋可能會找到很多不同資料，這些資料提供的處理方法各異。因此，在這方面，我們通常只能了解個大概，並依賴醫生解決問題。</p>



<p>同樣的情況也會出現在 Generative AI 上，我們讓 Generative AI 為我們完成某些任務，然後再驗收成果。然而，目前我們可以預見到，對於複雜的命令，我們可能也難以驗證其正確性，這可能成為一個潛在問題。或許解決方案是像 Bing AI 那樣提供參考資料的網站，讓人類進行驗證。總之，仍然需要進行查核的工作。</p>



<p>不論是 Google 或 Generative AI，都無法完全保證提供的資訊的正確性。在使用這些工具時，我們需要保持警惕，並在必要時進行人工核對。隨著 AI 技術的不斷發展，未來或許能找到更好的解決方案來提高資訊的可靠性和準確性。然而，直到那時，我們仍需要依賴人類的智慧和判斷力來確保資訊的準確無誤。（註：本段是 GPT-4 憑空加入的，特別留下）</p>



<h3 class="wp-block-heading">生成式資料對抗 Google 和 Generative AI</h3>



<p>Google 近年面臨的一個困境可能是過多的 SEO 網站導致其搜尋結果的可信度降低。這些網站使用消費者常用的搜尋關鍵字，並根據這些關鍵字生成相關或無關的內容。</p>



<p>有些網站劣質地抄襲其他網站的內容，但經過 SEO 優化後，它們的排名卻高於原始網站，導致劣幣驅逐良幣的現象。有些甚至只有關鍵導引流量進去，內容都是無關的資料或是沒有內容。</p>



<p>如今 Generative AI 的出現使得更多看似內容合理的網站充斥網絡。由於這些網站的生成速度快、資料量大，Internet 上的充滿著生成式資料的網站，而這些網站經常在 Google 搜尋排名中名列前茅，使得 Google 搜尋的有效性進一步下降。在這種情況下，人們可能更願意直接向 ChatGPT 詢問問題，而不是翻閱 Google 搜尋結果的多個頁面。</p>



<p>下一代 Google 和 ChatGPT 都可能會使用相似的技術來識別高度 SEO 化和高度資料生成化的網站。然而，SEO 技術也可能會相應地升級以對抗這些新方法。未來發展難以預料，但個人認為搜尋可能會逐漸向 Generative AI 方向發展。畢竟，在過濾資訊方面，Generative AI 至少可以直接提供一個答案，而不是像 Google 一樣給出許多網站讓使用者過濾，這樣可以減少對大腦的負擔，如果 Generative AI 找不到再回去找 Google，這個態勢應該很快就會發生，或許這會是 Google 的惡夢，看看接下來 Google 能不能有效反擊了。</p>



<h2 class="wp-block-heading">工作流程半自動化的時代</h2>



<p>社會進步的基石是將計算能力轉換為生產力。早期的 Word/Excel 時代已經證明了這一點，通過滑鼠操作，可以輕鬆地生成統計數字和圖表。許多小型企業便可以利用 Excel 計算成本和營收。電子郵件減少了公文往來的時間和打電話的成本，釋放出來的時間可以用來提高生產力。隨著網絡購物的興起、Google 等搜尋引擎的發展以及 Food Panda/Uber Eats 等服務的出現，人們節省了大量時間。</p>



<p>Generative AI 正是利用計算能力換取生產力的典範，而且效果顯著。想象一下，一個專業的助手每月花費不到一千元台幣，這是多麼划算。Generative AI 至少可以做到以下幾點（但不限於）：</p>



<ol class="wp-block-list">
<li>繪圖，程式設計，即使不能完全符合需求，也能接近要求，大幅減少製作開發時程</li>



<li>翻譯</li>



<li>查找資料</li>



<li>進行基本研究，堆砌想法</li>



<li>協助除錯，如取代黃色小鴨除錯法</li>



<li>校對稿件</li>
</ol>



<p>這種將計算能力轉換為生產力的方式是顯而易見的。人們導入 Generative AI已經不是考慮需不需要，而是如何導入，或是在更成熟的時候導入的問題。</p>



<p>Generative AI 最終將實現工作流程的半自動化。至於為什麼不是全自動化，稍後會解釋。因為 Generative AI 並不能產生完全正確的資料，人類仍然需要在中間或最後進行把關。這也引出了一個值得思考的問題：如果 Generative AI 能夠實現全自動化，人類的角色將會是什麼？</p>



<h2 class="wp-block-heading">Model as a service(MAAS,模型即服務) 的未來展望</h2>



<p>（註：這段我覺得原來太短，讓 GPT-4 擴充一下，感覺好像論文呀）</p>



<p>MAAS可以說是平台即服務（Platform as a service, PAAS）和軟體即服務（Software as a service, SAAS）的延伸，它將模型視為平台或軟體。這種模式對於大型語言模型商用具有很大的潛力，因為這些模型需要強大的計算能力來運作。</p>



<p>目前即使是小型大語言模型也需要約 24GB 的顯示卡記憶體，這相當於兩張消費級顯示卡。而像 OpenAI 這樣的大型語料庫，所需的建模運算能力更是驚人，可能需要上萬張A100運算（註：A100需要45萬台幣，每 4~6 張還需要一台20~40萬伺服器）。除了運算能力的需求，這些大型模型還需要大量的資料清洗、整理和人力糾正語料庫資料。這樣的需求遠遠超出了一般小型企業或個人的負擔範疇。</p>



<p>隨著技術的發展，我們可以預期 MAAS 將成為未來的趨勢。通過將模型視為一種服務，企業和個人可以將其資源集中在其他方面，同時享受強大的生成式 AI 模型帶來的好處。</p>



<p>未來，MAAS 可能會涵蓋各種領域，包括但不限於自然語言處理、圖像生成、語音識別等。此外，隨著各種模型的發展，我們可能會看到更多針對特定領域的專業模型，這將大大提高這些模型在特定行業中的應用價值。</p>



<p>總之，隨著生成式 AI 技術的發展，MAAS 有望成為一個強大且實用的解決方案，讓企業和個人能夠充分利用這些先進的技術，以提高生產力和創新能力。</p>



<h2 class="wp-block-heading">優質內容的重要性與挑戰</h2>



<p>（註：本段上半部是我寫的，下半部是 GPT-4 延伸的）</p>



<p>隨著生成式 AI 的興起，我們不再缺乏內容，但優質內容卻越來越難以尋找。生成式 AI 的出現使得內容呈指數型增長，然而這卻同時帶來了難以區分原創和 AI 生成內容的問題。雖然許多文章看似精彩，但讀者可能會感覺到一種相似的套路，甚至具有一定的 AI 味道。像有個微信的帳號叫碧樹西風，他的文章每篇看起來就是都有模有樣，但是看久了就有一種 AI 味跑出來，我猜可能就是將概念抽取出來之後，找助手疏理過後再丟去 AI 產生的的文字，亦或是沒有丟 AI ，但是 AI 本身就是可以替代助手的工作，所以也就變成那個味道了。</p>



<p>儘管如此，生成式 AI 在天氣、金融報導等領域已經取得了不錯的成果，未來新聞產生也可能採用類似的技術。然而，生成式 AI 仍然無法滿足人類對優質內容的需求，因為其生成能力依賴於資料庫的品質。要獲得真正的優質內容，人類仍需要付出努力和資源。</p>



<p>依目前的使用者習慣，目前大部分人並不需要高品質的內容，這可以從短影片平台如抖音的流行中看出。儘管如此，優質內容仍然具有重要價值，書籍是其最佳來源之一。寫書仍然是一個具有吸引力的商業模式，讀者可以通過購買書籍獲得經過整理的系統性知識。例如，花費 500 元購買一本書，可以獲得作者精心整理的知識，相當划算。此外，不想買書讀者還可以選擇前往圖書館借閱書籍。</p>



<p>儘管書籍在當今時代仍然是優質內容的重要來源，但許多人可能會誤以為只需依賴 AI，就不再需要書籍。然而，這種觀念在 Google 時代已經被證明是錯誤的。我們需要意識到，優質內容對於學習和發展仍然具有不可替代的價值，不能僅僅依賴生成式 AI。在追求創新和知識成長的過程中，我們應該珍惜並尋求優質內容，而不僅僅是滿足於表面的內容需求。</p>



<p>因此，在這個充斥著生成式 AI 內容的時代，我們需要更加重視優質內容的挖掘和創作。教育機構、出版社和內容創作者應該強調原創性、深度和獨特性，以提供有益的知識和見解。同時，我們也需要為消費者提供更好的工具和管道，幫助他們在茫茫內容海洋中找到真正有價值的資訊。</p>



<p>在此背景下，AI 技術本身也有潛力成為優質內容挖掘的助力。例如，可以開發新型搜尋引擎和內容推薦系統，利用 AI 智能分析和評估內容質量，為用戶提供更精準和個性化的推薦。此外，AI 也可協助創作者改進他們的作品，提供創意靈感和審稿建議，從而提高內容的質量和多樣性。</p>



<p>總之，隨著生成式 AI 的普及，我們面臨著內容品質的挑戰。為了確保人類繼續獲得有益的知識和見解，我們需要重視優質內容的創作和傳播。這需要教育機構、出版商和創作者共同努力，並利用 AI 技術作為輔助工具，共同為用戶提供更豐富、有深度的內容體驗。</p>



<h2 class="wp-block-heading">詐騙集團利用 AI 的潛在風險</h2>



<p>當今，詐騙集團正利用先進科技迅速創新，以達到更高的詐騙效果。生成式 AI 作為一個強大的工具，很可能被這些犯罪分子利用，甚至形成一個全新的詐騙風險。例如，利用偽造的網站、合成語音或甚至是 AI 生成的聊天機器人來詐騙無辜的受害者。</p>



<p>在未來幾年內，我們可能會看到更多利用生成式 AI 技術的詐騙案例。這些案例可能包括結合生成的影片、語音和大型語言模型來欺騙人類。對於那些尚未意識到生成式 AI 威力的人們，這無疑是一個巨大的威脅。下面這個影片就是利用大語言模型開設一個假的網路商店的過程，而這個過程在有心人的包裝之下非常快的就可以建成一個基本的詐騙產業鍊。（當然正當用途也會更多在此就不討論了）</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="1204" height="896" src="https://blog.richliu.com/wp-content/uploads/2023/04/Fake_AI_Taobao.png" alt="" class="wp-image-5188" srcset="https://blog.richliu.com/wp-content/uploads/2023/04/Fake_AI_Taobao.png 1204w, https://blog.richliu.com/wp-content/uploads/2023/04/Fake_AI_Taobao-600x447.png 600w, https://blog.richliu.com/wp-content/uploads/2023/04/Fake_AI_Taobao-768x572.png 768w" sizes="(max-width: 1204px) 100vw, 1204px" /><figcaption class="wp-element-caption"><a href="https://www.bilibili.com/video/BV15v4y1E7zV/" target="_blank" rel="noreferrer noopener">【36氪】我用AI开了家“假”淘宝店，居然真的有人下单？</a></figcaption></figure></div>


<p>然而，值得注意的是，許多公司和研究機構（如 OpenAI）正在努力對 AI 生成的內容進行審查，以防止其被惡意利用。這表明，在短期內，我們可能不會立即面臨成熟的 AI 詐騙模型。但這並不意味著我們可以放鬆警惕。</p>



<p>為了應對這些潛在的風險，政府、企業和個人都需要提高對生成式 AI 應用的認知。同時，AI 研究者和開發者應該關注生成式 AI 的潛在風險，並努力尋求減少不良影響的方法。這可能包括改進生成模型的安全性，以防止被惡意操控，以及開發能夠識別和過濾惡意 AI 生成內容的技術。</p>



<h2 class="wp-block-heading">李家同：競爭的問題</h2>



<p>（註：本段不知道為什麼 GPT-4 都無法校稿，都亂改，只能自己來了）</p>



<p>最近在臉書上看到很多人嘲笑李家同，主要是針對他的觀點『我們要創造不會思考的下一代？』在網路上引起了不少的爭議。雖然我不太同意他的觀點，但是在這裡，我想稍微談談這個問題。</p>



<p>例如我現在要用 ChatGPT 寫個 Python 作業，只要給了prompt，可能大部份的演算法作業都可以靠 ChatGPT 完成（註：讓 ChatGPT 找到演算法，並非是 ChatGPT 自己寫）。但是實際上，我們這一代在學校學習的時候，這部份都是自己手刻完成的。儘管手刻會比較慢，但這能讓我們對演算法有更深刻的認識，如果學校在這部份使用 ChatGPT 教學，就少了這部份打底的工作。</p>



<p>然而，現今很多新技術都是建立在前人的肩膀上，有時我們不需要再去學習太多東西，而是站在這些演算法之上建立新東西。以 C 語言為例，最早我學習電腦的時候，學程式都要學習 C 語言，如果要能夠精確的最佳化程式碼，那還要學習 Assembly code ，而且當年學習 Assembly code 還不夠，指令最佳化還要算到 instructions 的 timing。但是現在的情況已經不同了，現今的程式語言越來越高階，以 Python 為例，相較於 C 語言，Python 可以用更少的程式碼完成同樣的事情，而且 C 語言所需的指令最佳化等等複雜問題也不再是現今所需要考慮的問題，Compiler 都會協助完成所有的事情。在寫出程式這件事情上，python 的速度的是 C 的很多倍，而 python 本身效率的問題可以用暫時加機器達成這個目的。</p>



<p>但是在 python 的程式設計師能順利寫作的前提下，還是需要優秀的底層的工程師去發想並且進行各種最佳化 python 背後需要的技術，而擴展雲端設備之後的架構演算法也是需要紮實的基礎訓練，像是電腦系統架構，Assembly ，compiler ，network 等等知識，而這些東西剛剛好就是靠 ChatGPT 所無法完成的，需要自己一步一腳印的將基礎打好。甚至有些程式碼都是要非常熟悉這些演算法和電腦架構的人才改得動，ChatGPT 是幫不了任何忙的，這時候李家同講的是不是對的？（註：LLM 告訴你的都是他已知的，如果要走向未知還是要自己想，不過 LLM 最大的好處是可以幫忙發想新點子）</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="916" height="1086" src="https://blog.richliu.com/wp-content/uploads/2023/04/ChatGPT_Assembly.png" alt="" class="wp-image-5189" srcset="https://blog.richliu.com/wp-content/uploads/2023/04/ChatGPT_Assembly.png 916w, https://blog.richliu.com/wp-content/uploads/2023/04/ChatGPT_Assembly-506x600.png 506w, https://blog.richliu.com/wp-content/uploads/2023/04/ChatGPT_Assembly-768x911.png 768w" sizes="(max-width: 916px) 100vw, 916px" /><figcaption class="wp-element-caption">ChatGPT 不知道組語寫什麼</figcaption></figure></div>


<p>但是時代的火車是不留情的，所以李家同講的這些雖然是對的但是沒有用，Generative AI 終將會輾壓過去，能做李家同講的那些事情的人就變得鳳毛麟角，不過我想社會會自己調整，可能還是有人對這件事有興趣只是比較少而已，輪子還是有人造只是種類變少。當然也有一種可能就是大家不重視基礎只重視符號政治，政治凌駕專業，然後大家就將自己搞得愈來愈慘，這也是有可能的，畢竟改變不見得都是變好的。我想合理的狀況就是雖然互有消長，但是 LLM 最終還是幫助人類社會進步較多，畢竟我們已經踏在這些事情上面前進非常多步了。</p>



<p>最後來談談那些被科技所輾壓的人。如今的學生從小學就能接觸到網路，因此很多資訊都可以從網路上獲得。理想情況下，網路能夠彌平城鄉差距，事實上也有一些成功案例，例如沈芯菱。然而，媒體往往忽略了更多的負面效應。例如，網路讓性犯罪者能夠接觸到更多原本無法接觸的國中小學生，或者像近來一種名為繭居族的族群。我們熟悉日本文化的人知道，在日本這種情況很常見，但在現今的台灣國中小學生中也越來越普遍。這些孩子通常需要更多家庭資源，但因為缺乏家庭資源，最終卻將自己封閉在網路世界中，變成拒學症的受害者。當然我們不說網路害了他，但是網路讓他們有在家不出門的理由，科技帶來的便利和社會資源讓這些孩子從小封閉自己，失去了謀生和取得基本學歷的機會。這將成為未來的另一個社會問題。當我們的時代火車疾馳向前，是否有人能回頭關注那些被拋下的人呢？</p>



<p>然而，在這個時代的火車輾過後，真的有人會花時間去關心這些被科技輾壓過去的人嗎？其實只有像李老先生這樣的人才會真正關心他們。作為網路發展初期就接觸這些事情滿懷希望，到網路已經影響人類生活看到某些陰暗面的我們這一代人，應該在某種程度上也能理解李老先生此刻可能的想法吧。</p>



<h2 class="wp-block-heading">沒有結論的結尾</h2>



<p>這篇文章主要是闡述一些感想，畢竟它只是記錄了某個時間點的觀察。以下是一位對岸網友使用 GPT-4 分析會被影響工作的總結：大部分容易被取代的工作都是具有固定模式的。通過總結，我們大概可以了解大型語言模型將對哪些行業產生威脅。例如，程式設計師的被替代概率很高，但這是否意味著程式設計的應用門檻也降低了？這樣一來，各行各業的滲透率也將提高，因為能寫程式的人比例是固定的，他們可以去從事其他事情。而難以取代的工作幾乎都是需要實際操作的，這意味著未來將更多地屬於藍領工作者。</p>



<p>然而，許多被取代的工作，並非因為使用 AI，我們就可以完全信任 AI 的結果。因為最終仍需人類過濾，AI 只是能降低單一工作的工作量和成本。至於整體工作量，未必會減少。例如，許多翻譯工作都是兼職的，如果成本降低了，那麼他們可能需要尋找更多的兼職工作來彌補收入，但是這樣的影響之下，能提供翻譯的可能變多可能變少，變多就是門檻低大家只需要校稿，變少就是無利可圖，大家去做別的。總之，AI 在某些方面的確帶來了便利，但對於整體工作量和人類在各行業的作用，仍有待觀察。</p>



<p>或許正如黃仁勳所言，現在是 AI 的 iPhone 時代。大家都知道 iPhone 開創了智慧型手機的先河，Generative AI 同樣具有類似的地位。不過目前仍在 Generative 蠻荒年代，或許二十年後回來再在很多事情都會不一樣（希望不會是天網統治世界）。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1774" height="2048" src="https://blog.richliu.com/wp-content/uploads/2023/04/AI_AFFECT_JOB.png" alt="" class="wp-image-5190" srcset="https://blog.richliu.com/wp-content/uploads/2023/04/AI_AFFECT_JOB.png 1774w, https://blog.richliu.com/wp-content/uploads/2023/04/AI_AFFECT_JOB-520x600.png 520w, https://blog.richliu.com/wp-content/uploads/2023/04/AI_AFFECT_JOB-768x887.png 768w, https://blog.richliu.com/wp-content/uploads/2023/04/AI_AFFECT_JOB-1331x1536.png 1331w" sizes="(max-width: 1774px) 100vw, 1774px" /></figure>



<p>最後丟一篇給 GPT-4 評價的結果</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="980" height="663" src="https://blog.richliu.com/wp-content/uploads/2023/04/image.png" alt="" class="wp-image-5195" srcset="https://blog.richliu.com/wp-content/uploads/2023/04/image.png 980w, https://blog.richliu.com/wp-content/uploads/2023/04/image-600x406.png 600w, https://blog.richliu.com/wp-content/uploads/2023/04/image-768x520.png 768w" sizes="(max-width: 980px) 100vw, 980px" /><figcaption class="wp-element-caption">GPT-3.5</figcaption></figure></div>

<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="1058" height="941" src="https://blog.richliu.com/wp-content/uploads/2023/04/image-1.png" alt="" class="wp-image-5200" srcset="https://blog.richliu.com/wp-content/uploads/2023/04/image-1.png 1058w, https://blog.richliu.com/wp-content/uploads/2023/04/image-1-600x534.png 600w, https://blog.richliu.com/wp-content/uploads/2023/04/image-1-768x683.png 768w" sizes="(max-width: 1058px) 100vw, 1058px" /><figcaption class="wp-element-caption">GPT-4</figcaption></figure></div><p>The post <a rel="nofollow" href="https://blog.richliu.com/2023/04/22/5185/generative-ai-chatgpt/">Generative AI(生成式AI)/ChatGPT</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.richliu.com/2023/04/22/5185/generative-ai-chatgpt/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
