至於 C++, 我剛好有個網路課程只剩幾個小時沒上完. 正好就今天處理了. 畢竟從天竺轉機回台灣這兩天, 加起來睡不到十小時, 累到幾乎無法思考大事. 這麼難用的時間, 碰上簡單的課程和超簡單的最後一個作業, 真是天作之合. (Adjacency List 那個作業就難多了, 題意說明落落長, class 定義在哪裡要自己找出來).
這門課雖然用到一些 C++, 重點還是講資料結構. 例如: Dijkstra’s algorithm wasn’t able to find the shortest path if edge has negative weight. 翻譯成白話是: 假如我們的工作流程中有人扯後腿, 怎麼優化都會鬼打牆. 基本上這堂課還不錯.
當初會上 Coursera 是為了學 AI. 為了發揮最大投資效益, 我買了一年Plus 會員吃到飽來學習 Tensorflow, LLM, 和其他 AI 的訓練課程. 基本上能選的課, 我聽得差不多了, 甚至還產生了心得. 像是同樣的生成式 AI 課程, Google 版重視 AI 倫理, Amazon 版重視 AWS 生態系實作, IBM 版重視如何用在 project 管理, DeepLearning AI 重視知識完整性等等.
再回溯 Chain of Thought (COT) 和另外一個 Tree of Thought (TOT), 前者也提到chain, 他們和 LangChain 又是甚麼關係呢? 它們都只是輔助 LLM 推理的方法, COT 就是 step by step, TOT 就是找不到方法是會換一條思路. 它們都只是強調推理 (reason) 的部分, 有 action 才會去執行指令, 做成可互動的應用程式 (ReAct) [3].
from jinja2 import Template
# Define the template
DEFAULT_KEYWORD_EXTRACT_TEMPLATE_TMPL = Template(
"Some text is provided below. Given the text, extract up to {{ max_keywords }}"
" keywords from the text. Avoid stopwords.\n"
"---------------------\n"
"{{ text }}\n"
"---------------------\n"
"Provide keywords in the following comma-separated format: 'KEYWORDS: <keywords>'\n"
)
# Generate the prompt
def generate_prompt(text, max_keywords=5):
return DEFAULT_KEYWORD_EXTRACT_TEMPLATE_TMPL.render(text=text, max_keywords=max_keywords)
# Example usage
prompt = generate_prompt("Jinja2 is a popular templating engine in the Python ecosystem.", 3)
print(prompt)
這個 example 輸出的長相如下:
Some text is provided below. Given the text, extract up to 3 keywords from the text. Avoid stopwords.
---------------------
Jinja2 is a popular templating engine in the Python ecosystem.
---------------------
Provide keywords in the following comma-separated format: 'KEYWORDS: <keywords>'