AI 浪潮席捲而來的當下,軟體工程師若想不被大浪滅頂,勢必得將它視為助力而非阻力。唯有動心起念、善加運用,才能立於不敗之地。而對第一線的程式開發者來說,面對 AI 可以學習的方向,大致可分成兩個主題:一是人工智慧的 Vibe Coding 開發工具,增益自身的開發能量;二是探索與實作 AI 應用程式,將 LLM(大語言模型)的大腦融入不同的應用情境,開發出新世代的智慧程式。
在軟體開發的過程中,程式框架(Framework)具有將重複性需求規格化、模組化的優點,框架優先的觀念早已在 Web 應用開發中根深蒂固。在 LLM 應用的領域裡,LangChain 則是最具知名度的程式框架,其核心理念是透過它所提供的抽象層,達成不受制於單一 LLM 平台或業者的設計。這本《LangChain 奇幻旅程》不僅讓讀者學到 LangChain 框架的基礎,更進一步介紹 AI 應用開發會觸及的相關技術,像是本地端模型的 Hugging Face、Ollama、RAG 的觀念與實作、LINE Bot 對話機器人,以及極具價值的 Qdrant 向量資料庫基礎運用。
書中不偏袒地將 OpenAI 與 Gemini 這兩個 LLM 領頭羊的實作一併收錄,不論讀者原本採用的是哪一家的方案,都可以直接從書中學到具備即戰力的開發技能。可惜的是,AI 技術一日千里,即便這本書出版至今才約一年半(2024 年 10 月出版),LangChain 的版本已經歷多次更新,書中的程式碼也大多已經過時,得自行花時間查找新版的寫法。幸好身處 AI 時代,在 ChatGPT 這類工具的協助下,相信都能迎刃而解。
不過,對於 AI 應用的開發是否非得採用 LangChain 這樣的框架,目前我還是有點遲疑。以我比較熟悉的 GCP Vertex AI 為例,有一些平台專屬的功能,像是格式化輸出(Structured Output)、Grounding 等,都不包含在 LangChain 基本類別的設定值裡。換言之,如果想使用這些強大的 LLM 功能,就得客製化框架的程式碼;然而,一旦這麼做,就很難再切換到其他 LLM 平台,如此一來,採用框架所追求的平台無關性(Platform Agnostic)也就不復存在了。
With the AI wave sweeping across the software industry, developers who don't want to be left behind need to see AI as an opportunity rather than an obstacle. The key is to embrace it and learn how to use it effectively. For software developers, there are two main directions for learning AI. The first is using AI-powered development tools, such as Vibe Coding, to boost productivity. The second is exploring and building AI applications by integrating the "brain" of LLMs (Large Language Models) into different use cases to create the next generation of intelligent software.
In software development, frameworks help standardize and modularize common requirements, making development more efficient. As a result, the "framework-first" mindset has become deeply rooted in modern web development. In the world of LLM applications, LangChain is probably the best-known framework. Its core idea is to provide an abstraction layer so developers are not tied to a single LLM platform or vendor. This book, LangChain 奇幻旅程 (The Fantastic Journey of LangChain), not only teaches the fundamentals of the LangChain framework, but also introduces many important technologies used in AI application development. These include local models with Hugging Face and Ollama, the concepts and implementation of RAG, LINE Bot development, and the basics of using the Qdrant vector database.
The book presents examples for both OpenAI and Gemini without favoring either one. No matter which LLM platform you are currently using, you can learn practical development skills that are immediately useful. The downside is that AI technology evolves incredibly fast. Although the book was published only about a year and a half ago (October 2024), LangChain has already gone through multiple major updates. Much of the sample code is now outdated, so readers will need to spend some time figuring out the new APIs and coding style. Fortunately, with AI assistants like ChatGPT, updating the code is much easier than it used to be.
That said, I'm still not completely convinced that AI applications must be built on a framework like LangChain. Take GCP Vertex AI as an example. It provides several platform-specific features, such as Structured Output and Grounding, that are not covered by LangChain's standard abstractions. In other words, if you want to take advantage of these advanced LLM features, you'll need to customize the framework. Once you do that, however, switching to another LLM platform becomes much more difficult. As a result, the platform-agnostic design that frameworks like LangChain aim to provide starts to lose its value.

沒有留言:
張貼留言