<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by ChunJen Wang on Medium]]></title>
        <description><![CDATA[Stories by ChunJen Wang on Medium]]></description>
        <link>https://medium.com/@chunjen-jimmy?source=rss-2c7cfbfab06------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Hq8o-lIQUhTdV1CNaM7uIw.jpeg</url>
            <title>Stories by ChunJen Wang on Medium</title>
            <link>https://medium.com/@chunjen-jimmy?source=rss-2c7cfbfab06------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 21:25:01 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@chunjen-jimmy/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[什麼是 MCP？]]></title>
            <link>https://medium.com/jimmy-wang/%E4%BB%80%E9%BA%BC%E6%98%AF-mcp-ccacac31ef90?source=rss-2c7cfbfab06------2</link>
            <guid isPermaLink="false">https://medium.com/p/ccacac31ef90</guid>
            <category><![CDATA[mcp-server]]></category>
            <category><![CDATA[anthropic-claude]]></category>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[llm]]></category>
            <dc:creator><![CDATA[ChunJen Wang]]></dc:creator>
            <pubDate>Sat, 16 Aug 2025 06:26:59 GMT</pubDate>
            <atom:updated>2025-10-03T23:56:19.080Z</atom:updated>
            <content:encoded><![CDATA[<p>本文紀錄DeepLearning.ai Anthropic推出的MCP課程筆記。</p><h3><strong>Model Context Protocol (MCP)</strong></h3><p>是 Anthropic 在 <strong>2024 年 11 月 25 日</strong> 推出的開源標準協議，旨在讓大型語言模型（LLMs）可以<strong>一致、標準化地</strong>連接與外部工具、資料來源或系統。它被形容為 AI 世界中的「<strong>USB‑C 接口</strong>」 — 就像 USB‑C 統一了各種設備的接入方式，MCP 也統一了 AI 與外部資源溝通的介面。</p><h4>核心功能與架構</h4><ul><li><strong>標準化</strong>：透過 MCP，開發者只需於LLM或AI Agent實作一次協議，即可連接多種資料源或工具，避免為每個應用單獨開發整合介面。</li><li><strong>雙向且安全的連接</strong>：MCP 支援兩端之間的安全通信，包括資料讀取、工具調用與上下文提示傳遞等。</li><li><strong>技術細節</strong>：採用 JSON‑RPC 2.0 作為通信協議，支援 HTTP 和 stdio 通道，也可透過 SDK 進行能力協商、錯誤處理、記錄等。</li></ul><blockquote><em>一句話說 MCP 就是：</em><strong><em>用一個標準協議讓 LLM 透過同樣格式與外部資料或工具互動，不再重寫每段邏輯。(如下圖)</em></strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/826/1*BofV4zP4tfOZdWmlJYTYcQ.png" /></figure><p>MCP的模式，也讓各種AI Agent，都可以直接與MCP Server互動，而不需要額外客製開發。 <br>→ 這裡的客製開法，是指Google Drive雖然也可以透過API介接，但我們不再需要煩惱如何前處理、帶入參數等功能。<br> → 因為，MCP本身就包含了metadata 描述、支援 capability discovery，這些是為了讓LLM看懂如何調用、何時調用的重要資訊。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/756/1*rcKuc3yYvqmw1itw96C_Sg.png" /><figcaption>各種AI Agent只需要接上MCP Server就可以自由調用後面對應的工具</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/739/1*-4tF0AU7q5APmUc3xe9nlA.png" /><figcaption>GPT-5 對於API與MCP理解的差異比較表</figcaption></figure><h4>MCP（Model Context Protocol）<br>本質上就是一種標準化的 Client-Server 架構</h4><ul><li><strong>Host </strong>= 使用 MCP 的應用程式（像 Claude Desktop、AI Agents）<br>這些是最終想要「查資料」、「執行動作」的應用。</li><li><strong>MCP Client</strong> = 發送指令的一方（在應用程式內）<br>每個 MCP Client 是一個「協議連接器」：它根據 MCP 規格建立連線，發送像 query, get, search 等 request，並接收處理好的結果，給 LLM 使用（可以當作 prompt context）</li><li><strong>MCP Server</strong> = 資料或工具功能的封裝者（如：Google Drive MCP Server），負責接收 request，執行實際的操作（例如查檔案、寫入資料庫），對外只暴露標準化的功能定義與資料格式（像 plugin API）</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/515/1*sj8YO4SJxeptdC9EvdApTA.png" /><figcaption>MCP（Model Context Protocol）<br>本質上就是一種標準化的 Client-Server 架構</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/754/1*t2zOQSgewetHciVP0JpPjw.png" /><figcaption>MCP Client與Server端各自負責的任務</figcaption></figure><p>說穿了MCP Server端也只是將API包一層，讓LLM可以調用，其內部原始功能也許都和原始API一模一樣，而我們也可以針對給LLM使用的Tool function，另外客製開發，讓這個MCP Server上的功能越來越強大。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JzrsaRgl5AYTzAKzoE_j8A.png" /><figcaption>MCP Server上是原始開發者定義的functions</figcaption></figure><blockquote><em>而LLM怎麼知道要如何調用哪一個Tool? <br></em><strong><em>是因為 MCP Server 自我描述了「我會什麼」</em></strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qFeSIjSfo29aQYputF95Ag.png" /><figcaption>MCP Server上預定義好的prompt也可以當作是一種被LLM調用的功能</figcaption></figure><h4>才能夠讓MCP Client 啟動時，「查詢 MCP Server 有哪些 method」</h4><p>且每個方法都有清楚的：</p><ol><li>名稱</li><li>輸入參數格式（含型別）</li><li>行為描述（自然語言描述）</li><li>回傳格式</li></ol><p>這就像 LLM 使用 plugin 或 tool 時，能知道：「我可以呼叫 format 這個工具，輸入是文件 ID，輸出會是 messages。」</p><h4>從API到MCP：</h4><p>1)假設一個function裡面我們使用API方式，可以去搜尋Paper如下:</p><pre>def search_papers(topic: str, max_results: int = 5) -&gt; List[str]:<br>    &quot;&quot;&quot;<br>    Search for papers on arXiv based on a topic and store their information.<br>    <br>    Args:<br>        topic: The topic to search for<br>        max_results: Maximum number of results to retrieve (default: 5)<br>        <br>    Returns:<br>        List of paper IDs found in the search<br>    &quot;&quot;&quot;<br>    <br>    # Use arxiv to find the papers <br>    client = arxiv.Client()<br><br>    # Search for the most relevant articles matching the queried topic<br>    search = arxiv.Search(<br>        query = topic,<br>        max_results = max_results,<br>        sort_by = arxiv.SortCriterion.Relevance<br>    )<br><br>    papers = client.results(search)<br>    <br>    # Create directory for this topic<br>    path = os.path.join(PAPER_DIR, topic.lower().replace(&quot; &quot;, &quot;_&quot;))<br>    os.makedirs(path, exist_ok=True)<br>    <br>    file_path = os.path.join(path, &quot;papers_info.json&quot;)<br><br>    # Try to load existing papers info<br>    try:<br>        with open(file_path, &quot;r&quot;) as json_file:<br>            papers_info = json.load(json_file)<br>    except (FileNotFoundError, json.JSONDecodeError):<br>        papers_info = {}<br><br>    # Process each paper and add to papers_info  <br>    paper_ids = []<br>    for paper in papers:<br>        paper_ids.append(paper.get_short_id())<br>        paper_info = {<br>            &#39;title&#39;: paper.title,<br>            &#39;authors&#39;: [author.name for author in paper.authors],<br>            &#39;summary&#39;: paper.summary,<br>            &#39;pdf_url&#39;: paper.pdf_url,<br>            &#39;published&#39;: str(paper.published.date())<br>        }<br>        papers_info[paper.get_short_id()] = paper_info<br>    <br>    # Save updated papers_info to json file<br>    with open(file_path, &quot;w&quot;) as json_file:<br>        json.dump(papers_info, json_file, indent=2)<br>    <br>    print(f&quot;Results are saved in: {file_path}&quot;)<br>    <br>    return paper_ids</pre><p>當我們執行 search_papers(“computers”) ，就可以回傳以下結果<br># Results are saved in: papers/computers/papers_info.json<br># [‘1310.7911v2’, ‘math/9711204v1’,‘2208.00733v1’, ‘2504.07020v1’]</p><p>課程同理也示範了其他funtions，但我們可以使用一種模式，讓LLM看懂如何取用這些功能。<br>→ Tool Schema</p><pre>tools = [<br>    {<br>        &quot;name&quot;: &quot;search_papers&quot;,<br>        &quot;description&quot;: &quot;Search for papers on arXiv based on a topic and store their information.&quot;,<br>        &quot;input_schema&quot;: {<br>            &quot;type&quot;: &quot;object&quot;,<br>            &quot;properties&quot;: {<br>                &quot;topic&quot;: {<br>                    &quot;type&quot;: &quot;string&quot;,<br>                    &quot;description&quot;: &quot;The topic to search for&quot;<br>                }, <br>                &quot;max_results&quot;: {<br>                    &quot;type&quot;: &quot;integer&quot;,<br>                    &quot;description&quot;: &quot;Maximum number of results to retrieve&quot;,<br>                    &quot;default&quot;: 5<br>                }<br>            },<br>            &quot;required&quot;: [&quot;topic&quot;]<br>        }<br>    },<br>]<br># ...(略)<br><br>mapping_tool_function = {<br>    &quot;search_papers&quot;: search_papers,<br>    &quot;extract_info&quot;: extract_info<br>}<br><br># ...(略)<br>response = client.messages.create(max_tokens = 2024,<br>                              model = &#39;claude-3-7-sonnet-20250219&#39;, <br>                              tools = tools,<br>                              messages = messages)<br># 在這一步就是將Tool打包為LLM能夠看懂，並隨時進行調用的模式，在過去稱之為Tool Calling。</pre><p>2) 但我們可以將其功能，打包為一個MCP Server，讓各個LLM或AI Agent都可以自由調用這組paper搜尋工具。</p><pre>from mcp.server.fastmcp import FastMCP<br><br>mcp = FastMCP(&quot;research&quot;)<br><br>@mcp.tool()<br>def search_papers(topic: str, max_results: int = 5) -&gt; List[str]:<br>    &quot;&quot;&quot;<br>    Search for papers on arXiv based on a topic and store their information.<br>    <br>    Args:<br>        topic: The topic to search for<br>        max_results: Maximum number of results to retrieve (default: 5)<br>        <br>    Returns:<br>        List of paper IDs found in the search<br>    &quot;&quot;&quot;<br>    <br>    # Use arxiv to find the papers <br>    client = arxiv.Client()<br><br>    # Search for the most relevant articles matching the queried topic<br>    search = arxiv.Search(<br>        query = topic,<br>        max_results = max_results,<br>        sort_by = arxiv.SortCriterion.Relevance<br>    )<br><br>    papers = client.results(search)<br>    <br>    # Create directory for this topic<br>    path = os.path.join(PAPER_DIR, topic.lower().replace(&quot; &quot;, &quot;_&quot;))<br>    os.makedirs(path, exist_ok=True)<br>    <br>    file_path = os.path.join(path, &quot;papers_info.json&quot;)<br><br>    # Try to load existing papers info<br>    try:<br>        with open(file_path, &quot;r&quot;) as json_file:<br>            papers_info = json.load(json_file)<br>    except (FileNotFoundError, json.JSONDecodeError):<br>        papers_info = {}<br><br>    # Process each paper and add to papers_info  <br>    paper_ids = []<br>    for paper in papers:<br>        paper_ids.append(paper.get_short_id())<br>        paper_info = {<br>            &#39;title&#39;: paper.title,<br>            &#39;authors&#39;: [author.name for author in paper.authors],<br>            &#39;summary&#39;: paper.summary,<br>            &#39;pdf_url&#39;: paper.pdf_url,<br>            &#39;published&#39;: str(paper.published.date())<br>        }<br>        papers_info[paper.get_short_id()] = paper_info<br>    <br>    # Save updated papers_info to json file<br>    with open(file_path, &quot;w&quot;) as json_file:<br>        json.dump(papers_info, json_file, indent=2)<br>    <br>    print(f&quot;Results are saved in: {file_path}&quot;)<br>    <br>    return paper_ids<br><br># ...(略)<br><br>if __name__ == &quot;__main__&quot;:<br>    # Initialize and run the server<br>    mcp.run(transport=&#39;stdio&#39;)</pre><p>接著就可以透過uv在local啟動MCP server (此處如想實作，請follow原始課程指南。在此不詳述完整指令。)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eGgsN7_zIA220xm0fMNjvw.png" /><figcaption>課程指南提供測試MCP Server架設Demo畫面</figcaption></figure><h4>那LLM與AI Agent又是如何跟MCP Server溝通與連接?</h4><p><strong>第一階段：工具探索階段（Tool Discovery）</strong></p><ul><li>目的：讓 LLM 知道 MCP Server 有哪些功能（tools/prompts）</li><li>LLM 啟動 / Agent 啟動時<br>1) MCP Client 執行 connect_to_server_and_run()<br>發出 ListToolsRequest 給 MCP Server<br>2) MCP Server 回應<br>傳回 ListToolsResult，包含所有工具的：<br>名稱（name）<br>說明（description）<br>參數格式（args schema）<br>回傳格式（optional）<br>3) MCP Client 將這些工具 expose 給 LLM</li><li>透過 prompt 或 function calling 系統，讓模型能看到：「我有這些工具可以用喔！」</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XVSP9eGHg-XUcNdLom4Ofw.png" /><figcaption>MCP Client第一動作，先了解MCP Server有哪些工具，可以如何使用?</figcaption></figure><p><strong>第二階段：執行工具階段（Tool Invocation）</strong></p><ul><li>目的：LLM 判斷需要用某個工具，並實際觸發執行</li><li>LLM 決定使用某個工具<br>例如根據使用者說「幫我把這份文件轉成 Markdown」，模型判斷需要調用 format 工具<br>1) MCP Client 發出 CallToolRequest<br>帶上選定的工具名與參數（如 doc_id=xyz）<br>2) MCP Server 執行並回傳 CallToolResult<br>把工具執行的結果，如一段文字、一組文件、一串 messages 回傳給 MCP Client<br>3) MCP Client 將結果交給 LLM 當作接續 prompt 的 context 或回答基礎</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YC_n8SyDYnXuTxRDfENT5Q.png" /><figcaption>MCP Client開始調用Server端工具，並收到結果接續後續工作</figcaption></figure><h4>發揮MCP真正無遠弗屆的能力</h4><p>課程中也提到，除了自己建設MCP Server，我們還可以調用來自世界各地所開發的MCP Server，甚至是直接使用他人啟動的服務。</p><p><a href="https://github.com/modelcontextprotocol/servers">GitHub - modelcontextprotocol/servers: Model Context Protocol Servers</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HD9_fYzV4jVPAYEf6IDYxw.png" /></figure><p>但要記得在Client端，需要去維護我們可以調用的MCP清單：</p><pre>// find the `server_config.json` <br>// configuration file that has the following structure.  <br>{<br>    &quot;mcpServers&quot;: {<br>        <br>        &quot;filesystem&quot;: {<br>            &quot;command&quot;: &quot;npx&quot;,<br>            &quot;args&quot;: [<br>                &quot;-y&quot;,<br>                &quot;@modelcontextprotocol/server-filesystem&quot;,<br>                &quot;.&quot;<br>            ]<br>        },<br>        <br>        &quot;research&quot;: {<br>            &quot;command&quot;: &quot;uv&quot;,<br>            &quot;args&quot;: [&quot;run&quot;, &quot;research_server.py&quot;]<br>        },<br>        <br>        &quot;fetch&quot;: {<br>            &quot;command&quot;: &quot;uvx&quot;,<br>            &quot;args&quot;: [&quot;mcp-server-fetch&quot;]<br>        }<br>    }<br> }</pre><h4>那為什麼MCP Server上需要有預寫好的Prompt?</h4><ul><li>目的：避免 LLM 每次都要自己「想 Prompt」<br>因為如果 LLM 自己隨機生成，結果會不一致、不穩定。</li><li>MCP Server 提供「標準化 Prompt」，確保輸入高品質且可重複，並將 Prompt 視為「資源」來共用；和 Tool 一樣，Prompt 也可以被不同 LLM、不同 AI Agent 共用。</li></ul><blockquote><strong><em>MCP Server 專門維護 「怎麼問問題」 的最佳實踐。<br>LLM 專注於 「如何回答」。</em></strong></blockquote><p>這樣可以避免 prompt engineering 分散在各 Agent 裡。提高一致性與可測試性。而且Prompt 可以事先驗證（well-tested），像單元測試一樣。保證不同場景下，輸入與輸出都符合預期。</p><h4>MCP課程小結</h4><p><strong>MCP 的角色</strong>，就像 REST 對 Web、LSP 對 IDE 一樣，<br><strong>是 AI 應用的通用語言</strong>：</p><ul><li>REST = 統一了 Web 與後端溝通方式</li><li>LSP = 統一了 IDE 與程式語言工具的溝通方式</li><li>MCP = 統一了 LLM 與外部系統的溝通方式</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/890/1*tXgB9bMlPecTOnZJfjq3qQ.png" /><figcaption>什麼是MCP? 與API, LSP差別是什麼?</figcaption></figure><p><strong>MCP 在 AI 世界的定位，就等於 REST 在 Web 世界、LSP 在 IDE 世界的定位。</strong>它不是在「發明新 API」，而是在「定義標準介面」，讓 <strong>所有 LLM 與AI Agents都能 plug-and-play 使用外部工具與資料源</strong>。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wm1SUbxoggeh-MNAb8iEQA.png" /><figcaption>MCP Server也能夠結合在AI Agent的設計框架</figcaption></figure><p><strong>MCP課程連結(from Deeplearning.ai)</strong></p><p><a href="https://learn.deeplearning.ai/courses/mcp-build-rich-context-ai-apps-with-anthropic/">https://learn.deeplearning.ai/courses/mcp-build-rich-context-ai-apps-with-anthropic/</a></p><p>另外推薦一支在Youtube的影片，內容相當於課程結構，但節奏感可以用比較輕鬆的方式聽(由MCP發明人說明)，但收音就~不太好，中間會有地方是中斷的。</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FkQmXtrmQ5Zg%3Fstart%3D1%26feature%3Doembed%26start%3D1&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DkQmXtrmQ5Zg&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FkQmXtrmQ5Zg%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/06a89b04e5b409924d09e58455d19dcd/href">https://medium.com/media/06a89b04e5b409924d09e58455d19dcd/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ccacac31ef90" width="1" height="1" alt=""><hr><p><a href="https://medium.com/jimmy-wang/%E4%BB%80%E9%BA%BC%E6%98%AF-mcp-ccacac31ef90">什麼是 MCP？</a> was originally published in <a href="https://medium.com/jimmy-wang">jimmy-wang</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[LangChain-02] RAG先備知識：資料格式與VDB]]></title>
            <link>https://medium.com/jimmy-wang/langchain-02-rag%E5%85%88%E5%82%99%E7%9F%A5%E8%AD%98-%E8%B3%87%E6%96%99%E6%A0%BC%E5%BC%8F%E8%88%87vdb-f53a821402f0?source=rss-2c7cfbfab06------2</link>
            <guid isPermaLink="false">https://medium.com/p/f53a821402f0</guid>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[vector-database]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[embedding]]></category>
            <category><![CDATA[langchain]]></category>
            <dc:creator><![CDATA[ChunJen Wang]]></dc:creator>
            <pubDate>Sat, 19 Jul 2025 07:14:48 GMT</pubDate>
            <atom:updated>2025-07-19T07:14:48.815Z</atom:updated>
            <content:encoded><![CDATA[<p>本文參考deeplearning.ai課程與開源文件，希望能以中文形式將Langchain或其他流程內的工具，把RAG一些很重要的基本概念做整理。</p><h3>LangChain重要概念</h3><ol><li>LangChain 資料格式: Document是什麼?</li><li>Text Splitters怎麼實作? 不同方法真的有差?</li><li>Embedding模型在做什麼?</li><li>VDB裡面到底儲存了什麼?</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*aoYD6xovYUR3uRly" /></figure><h3>LangChain 資料格式: Document是什麼?</h3><h4>LangChain Document</h4><p>是將文件上傳後，透過檔案讀取、資料轉換後的透定資料格式，通常是由 Loader 讀取後產生的物件，例如 PDF、Word、網頁、純文字等。</p><p>實際樣貌是 LangChain 定義的 Document 物件格式，表面上看起來像是 List[Document]，每一個 Document 就像是一個 dict，包含兩個欄位：</p><ul><li>page_content: 文件的文字內容（String）</li><li>metadata: 來源資訊、頁碼、文件類型等（Dict）</li></ul><pre>from langchain.document_loaders import PyPDFLoader<br>loader = PyPDFLoader(&quot;你的PDF路徑&quot;)<br>pages = loader.load()<br><br>len(pages)<br># 22<br><br>type(pages)<br># list<br><br>type(pages[0])<br># langchain.schema.Document<br><br>pages[0].dict().keys()  # 取出list中第一個document，轉換成dict，抓出key<br># dict_keys([&#39;page_content&#39;, &#39;metadata&#39;])<br><br>pages[0].page_content[0:100]<br># &#39;MachineLearning-Lecture01  \nInstructor (Andrew Ng):  Okay. Good morning. Welcome to CS229, the machi&#39;<br><br>pages[0].metadata<br># {&#39;source&#39;: &#39;docs/cs229_lectures/MachineLearning-Lecture01.pdf&#39;, &#39;page&#39;: 0}</pre><h3>2. Text Splitters怎麼實作? 不同方法真的有差?</h3><h4>Text Splitter 是什麼？</h4><p>Text Splitter 是 LangChain 中的關鍵元件，負責將一個 Document 的文字內容（page_content）<strong>分割成多個小段 (chunk)</strong>，以便後續進行 Embedding、語意檢索與 RAG 等任務。常見的Spl</p><ol><li>CharacterTextSplitter : 最簡單，就是依據字數長度切斷</li><li>MarkdownHeaderTextSplitter Document-structured based : 第二簡單，依據標題階層定義，通常會使用markdown格式去切，</li><li>RecursiveCharacterTextSplitter Text-structured based：依據定義好的換行符號或句尾切。但不會是「同時嘗試全部 separator」，是曾聽過誤解這個方法的要點。</li></ol><pre># MarkdownHeaderTextSplitter<br># 舉例依據文件結構切段<br>headers_to_split_on = [<br>    (&quot;#&quot;, &quot;Header 1&quot;),<br>    (&quot;##&quot;, &quot;Header 2&quot;),<br>]<br>markdown_splitter = MarkdownHeaderTextSplitter(<br>    headers_to_split_on=headers_to_split_on<br>)<br><br># RecursiveCharacterTextSplitter<br># 舉例依據符號標記切段<br>RecursiveCharacterTextSplitter(<br>    chunk_size=80,<br>    chunk_overlap=0,<br>    separators=[&quot;\n\n&quot;, &quot;\n&quot;, &quot;\. &quot;, &quot; &quot;, &quot;&quot;],<br>    keep_separator=True<br>)<br><br>&#39;&#39;&#39;重要!<br>遞迴切分流程（遞減粒度）：<br>1. 先用第一個 separator（\n\n）試切：把整段文字用 \n\n 拆成幾段<br>2. 檢查每一段是否都 ≤ chunk_size。如果都 OK → 回傳<br>3. 若其中任何一段長度 &gt; chunk_size → 對那段進行下一層 separator 拆分<br>4. 再用第二個 separator（\n）試切那段過長內容<br>5. 重複上述檢查與切分邏輯，然後依序試： \. → &quot; &quot; → &quot;&quot;（最後是逐字切）<br>&#39;&#39;&#39;</pre><p><strong>為什麼需要切割Chunking？<br></strong>因為語言模型（像 OpenAI GPT-4o, 4.1）在上下文長度合適範圍內（如 128k、32k token），直接丟整篇文件容易模糊回答焦點，因此需要把大文件<strong>切成語意相對完整、長度控制在可接受範圍內的區塊</strong>。</p><blockquote><strong><em>這裡要希望釐清一個要點，常會有人將Chunk與Document弄混。</em></strong><em><br>📌 Chunk = Document 嗎？通常操作步驟是這樣的：<br>(1)原始文件（PDF/Word）<br>→ (2)多個 Document（每頁或每段）<br>→ (3)Text Splitter 切分 <br>→ (4)多個 Chunk<br>資料格式都是</em><em>List[Document]但chunking是將文本依據字數／格式／語意把文件段落切割的較小塊，因此Chunk 在技術實作上 = Document（有 page_content 和 metadata）</em></blockquote><h3>3. Embedding模型在做什麼?</h3><h4>Embedding 是什麼？</h4><p>Embedding 是將文字資料轉換成向量（vector）的過程。<br>向量是一組數字（例如 1536 維的浮點數），用來表示該段的<strong>「語意特徵」</strong>。這些向量之間可以計算相似度（如 cosine similarity），用來做語意搜尋、關聯比較、推薦系統等任務。</p><p>在 LangChain 中，每個 Chunk（也就是 Document）都會經過 Embedding 模型處理，轉換成語意向量後送進向量資料庫（VectorStore）儲存，供後續查詢使用。</p><pre>import numpy as np<br>from langchain.embeddings.openai import OpenAIEmbeddings<br>embedding = OpenAIEmbeddings()<br><br>sentence1 = &quot;我喜歡蘋果&quot;<br>sentence2 = &quot;我喜歡巧克力&quot;<br>sentence3 = &quot;外面天氣正在下雨&quot;<br><br>embedding1 = embedding.embed_query(sentence1)<br>embedding2 = embedding.embed_query(sentence2)<br>embedding3 = embedding.embed_query(sentence3)<br><br>type(embedding1), len(embedding1), embedding1[0:5]<br># output:<br>&#39;&#39;&#39;<br>(<br>  list,<br>  1536,<br>   [-0.003422374837100506,<br>    -0.014893854036927223,<br>    -0.0050917440094053745,<br>    -0.019068950787186623,<br>    -0.019283058121800423]<br>)<br>&#39;&#39;&#39;<br><br>np.dot(embedding1, embedding2)<br># 相似度=0.9233707071859012<br>&#39;&#39;&#39;<br>sentence1: 我喜歡蘋果<br>sentence2: 我喜歡巧克力<br>→ 雖然名詞不同，但句型和語意結構相似 → 向量內積高<br>&#39;&#39;&#39;<br><br>np.dot(embedding1, embedding3)<br># 相似度=0.789573196234445<br><br>np.dot(embedding2, embedding3)<br># 相似度=0.7912500213410828</pre><blockquote><em>np.dot是內積計算，如果向量經過正規化，就相當於 </em><strong><em>cosine similarity</em></strong></blockquote><h3>4. VDB裡面到底儲存了什麼?</h3><h4>向量資料庫（Vector Database, VDB)</h4><p>向量資料庫是專門用來儲存與搜尋<strong>高維語意向量</strong>的資料庫。<br>在 RAG（Retrieval-Augmented Generation）架構中，使用者的提問會先轉成向量，再與 VDB 中所有資料做比對，找出「語意最相近的內容」回傳給語言模型作為回答依據。</p><p>每筆儲存在 VDB 中的資料，通常包含三個部分：</p><p>╭─────── ──╮<br>│ ______向量 ID │<br>├──────────┤<br>│ ___embedding │→ [0.123, -0.984, …]（語意向量）<br>│ _page_content │→ “明天天氣是….” (chunk 對應文本=page_content)<br>│_____metadata │→ {“source”: “20250719_天氣預報.pdf”, “page”: 1, (略}<br>╰─────────╯</p><pre># 範例：<br>{<br>  &quot;id&quot;: &quot;chunk_001&quot;,<br>  &quot;embedding&quot;: [0.123, -0.456, 0.789, ...],  // 1536維浮點向量<br>  &quot;page_content&quot;: &quot;明天天氣是….&quot;,<br>  &quot;metadata&quot;: {<br>    &quot;source&quot;: &quot;20250719_天氣預報.pdf&quot;,<br>    &quot;page&quot;: 1,<br>    &quot;category&quot;: &quot;天氣&quot;,<br>    &quot;create_time&quot;: &quot;2025-07-19T08:00:00Z&quot;<br>  }<br>}</pre><blockquote><strong><em>為什麼不建議只用 Chroma？</em></strong><em><br>雖然 LangChain 預設內建 Chroma，使用上非常方便，但實際上 Chroma 的底層是使用 </em><strong><em>SQLite 儲存向量與 metadata</em></strong><em>，存在以下限制：<br>1. 無原生向量加速查詢（如 IVF, HNSW）<br>2. 不適合儲存大量 chunk（上千筆後明顯卡頓）</em></blockquote><h4>那要使用哪個VDB?</h4><p>簡單方式是找VDB排名<a href="https://db-engines.com/en/ranking/vector+dbms">https://db-engines.com/en/ranking/vector+dbms</a><br>可以很快找到主流的資料庫，再來是根據新創或業界常用的資料庫，通常會有運算速度快、適合商用、符合資安規格的。</p><p>例如，OpenSearch 支援向量查詢模組（k-NN plugin）與結構化查詢（DSL），提供以下功能:</p><ul><li>同時執行向量查詢 + metadata filtering（例如根據分類 + 相似度）</li><li>與原有企業 Elastic Stack 整合（很多銀行本身就用 Elastic）</li><li>metadata 欄位可全文索引、可排序、可聚合</li></ul><p>透過OpenSearch本身的HybridSearch就可以做到進階的VDB搜尋：</p><pre>{<br>  &quot;size&quot;: 3,<br>  &quot;query&quot;: {<br>    &quot;bool&quot;: {<br>      &quot;filter&quot;: [<br>        { &quot;term&quot;: { &quot;metadata.category&quot;: &quot;天氣&quot; } }<br>      ],<br>      &quot;must&quot;: {<br>        &quot;knn&quot;: {<br>          &quot;embedding&quot;: {<br>            &quot;vector&quot;: [0.123, -0.456, ...],　# embedding:提問轉換的vector<br>            &quot;k&quot;: 3<br>          }<br>        }<br>      }<br>    }<br>  }<br>}</pre><p>其他參考資料：</p><p><a href="https://learn.deeplearning.ai/courses/langchain-chat-with-your-data/">LangChain Chat with Your Data - DeepLearning.AI</a></p><p>以上是一些RAG上手後，可以多理解對其背後的原理。感謝閱讀~</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f53a821402f0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/jimmy-wang/langchain-02-rag%E5%85%88%E5%82%99%E7%9F%A5%E8%AD%98-%E8%B3%87%E6%96%99%E6%A0%BC%E5%BC%8F%E8%88%87vdb-f53a821402f0">[LangChain-02] RAG先備知識：資料格式與VDB</a> was originally published in <a href="https://medium.com/jimmy-wang">jimmy-wang</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[PostgreSQL 16免安裝版]架設資料庫Server與Client端使用筆記(含安裝向量資料擴充pgvector)]]></title>
            <link>https://medium.com/jimmy-wang/postgresql-16%E5%85%8D%E5%AE%89%E8%A3%9D%E7%89%88-%E6%9E%B6%E8%A8%AD%E8%B3%87%E6%96%99%E5%BA%ABserver%E8%88%87client%E7%AB%AF%E4%BD%BF%E7%94%A8%E7%AD%86%E8%A8%98-%E5%90%AB%E5%AE%89%E8%A3%9D%E5%90%91%E9%87%8F%E8%B3%87%E6%96%99%E6%93%B4%E5%85%85pgvector-9f1100738ad1?source=rss-2c7cfbfab06------2</link>
            <guid isPermaLink="false">https://medium.com/p/9f1100738ad1</guid>
            <category><![CDATA[postgresql]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[pgvector]]></category>
            <dc:creator><![CDATA[ChunJen Wang]]></dc:creator>
            <pubDate>Thu, 23 May 2024 09:32:05 GMT</pubDate>
            <atom:updated>2024-05-23T13:34:06.084Z</atom:updated>
            <content:encoded><![CDATA[<p>本篇文寫於2024/05，紀錄如何透過zip(二進位檔)安裝PostgreSQL，作業系統為Window10 x64。</p><p>PostgreSQL號稱地表最強開源資料庫，也不少新創或大企業用於軟體開發過程，其中EDB更是以PostgreSQL為基礎推出各種資料庫服務產品。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/349/1*A6bsGY2gilOca5yz_a9RXw.png" /><figcaption>PostgreSQL Logo. source: <a href="https://www.postgresql.org/">https://www.postgresql.org/</a></figcaption></figure><p>PostgreSQL版本目前每次維護5個版次，可參照自己所需要的版本調整，避免碰到已更新終止(EOL)問題。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qxrRPtY0_2m0TDrSyl-frw.png" /><figcaption>PostgreSQL release timeline(2024/05), source: <a href="https://en.wikipedia.org/wiki/PostgreSQL">https://en.wikipedia.org/wiki/PostgreSQL</a></figcaption></figure><h3>一、下載檔案</h3><blockquote>檔案下載連結:<br>(免安裝版) <a href="https://www.enterprisedb.com/download-postgresql-binaries">https://www.enterprisedb.com/download-postgresql-binaries</a><br>(安裝版) <a href="https://www.postgresql.org/download/windows/">https://www.postgresql.org/download/windows/</a></blockquote><p>這篇文章採用免安裝版，因此下載的是zip file，安裝版本為16.2.1</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/313/1*0IoeutaYLkBC5EFFn_tC7g.png" /></figure><p>建議解壓縮位置放在D:\或E:\。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/549/1*7TnDTsoJYRjBe0cJhlLt0g.png" /></figure><h3>二、初始化設定: 初始化DB、連線管理</h3><h4>2–1 初始化DB</h4><pre># 到安裝檔路徑下bin資料夾<br>cd your_unzip_path/postgresql-16.2-1-windows-x64-binaries/pgsql/bin<br><br># 初始化DB:只需執行一次<br>initdb.exe -D ../data --username=postgres --auth=trust</pre><p>到這裡就可以開始啟動我們的PostgreSQL Server：</p><pre># 啟動postgresql server<br>pg_ctl -D D:\postgresql-16.2-1-windows-x64-binaries\pgsql\data -l logfile start<br><br># 可以透過以下指令確認指定port是否有被占用<br>netstat -ao | findstr 5433</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/219/1*GvjRWkdGA8n0JGWRufFMeQ.png" /><figcaption>於windows cmd預期結果</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1006/1*ef1hkl_l86YGTyVgwPVIZg.png" /><figcaption>確認port=5433是否占用</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/589/1*6376LiE-MyNacegQb1mNBg.png" /><figcaption>Windows工作管理員可以確認postgreSQL是否正常運行</figcaption></figure><p>工作管理員裡面有多個執行序，主要控制的是postmaster。<br>完整架構可以參考EDB的教材<br>&gt; <a href="https://pgadminedb.readthedocs.io/en/latest/module_02/">https://pgadminedb.readthedocs.io/en/latest/module_02/</a></p><h4>2–2 連線管理</h4><p>PostgreSQL Server預設只開給local連線，所以不必擔心在啟動後，就門戶大開。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/619/1*GLAM3miEXXJVgnIvkH0hiA.png" /><figcaption>預設本地連線，port=5432</figcaption></figure><p>這裡需要調整的設定檔有兩個：</p><ol><li>postgresql.conf：server端連線參數</li><li>pg_hba.conf：可控制依據資料庫、使用者、IP、登入方式調整</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/633/1*6a1yfnmnIN9bPmmcxh4_qg.png" /><figcaption>調整為開放外部ip連線，port=5433</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*zEamjJD_KSL8HMlZRPNSeQ.png" /></figure><h4>!注意!</h4><p>－pg_hba.conf如果調整為ip 0.0.0.0/0代表任意IP都可以進行連線。</p><p>建議實際控管<strong>人數若不多，可以個別設定IPv4來進行開放</strong>，記得設定對應DB或User，這點可以彈性運用；若<strong>為分單位需求，則可考慮分網段</strong>開放。</p><h4>連線方式(METHOD)則分為：</h4><ol><li>trust :不須驗證密碼，直接相信客戶端所提供的資料庫使用者(必須已經存在的db user)，若客戶端沒有明確提供資料庫使用者，則自動根據執行客戶端程式的os使用者當作資料庫使用者。</li><li>md5：客戶端將密碼以md5方式加密傳送至資料庫端進行驗證(pg13之前)</li><li>scram-sha-256：客戶端將密碼以scram-sha-256方式加密傳送至資料庫端進行驗證(pg13開始預設使用)</li><li>password：客戶端將密碼以明文方式傳送至資料庫端進行驗證</li><li>ident：直接使用執行客戶端軟體的os user當作資料庫使用者</li><li>reject：拒絕連線</li></ol><h4>重新讀取設定方式有2種：</h4><p>調整完畢後，需要重啟服務或重讀(reload)設定檔。</p><pre># 已使用psql連線來重讀設定檔<br>SELECT pg_reload_conf();<br><br># 於cmd透過pg_ctl指定DB server重讀設定檔<br>pg_ctl -D D:\postgresql-16.2-1-windows-x64-binaries\pgsql\data reload</pre><h3>三、基本管理操作</h3><h4>1. 建立使用者與授權</h4><pre># 建立使用者(含密碼)<br>CREATE USER jimmy WITH PASSWORD &#39;jimmy012300&#39;;<br><br># 透過既定群組設定權限，例如開放使用者可以「讀」「寫」資料<br>GRANT pg_read_all_stats, pg_read_all_data, pg_write_all_data TO jimmy;<br><br># 設定使用者可以連線的DATABASE<br>GRANT CONNECT ON DATABASE dev TO jimmy;<br><br># 開放特定功能，例如讓使用者可以在指定的schema「建立」表<br>GRANT USAGE, CREATE ON SCHEMA public TO jimmy;</pre><p>PostgreSQL內建幾種權限群組:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*v26m1mdibyRZ2ls4FGVb4A.png" /></figure><h4>2. 透過csv匯入資料</h4><p>假如我們已經建立了一張table想要塞資料進去，但手上只有csv檔案，可以怎麼操作?</p><pre>--匯入csv檔案<br>--透過COPY指定資料表、從From中指定檔案路徑<br><br>COPY table_name(cyc_mn, count)<br>FROM &#39;D:\jimmy\Downloads\mock_data.csv&#39;<br>DELIMITER &#39;,&#39;<br>CSV HEADER;</pre><ul><li>生成模擬資料網站: <a href="https://www.mockaroo.com/">https://www.mockaroo.com/</a></li></ul><h4>3. client端連線怎麼操作?</h4><h4>方式A. 透過zip檔案中的psql來進行連線</h4><p>psql -h (host IP) -p (port) -U (Username) -d (DB name)</p><pre># 舉例:<br>psql -h 10.ooo.ooo.ooo -p 5433 -U jimmy -d dev</pre><h4>方式B. Tableau連線 (示範版本為2021.2)</h4><p>如果有資料視覺化軟體(像是Tableau)也可以直接連線</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/969/1*pD_M3gVGPG9syyAu0VOA2Q.png" /><figcaption>Tableau連線設定畫面</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/870/1*0e0iXYUIUYpj169ssPIM8A.png" /><figcaption>成功連線後，會在左側顯示Database名稱，與可以使用的Table</figcaption></figure><h4>方式C. Python連線 (示範版本為3.10.14)</h4><p>需要安裝psycopg2套件或其他整合的DB連線套件(例如sqlalchemy)</p><pre>import psycopg2<br>import pandas as pd<br><br>password = input(f&#39;password:&#39;)<br><br>conn = psycopg2.connect(database=&quot;dev&quot;, user=&quot;jimmy&quot;, <br>                        password=password, host=&quot;10.ooo.ooo.ooo&quot;, <br>                        port=&quot;5433&quot;)</pre><p>連線成功後，就可以透過自建table來測試query：</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/546/1*uN-_Y-SLvjDJ-3QQEUPMIg.png" /></figure><h3>四、管理介面GUI: pgAdmin4</h3><p>pgAdmin包含了監控用的儀表板，<br>可以查看目前DB server運行狀況、吞吐量等等。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B1jhb1sS4Xyx3gmt1pR_Jw.png" /></figure><h4>第一次開次需要建立新的連線:</h4><p>Register&gt;Server&gt;命名:Name&gt;填入Connection</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/457/1*i4uUIo4BPaxg_rvclmKIEg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/707/1*QSCntlLExk9A9OxbwQ6myg.png" /><figcaption>建議管理者可以設定一個專用的，個人是採用(DB Name)_(User Name)來識別，例如dev_admin。</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/706/1*spu7MeLN1_vIcAk4oR_YwQ.png" /><figcaption>連線設定如同先前的設定值。</figcaption></figure><p>在pgAdmin也可以快速做表操作、查看，或建立schema, index, table等設定</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*1YsiDXW0tFl9cDd5Ev538A.png" /><figcaption>查看表設定</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/777/1*QXuXSNNwT8ZLymMvr6ncEg.png" /><figcaption>欄位設定</figcaption></figure><h3>五、安裝擴充: 向量資料儲存</h3><ul><li>向量資料格式在此時通常為「大型語言模型LLM開發用」</li></ul><p>使用大型語言模型(LLM)時，如有開發RAG應用需求，<br>通常需要先將input與文件庫進行向量轉換(embedding)，<br>主要考量：</p><ol><li>避免個資或機敏資料直接透過API傳送給LLM供應商，例如OpenAI。</li><li>加速資料比對與提高找到解答正確率(可以參照內部文件)。</li></ol><p><a href="https://github.com/pgvector/pgvector">GitHub - pgvector/pgvector: Open-source vector similarity search for Postgres</a></p><h4>安裝的擴充為<a href="https://github.com/pgvector/pgvector">pgvector</a></h4><ol><li>安裝前須先確認有無安裝Visual Studio</li></ol><pre># 確認是否已安裝Visual Studio<br>call &quot;C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat&quot;<br><br># Expected Output<br>&#39;&#39;&#39;<br>**********************************************************************<br>** Visual Studio 2022 Developer Command Prompt v17.7.3<br>** Copyright (c) 2022 Microsoft Corporation<br>**********************************************************************<br>[vcvarsall.bat] Environment initialized for: &#39;x64&#39;<br>&#39;&#39;&#39;</pre><p>2. 開始安裝<a href="https://github.com/pgvector/pgvector">pgvector</a></p><pre>D:\postgresql-16.2-1-windows-x64-binaries\pgsql<br>set &quot;PGROOT=D:\postgresql-16.2-1-windows-x64-binaries\pgsql&quot;<br>cd %TEMP%<br>git -c http.sslVerify=false clone --branch v0.7.0 https://github.com/pgvector/pgvector.git<br>cd pgvector<br>nmake /F Makefile.win<br>nmake /F Makefile.win install</pre><p>在RMDBS背後其實還是如一般儲存方式，但data type為「vector」</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/303/1*UJi40YP9eV6Cy2axSgIZuA.png" /></figure><h4>[補充]更多操作介紹，請參考PostgreSQL使用手冊(中文版)：</h4><p><a href="https://docs.postgresql.tw/">簡介 | 16 | PostgreSQL 正體中文使用手冊</a></p><p><strong>[AWS EC2安裝指令note]</strong></p><pre>whoami      #確認<br>sudo su     #切換至root權限<br>passwd root #設定密碼<br><br># 安裝postgresql<br>dnf install postgresql15-server.x86_64 -y<br># 初始化db<br>postgresql-setup --initdb<br># 啟動server<br>systemctl start postgresql<br># 加入服務<br>systemctl enable postgresql<br>### [OUTPUT] Created symlink /etc/systemd/system/multi-user.target.wants/postgresql.service → /usr/lib/systemd/system/postgresql.service.</pre><p>[<strong>Linux RedHat指令安裝note</strong>]</p><pre># Linux RedHat指令安裝<br>## RedHat<br>https://www.postgresql.org/download/linux/redhat/<br># Install the repository RPM:<br>sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm<br><br># Disable the built-in PostgreSQL module:<br>sudo dnf -qy module disable postgresql<br><br># Install PostgreSQL:<br>sudo dnf install -y postgresql16-server<br><br># Optionally initialize the database and enable automatic start:<br>sudo /usr/pgsql-16/bin/postgresql-16-setup initdb<br>sudo systemctl enable postgresql-16<br>sudo systemctl start postgresql-16</pre><p>✍️感謝閱讀到這邊的你，如果有其他想知道的也可以留言給我。</p><p>或幫我在底下拍手👏👏👏，來支持一下這邊文章喔~😀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9f1100738ad1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/jimmy-wang/postgresql-16%E5%85%8D%E5%AE%89%E8%A3%9D%E7%89%88-%E6%9E%B6%E8%A8%AD%E8%B3%87%E6%96%99%E5%BA%ABserver%E8%88%87client%E7%AB%AF%E4%BD%BF%E7%94%A8%E7%AD%86%E8%A8%98-%E5%90%AB%E5%AE%89%E8%A3%9D%E5%90%91%E9%87%8F%E8%B3%87%E6%96%99%E6%93%B4%E5%85%85pgvector-9f1100738ad1">[PostgreSQL 16免安裝版]架設資料庫Server與Client端使用筆記(含安裝向量資料擴充pgvector)</a> was originally published in <a href="https://medium.com/jimmy-wang">jimmy-wang</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[LangChain-01] RAG實戰第一站]]></title>
            <link>https://medium.com/jimmy-wang/langchain-rag%E5%AF%A6%E6%88%B0%E7%AC%AC%E4%B8%80%E7%AB%99-efe975f4c3bd?source=rss-2c7cfbfab06------2</link>
            <guid isPermaLink="false">https://medium.com/p/efe975f4c3bd</guid>
            <category><![CDATA[langchain]]></category>
            <category><![CDATA[openai]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[ChunJen Wang]]></dc:creator>
            <pubDate>Sat, 24 Feb 2024 05:00:17 GMT</pubDate>
            <atom:updated>2024-02-24T05:00:52.227Z</atom:updated>
            <content:encoded><![CDATA[<p>透過製作筆記過程，加深學習記憶。</p><p>適合閱讀此篇筆記的人：沒有接觸過RAG或LLM的開發人員。</p><p>Source: <a href="https://python.langchain.com/docs/use_cases/question_answering/">https://python.langchain.com/docs/use_cases/question_answering/</a></p><h3>RAG 檢索增強生成</h3><p>RAG是利用額外資料來增強 LLM 知識的技術。<br>額外資料可以是：</p><ol><li>公司內部的文件、手冊。</li><li>外部公開的資料庫，如法規條文、財報資訊。</li><li>Google搜尋結果 (透過API)。</li><li><a href="https://python.langchain.com/docs/use_cases/sql/prompting">DB Schema</a>。</li></ol><p>金融業使用RAG原因，通常為資安、個資與機密資料保護，而採取的解決方式<em>。 <br>— </em><strong>RAG檢索的資料可以留存於地端。</strong></p><p>RAG的步驟(官方文件說明)：</p><ul><li><strong>RAG主要步驟</strong>為<strong>左圖</strong>，進行檢索(查詢)，將檢索到的資料，連同一開始的問題一起丟給LLM進行回答。</li><li><strong>右圖</strong>檢索<strong>資料前處理</strong>，讀取各種格式資料，將讀取的資料切成一小段一小段的文本資料，進行embedding，儲存到向量資料庫。</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A8Jdo0x1p4Ky9TzZNJSzLg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N15zqVxu9G_ZTq-ksVO4MA.png" /><figcaption>Source: <a href="https://python.langchain.com/docs/use_cases/question_answering/#retrieval-and-generation">https://python.langchain.com/docs/use_cases/question_answering/#retrieval-and-generation</a></figcaption></figure><h4>動手試試</h4><p>官方sample code</p><pre>import os<br><br># for LLM model<br>os.environ[&quot;OPENAI_API_KEY&quot;] = &quot;填入你的OpenAI API KEY&quot;<br><br># for langSmith (可以不使用)<br>os.environ[&quot;LANGCHAIN_TRACING_V2&quot;] = &quot;true&quot;<br>os.environ[&quot;LANGCHAIN_API_KEY&quot;] = &quot;填入你的LangSmith API KEY(非必要)&quot;<br><br>import bs4<br>from langchain import hub<br>from langchain.text_splitter import RecursiveCharacterTextSplitter<br>from langchain_community.document_loaders import WebBaseLoader<br>from langchain_community.vectorstores import Chroma<br>from langchain_core.output_parsers import StrOutputParser<br>from langchain_core.runnables import RunnablePassthrough<br>from langchain_openai import ChatOpenAI, OpenAIEmbeddings<br><br># 讀取資料，轉為向量儲存<br>loader = WebBaseLoader(<br>    web_path=(&quot;https://lilianweng.github.io/posts/2023-06-23-agent/&quot;,),<br>    bs_kwargs=dict(<br>        parse_only=bs4.SoupStrainer(<br>            class_=(&quot;post-content&quot;, &quot;post-title&quot;, &quot;post-header&quot;)<br>        )<br>    )<br>)<br><br>docs = loader.load()<br><br>text_splitter = RecursiveCharacterTextSplitter(chunk_size=1000, chunk_overlap=200)<br>splits = text_splitter.split_documents(docs)<br>vectorstore = Chroma.from_documents(documents=splits, embedding=OpenAIEmbeddings())<br>print(&#39;完成向量化&#39;)<br><br><br># 進行檢索與生成<br>retriever = vectorstore.as_retriever()<br>prompt = hub.pull(&quot;rlm/rag-prompt&quot;)<br>llm = ChatOpenAI(model_name=&quot;gpt-3.5-turbo&quot;, temperature=0)<br><br>def format_docs(docs):<br>    return &quot;\n\n&quot;.join(doc.page_content for doc in docs)<br><br>rag_chain = (<br>    {&quot;context&quot;: retriever | format_docs, &quot;question&quot;: RunnablePassthrough()}<br>    | prompt<br>    | llm<br>    | StrOutputParser()<br>)<br>print(&quot;完成建立RAG&quot;)<br><br>result = rag_chain.invoke(&quot;What is Task Decomposition? 請用繁體中文回答。&quot;)<br>print(result)</pre><p>Output：</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YEOVYIj-mZzOG_u-t__amQ.png" /></figure><p>如有設定LangSmith，可以更容易檢視背後運作的資料流與<strong>耗時成本</strong>：</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v_S1y58Xa0q9HPDx6XcxsA.png" /></figure><p>其中map:key:context為在這個input問題下，<br>參考了哪一段文字來讓LLM思考如何回答問題。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9MFUWBA5vCjOTL06-ql9Rw.png" /></figure><p>而我們可以看最後丟給OpenAI處理的Prompt有完整的格式，<br>請GPT扮演QA助手，要依據參考資料(Context)來回答問題(Question)。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BrDAobwJaLm3mSMR1IKbeA.png" /></figure><blockquote>嗯? 這個prompt格式從哪裡來的?<br>Ans: <a href="https://smith.langchain.com/hub/rlm/rag-prompt?organizationId=ab4ba6d8-e630-52fc-9341-901fea3e9907">https://smith.langchain.com/hub/rlm/rag-prompt?organizationId=ab4ba6d8-e630-52fc-9341-901fea3e9907</a></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h1B7Tl4M6_F9OrQGk1oV_A.png" /></figure><p>一個在資料前處理的重點回顧:</p><h4>當要檢索的文本太長怎麼辦?</h4><p>切分資料!</p><p>我們在使用gpt-3.5的API目前仍需要考量文本長度，因此會需要在前處理時分割文本成等長的文字段落。完整的解答可以參考官網的步驟解說:</p><p><a href="https://python.langchain.com/docs/use_cases/question_answering/quickstart#indexing-split">Quickstart | 🦜️🔗 Langchain</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hEblyVc5fbdKiaDXqZAebw.png" /></figure><p>以上是一個最小的RAG使用範例。感謝閱讀~</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=efe975f4c3bd" width="1" height="1" alt=""><hr><p><a href="https://medium.com/jimmy-wang/langchain-rag%E5%AF%A6%E6%88%B0%E7%AC%AC%E4%B8%80%E7%AB%99-efe975f4c3bd">[LangChain-01] RAG實戰第一站</a> was originally published in <a href="https://medium.com/jimmy-wang">jimmy-wang</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[2024隨手記：轉職後，平穩的一年]]></title>
            <link>https://medium.com/jimmy-wang/2024%E9%9A%A8%E6%89%8B%E8%A8%98-%E8%BD%89%E8%81%B7%E5%BE%8C-%E5%B9%B3%E7%A9%A9%E7%9A%84%E4%B8%80%E5%B9%B4-41bc2f13fca8?source=rss-2c7cfbfab06------2</link>
            <guid isPermaLink="false">https://medium.com/p/41bc2f13fca8</guid>
            <category><![CDATA[2023]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[careers]]></category>
            <category><![CDATA[life]]></category>
            <dc:creator><![CDATA[ChunJen Wang]]></dc:creator>
            <pubDate>Sun, 07 Jan 2024 14:26:13 GMT</pubDate>
            <atom:updated>2024-11-30T02:17:29.534Z</atom:updated>
            <content:encoded><![CDATA[<p>記錄過去一年(2022/9~2023/12)工作與生活概況。</p><p>2022下半年，幾位前輩推薦下，當時對未來仍感到不安，還是到了另一家銀行。回想當下，很感謝鼓勵我出走的人們，讓我有機會再試過，進而轉換到理想的工作領域：在資料分析團隊內做開發、研究、追新趨勢。</p><p>2023年過得特別快速。轉換初期，冬天下班能看見陽光，能趕到大稻埕，看日落在河岸上波光粼粼，幸福感十足。其他時間，則去學鋼琴、韓式烤肉，也經營IG料理紀錄和參加社大西餐課程。</p><h4>新技能的養成一：維運AI模型</h4><p>原本擔心過去擔任BA一職，也會被分配到較多的溝通工作，或指派到專案中，對於經驗不多的年輕人(或著對我來說吧)，其實也不怕需要時常打電話、會議或信件對標需求，讓人覺得困擾的，大都是碰上個人手腕不夠力，處理不來的政治議題，才會讓人感到力不從心。</p><p>到了新環境，雖然也看到有前輩身上背著負擔比較重的案子，但相對來說，可以提出想法，希望案子的如何執行自由度挺高，主管也願意安排同仁相對有意願的工作項目。</p><p>我在初期接下維運模型作業，說難不難，接手維運就是避免模型失真，實務面，是模型標準以外更多的問題需要確認。</p><p>這段時間，要弄懂資料流、模型框架，花不少時間在逐行程式閱讀與執行驗證，也在直屬主觀丟出的可解釋模型命題下，閱讀了<a href="https://ema.drwhy.ai/">Explanatory Model Analysis</a>，這本書提供簡單的範例，包含R, Python實作程式，套件操作也容易。累積的經驗雖說不上有實質幫助，但在撰寫模型報告，或業務單位提問時，是提供資訊的好方法之一。</p><h4>穿插小記的個人里程碑：<a href="https://www.tableau.com/learn/certification/certified-data-analyst">Tableau Certified Data Analyst</a></h4><p>在年初，有一件開心的事情，就是通過了Tableau DA證照，當時還寫了一篇文章<a href="https://medium.com/jimmy-wang/%E5%A6%82%E4%BD%95%E5%9C%A82023%E5%B9%B4%E9%80%9A%E9%81%8Etableau-certified-data-analyst-dfbd4921dc31">「如何在2023年通過Tableau Certified Data Analyst?」</a>。</p><p>考證照非主管要求，純粹出於過去轉職路上的顛簸，希望累積的技能，能留下里程碑，把不開心的工作經驗，洗鍊為成就感。</p><p>意外無心插柳，這張證照時不時會被提起，像是成長心態標誌，到最近，還被點名參加內部Tableau競賽，是好是壞仍未卜，被認可的感動還是讓人覺得很滿足。</p><h4>技能養成二：深度學習、大型語言模型(LLM)應用 (依賴老闆期待來點技能)</h4><p>這一年因為主管提出的命題，需要在一定時間內累積技能，實作到可以POC的程度，譬如上半年重新複習pytorch, tensorflow兩種深度學習框架，惡補新的算法，自建模型做預測，也在與學生團隊溝通、交流發現，雖然晚起步，但似乎做的也還可以，同時，Kaggle也很神奇的推出手語辭彙辨識的比賽。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iOVMWSxuVJYPizb7Zx5c-w.png" /><figcaption>Google於Kaggle手語辭彙辨識公開賽</figcaption></figure><p>名次在初期原本還有前10%，但Kaggle的生態翻新的很快，一旦有人公開分享出更適合的模型後，沒有繼續跟，就會被海放 (sad)。</p><p>下半年，先是被派訓到台灣人工智慧學校(AIA)。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Flnmn_2hGFqUDxsOfnOKdA.png" /><figcaption>在AIA 課程也有內部Kaggle比賽</figcaption></figure><p>開始接觸大型語言模型(LLM)，與基本的前後端框架: <a href="https://streamlit.io/">streamlit</a>, <a href="https://docs.chainlit.io/get-started/overview">chainlit</a>, <a href="https://www.gradio.app/">gradio</a>。從prompt design、langchain、llamaindex、lora fine-tune能實作。才明白，能在浪潮之上嘗試這些新技術，其實不輕鬆，因為沒人能夠精準預測，下一波會被市場採用，真正切合需求的技術是哪一種，我們只能多做多試，從中找出最合適的方案。</p><p>工作中參與大大小小任務，用的工具多樣多變，但也是一種挑戰。2023上半年還在試用期的時候，很積極的每隔2–3天就讀完一本軟體開發觀念或敏捷、專案的書籍，有些似懂非懂，自己便收錄到個人筆記內；下半年，開始派訓到AIA上課，收到了提出專利的獎金，建立了公司內部的AI知識群組，過著週更貼文，常在切換思維模式之中打滾，過的有一點煎熬。</p><p>回顧起來，工作與生活中也完成了不少事，還是挺開心的。</p><p>原本期待在這篇文的撰寫過程，結論出一些有道理的句子，作為2023年的收尾，但拖稿了一週，這一年，真的就穩定的走過了，平凡、簡單，感覺也挺好。</p><h4>給轉職者，祝福的話</h4><p>昨日在松菸經過求職展，看見不少年輕人排隊等候入場。</p><p>希望每一位還在轉職路上的人們，能夠順利取得面試，遇到合拍的主管及文化環境，也能在工作中持續成長進步。</p><h4>結語</h4><p>想到自己能夠在這一兩年，勇敢踏出金融圈，再繞回來。不敢說是特別順利，但生活過的還不錯，下班後也都能留下時間放空、做便當，也朝向一些新的人生目標邁進，繼續努力加油！</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9lVEOPnLnBZ7B8jg.jpg" /><figcaption>Leonardo.ai 生成圖片。prompt: Through the window, you can see the sun shining on the river. The afterglow of the setting sun seems to be a blessing for his achievements in work. The whole scene seems to show a diligent and positive work attitude, as well as an infinite thirst for knowledge and technology</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=41bc2f13fca8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/jimmy-wang/2024%E9%9A%A8%E6%89%8B%E8%A8%98-%E8%BD%89%E8%81%B7%E5%BE%8C-%E5%B9%B3%E7%A9%A9%E7%9A%84%E4%B8%80%E5%B9%B4-41bc2f13fca8">2024隨手記：轉職後，平穩的一年</a> was originally published in <a href="https://medium.com/jimmy-wang">jimmy-wang</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[如何在2023年通過Tableau Certified Data Analyst?]]></title>
            <link>https://medium.com/jimmy-wang/%E5%A6%82%E4%BD%95%E5%9C%A82023%E5%B9%B4%E9%80%9A%E9%81%8Etableau-certified-data-analyst-dfbd4921dc31?source=rss-2c7cfbfab06------2</link>
            <guid isPermaLink="false">https://medium.com/p/dfbd4921dc31</guid>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[tableau]]></category>
            <dc:creator><![CDATA[ChunJen Wang]]></dc:creator>
            <pubDate>Mon, 30 Jan 2023 09:31:20 GMT</pubDate>
            <atom:updated>2023-02-23T08:21:38.179Z</atom:updated>
            <content:encoded><![CDATA[<p>如題，很幸運的我在今年農曆新年前，通過了Tableau DA的考試認證。本篇會簡單分享考試經驗與心得。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/384/1*SCQpGe69TpfrPZ_vL-EJAg.png" /></figure><p>Contents:</p><ol><li>為什麼需要考<a href="https://www.tableau.com/learn/certification/certified-data-analyst">Tableau Certified Data Analyst</a>?</li><li>準備過程與考場經驗</li><li>考試心得</li></ol><h3>為什麼需要考Tableau DA認證?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RAA7DgxCe4oUBQm4s1qnBA.png" /><figcaption>Source: <a href="https://www.tableau.com/blog/tableau-decade-leader-2022-gartner-magic-quadrant-analytics-business">https://www.tableau.com/blog/tableau-decade-leader-2022-gartner-magic-quadrant-analytics-business</a></figcaption></figure><ul><li>Tableau是世界認可的資料視覺化軟體，適用於探索與分析資料、儀表板監控等等功能。</li><li>若對資料分析有興趣，視覺化可以做為成為Data Analyst敲門磚。而考取認證就是你履歷上的磚頭XD。</li><li>追求自我認同。</li></ul><p>事實上，有更多相關文章與課程，說明了學會使用Tableau，可以找到高薪工作，甚至<a href="https://intellipaat.com/blog/how-to-become-tableau-analyst/#no2">有針對不同國家、Level薪水水平</a>彙總資訊。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/804/1*MCaU1w32S7KLx5QWO3vpvQ.png" /><figcaption>Source: <a href="https://intellipaat.com/blog/how-to-become-tableau-analyst/#no2">https://intellipaat.com/blog/how-to-become-tableau-analyst/#no2</a></figcaption></figure><p>認證絕對是很好的門面，但也需要瞭解到，考試與現實有落差仍是不可避免的，舉例來說，準備考試不會教你一個完整的儀表板開發流程，像是：</p><ul><li>如何與需求單位談儀表板內容</li><li>如何資料工程團隊談資料需求與連接DB。</li><li>如何精修儀表板，讓整體看起來更直覺、美觀。</li><li>資料若有誤如何驗算。</li><li>如何tune儀表板效能 (SQL、tableau公式或篩選器等等優化)。</li></ul><p>若有時間、可負擔報名費、公司支持、符合個人職涯規劃，多一張認證是挺不錯的，畢竟考試仍有門檻與效期</p><blockquote>必須在認證考試中取得 75% 以上的分數，並且該認證的有效期也只有兩年。</blockquote><h3>準備過程與考場經驗</h3><p>自學絕對可以通過測驗，網路上也有許多資源可以support你學習Tableau知識，依據考試前／中／後，可以彙整出下列資訊，提供給大家參考。</p><h4>A. 考前必讀資源 (前)</h4><ul><li>瞭解<a href="https://mkt.tableau.com/files/TableauCertifiedDataAnalyst_ExamGuide.pdf"><strong>考試規則與比重分布</strong></a>: 請至少完整讀過一輪考試guide。</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/758/1*B46eiS_6OFwjreK2objr9g.png" /><figcaption>節錄考試比重分布</figcaption></figure><ul><li>如果完全沒有接觸過Tableau，不要瞎讀，<strong>找完整課程來看</strong></li></ul><ol><li><a href="https://www.udemy.com/course/tableau-certification-prep/">[Udemy] Tableau Certification: Desktop Specialist + Data Analyst</a>: 講義整理的蠻完整的，可以以此起步，再擴充，且是目前看到相對好入手的課程 (時數較短、內容都有涵蓋、有搭配實作)。</li><li><a href="https://www.tableau.com/learn/training/data-analyst-certification-prep">Tableau官方課程</a>: 如果有錢或公司贊助再報名吧，$500 USD好貴QQ。</li></ol><ul><li><a href="https://learningtableau.com/data-analyst-study-guide/"><strong>官方文件重點資訊</strong></a>: 這裡匯集了依據不同Domain對應的官方documentation，一天速讀5~6篇，很快就可以消化完了。</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IfSNPJv1siAxGvpXqf4vTQ.png" /><figcaption>可以將網址en-us改為zh-tw，切換為中文閱讀。</figcaption></figure><ul><li>刷模擬題絕對有助於答題: 我推薦1. 的資源，可以先試做DA前兩回測驗看看符不符合期待，再決定是否購買。<br><em>(refund需要模擬題都90%up，且報名考試後沒通過XD)</em></li></ul><ol><li><a href="https://gettableaucertifications.com/free-quiz/"><strong>Tableau Certification Exam Questions</strong></a></li><li><a href="https://www.simplilearn.com/tableau-exam-questions-free-practice-test">Free Tableau Certification Exam Practice Test</a></li></ol><h4>B. 報名考試 (前)</h4><ul><li><strong>報名姓名</strong>需要<strong>與入場身分文件相符</strong>。<br>例如: WANG CHUN JEN，全大寫，出示信用卡/護照皆可。</li><li><strong>推薦現有考試中心</strong>，不用擔心網路、跟考官核對資料等等流程。<br><em>(nice: 恆逸教育訓練中心，台北市松山區復興北路99號)<br>- </em>冷氣很強。<br>- 有專人核對資料。<br>- 考場<strong>不能帶水</strong>、手機、<strong>手錶</strong>(螢幕有倒數時間)。</li><li>找現有考試中心，提早到，若準備好，可以直接入場進行考試。</li></ul><h4>C. 考試過程 (中)</h4><ul><li>實際答題時間共112分鐘。</li><li>整體考試分為3個階段，知識考題-&gt;實作(Lab)-&gt;知識考題。</li><li><strong>不可使用google</strong>。<a href="https://help.tableau.com/current/offline/en-us/tableau_desktop.pdf">僅於Lab階段可以開PDF</a>。有3567頁，基本上準備好，不會使用到，因為查PDF時機是知識考題比較需要。</li><li>請記得檢查是否都完成答題後，再跳至下一階段。</li></ul><h4>D. 考試結果 (後)</h4><ul><li>於考試中心，會立即拿到成績單，確認是否通過。</li><li>官方說約一天可於<a href="https://home.pearsonvue.com/tableau">Pearson Vue</a>上登入查詢，實際上我約6小時就可於官網查詢。</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5PP1SvUq2c2BYzdjuwkTAA.png" /></figure><h4>E. 其他可能發生的意外</h4><ol><li>報名名字打錯怎麼辦?<br>趕快上報名網站改名字，並email通知官方人員確認 (certification@tableau.com)</li><li>沒帶護照，身分證上面又沒英文怎麼辦?<br>使用信用卡，上面如果有英文名字也是可以的。</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0I_0AganJUX88Atq1c9MoA.png" /></figure><blockquote>我還真的打錯名字…，在報名上填了 JIMMY WANG…，而且是在當天才發現，考前半小時打國際電話客服沒人接，email過去後，隔了2天，官方回覆送了一張coupon，提供我再次報名(免費)，覺得真是佛心。</blockquote><h3>考試心得</h3><p>這次考試的主要目的，是給自己一個心安，雖然目前完全沒有接手Tableau的開發或維運需求，但過去在半導體通路商，夭壽的老闆給了機會讓我學會這套軟體(但技能與考試落差蠻大XD)，回到銀行擔任BA工作也或多或少，間接接觸到視覺化軟體開發、需求確認，真的是跟Tableau蠻有緣分。</p><p>里程碑達成了，心裡也踏實許多，放上<a href="https://tw.linkedin.com/">LinkedIn</a>感覺也是不錯，<br>btw 還可以拿到數位認證，內建8個skill~</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WiYqqcviSnfHGsmu26jybg.png" /></figure><p>如果對於考試有任何想瞭解，或是更多經驗的，也歡迎底下留言或透過其他方式找到我來聊聊~~</p><p>Buy Me a Coffee / <br>用5美元贊助讓我去喝杯星巴克，再多創作一篇文章👇</p><figure><a href="https://www.buymeacoffee.com/jimmywang2023"><img alt="" src="https://cdn-images-1.medium.com/max/170/1*WfbwTpxi0c0k2Vwzp3s5yg.png" /></a></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dfbd4921dc31" width="1" height="1" alt=""><hr><p><a href="https://medium.com/jimmy-wang/%E5%A6%82%E4%BD%95%E5%9C%A82023%E5%B9%B4%E9%80%9A%E9%81%8Etableau-certified-data-analyst-dfbd4921dc31">如何在2023年通過Tableau Certified Data Analyst?</a> was originally published in <a href="https://medium.com/jimmy-wang">jimmy-wang</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[轉職資料工程師以後，寫code寫文章比較開心嗎?]]></title>
            <link>https://medium.com/jimmy-wang/%E8%BD%89%E8%81%B7%E8%B3%87%E6%96%99%E5%B7%A5%E7%A8%8B%E5%B8%AB%E4%BB%A5%E5%BE%8C-%E5%AF%AB%E6%96%87%E7%AB%A0%E6%AF%94%E8%BC%83%E9%96%8B%E5%BF%83%E5%97%8E-2e032d14b402?source=rss-2c7cfbfab06------2</link>
            <guid isPermaLink="false">https://medium.com/p/2e032d14b402</guid>
            <category><![CDATA[medium]]></category>
            <category><![CDATA[other]]></category>
            <category><![CDATA[introspection]]></category>
            <category><![CDATA[retrospectives]]></category>
            <dc:creator><![CDATA[ChunJen Wang]]></dc:creator>
            <pubDate>Sat, 18 Jun 2022 11:17:33 GMT</pubDate>
            <atom:updated>2022-06-19T05:48:16.593Z</atom:updated>
            <content:encoded><![CDATA[<p>文末再來回答一下這個問題…</p><p>每每收到Medium回報每周、每月流量信件時，總會忍不住點開看看，近期流量如何，有更多人看嗎? 看的文章類型主要是哪些?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8nVgPjkZ8OAKiZZWD2cvBw.png" /></figure><p>然而，我的文章瀏覽量，蠻固定，就是那幾篇在創造流量：</p><h4>文章清單中，最多人瀏覽的top5</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1018/1*DsxaRnXmrpDBr5CwYZt4kg.png" /></figure><ul><li><a href="https://medium.com/jimmy-wang/opencv-%E5%9F%BA%E7%A4%8E%E6%95%99%E5%AD%B8%E7%AD%86%E8%A8%98-with-python-d780f571a57a">[OpenCV]基礎教學筆記：影像讀取、前處理(with python)-001</a></li><li><a href="https://medium.com/jimmy-wang/sql-with-as%E9%80%B2%E8%A1%8C%E5%AD%90%E6%9F%A5%E8%A9%A2-cte-sql-004-e045147f0317">[進階SQL]With As進行子查詢(CTE)[SQL-004]</a></li><li><a href="https://medium.com/jimmy-wang/oracle%E5%9F%BA%E6%9C%AC%E4%BF%AE%E7%B7%B4-pl-sql-cursor-fa0cd013692">Oracle基本修練: PL/SQL Cursor</a></li><li><a href="https://medium.com/jimmy-wang/oracle%E5%9F%BA%E6%9C%AC%E4%BF%AE%E7%B7%B4-pl-sql-stored-procedures-and-functions-73b235631880">Oracle基本修練: PL/SQL Stored procedures and Functions</a></li><li><a href="https://medium.com/jimmy-wang/%E5%88%9D%E5%98%97%E8%BB%9F%E9%AB%94%E6%B8%AC%E8%A9%A6-software-testing-3c7d786525a9">初嚐軟體測試(Software Testing)</a></li></ul><p>大概是因應目前的時代趨勢吧，許多人，不論透過線上課程、政府補助、私人企業內外部培訓，都在努力學習著「資料分析Data Analysis」相關的知識與技能。</p><p>特別是連我之前離開玉山銀行後，也有去上過<a href="https://elite.taiwanjobs.gov.tw/">勞發署補助的產業新尖兵課程</a>，主要是去學習了Python的AI應用，也看到求職市場上，好多人都想學習這資料分析這個領域的技能。</p><h4>我的撰寫文章時間軸如下：</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jOXcbMyNb9hITPi_DDvtOA.png" /></figure><p>可看過去有關Genesys系統文章，或是過於基本的SQL指令(例如select, where condition)，大家要不沒興趣，要不早就知道(或有更好的資源與課程)，根本不需要這些文章。</p><p>直到有關Python影像辨識那篇，與stored procedure/ SQL cursor文章後，才有比較多人瀏覽。</p><h4>最近30天的瀏覽量如何?</h4><p>很意外的，在我<strong>最痛苦的轉職期間</strong>，默默的某幾篇文章是在Medium慢慢發酵的，每個月幾乎以翻倍的瀏覽量有人點擊。</p><blockquote><strong>真的非常非常感謝大家。文章被看見，還真的是作者最大的動力。</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1015/1*_rfV_tTfBIVb-Rev5dKJ6w.png" /></figure><p>畢竟，寫文章雖是為了自主學習的筆記，但在網路上被瀏覽，背後影藏這樣的需要，特別是針對stored procedure的簡單intro文章。</p><p>必須感謝前公司老闆，工作上的壓力，迫使我必須在短期內pick-up許多進階的SQL技能，而且是要可以發揮到實戰上的。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/662/1*spRhs2-bNagmLwLqQEIjpg.png" /><figcaption>當時一個週末硬嗑下所有Oracle stored procedure的基本知識，隔週就開始在公司維運+開發。</figcaption></figure><p>而在公司內部，更進一步SQL技巧文章，或是針對公司維運的指南文件，基本上都是存在公司內部文件庫。</p><h3>回歸正題，轉職開心嗎?</h3><p>坦白來說，轉職過程是很開心的，能夠在不同面試場合了解試場需求，對於在<strong>半導體通路商 資料工程師</strong>，<strong>工作內容也很感興趣且很有成就感。</strong>覺得自己幸運被擺在重要的數據中台位置。<em>但工作也許就是有一好沒兩好。</em></p><p>上工以後，除了做SQL的學習與開發，</p><ul><li>也必須維護官網：基於wordpress維護html, css, js code，並依需求改寫。</li><li>維護公司內部data pipeline：使用了SAP data service，整套來說是SAP BODS，涵蓋了日常資料流，也可以做簡易的自動化報表產製)。以及其他小型的ETL工具，結合mail server做到自動告警等機制。</li><li>必須實作tableau專案，特別是部長級以上需要查看的儀表版。</li></ul><p>儘管工作內容認為很滿意，但對於組織文化與氛圍，卻不盡人意。儘管可以說是老闆的用心，但表達方式仍讓團隊成員感到相當壓迫與不愉快。</p><blockquote><em>結果就是選擇離職，重新回到銀行工作崗位，做著專案，做著BA的工作。</em></blockquote><h4>現在過得好嗎?</h4><p>就是普普通通，工作環境是好的，工作內容也是普普通通。團隊氛圍很好，大家幾乎都是秉持著利他精神在互助，也會經常做資訊交流，確保資訊對稱。</p><p>現在就是…幾乎是不需要碰任何程式碼。</p><p>如果重選一次，知道高壓環境很痛苦，我還是會找一個一樣是做資料工程有關的工作，但也只能祈禱不會遇到情緒化的老闆。</p><h4>感謝收看到這裡的尼~</h4><p>如果一樣是喜歡資料分析的工作，千萬千萬，不要放棄了自己的理想~</p><p>加油!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2e032d14b402" width="1" height="1" alt=""><hr><p><a href="https://medium.com/jimmy-wang/%E8%BD%89%E8%81%B7%E8%B3%87%E6%96%99%E5%B7%A5%E7%A8%8B%E5%B8%AB%E4%BB%A5%E5%BE%8C-%E5%AF%AB%E6%96%87%E7%AB%A0%E6%AF%94%E8%BC%83%E9%96%8B%E5%BF%83%E5%97%8E-2e032d14b402">轉職資料工程師以後，寫code寫文章比較開心嗎?</a> was originally published in <a href="https://medium.com/jimmy-wang">jimmy-wang</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Book Summary_MIT最打動人心的溝通課：組織心理學大師教你謙遜提問的藝術]]></title>
            <link>https://medium.com/jimmy-wang/book-summary-mit%E6%9C%80%E6%89%93%E5%8B%95%E4%BA%BA%E5%BF%83%E7%9A%84%E6%BA%9D%E9%80%9A%E8%AA%B2-%E7%B5%84%E7%B9%94%E5%BF%83%E7%90%86%E5%AD%B8%E5%A4%A7%E5%B8%AB%E6%95%99%E4%BD%A0%E8%AC%99%E9%81%9C%E6%8F%90%E5%95%8F%E7%9A%84%E8%97%9D%E8%A1%93-4c7005748565?source=rss-2c7cfbfab06------2</link>
            <guid isPermaLink="false">https://medium.com/p/4c7005748565</guid>
            <category><![CDATA[book-review]]></category>
            <category><![CDATA[humble-inquiry]]></category>
            <dc:creator><![CDATA[ChunJen Wang]]></dc:creator>
            <pubDate>Mon, 23 May 2022 15:43:24 GMT</pubDate>
            <atom:updated>2022-05-23T15:45:37.234Z</atom:updated>
            <content:encoded><![CDATA[<h4><a href="https://www.books.com.tw/products/0010660316">Humble Inquiry:The Gentle Art of Asking Instead of Telling</a></h4><ul><li>原文作者： <a href="https://search.books.com.tw/search/query/key/Edgar+H.+Schein/adv_author/1/">Edgar H. Schein</a></li><li>譯者： <a href="https://search.books.com.tw/search/query/key/%E5%BE%90%E4%BB%95%E7%BE%8E/adv_author/1/">徐仕美</a>, <a href="https://search.books.com.tw/search/query/key/%E9%84%AD%E7%85%A5%E6%98%87/adv_author/1/">鄭煥昇</a></li><li>出版社：<a href="https://www.books.com.tw/web/sys_puballb/books/?pubid=cwpc">天下文化</a></li><li>出版日期：2014/12/26</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/611/1*ERpLLaz6y022p0LKtGr5qQ.png" /><figcaption>Source: <a href="https://www.pinterest.com/pin/360217670173543298/">https://www.pinterest.com/pin/360217670173543298/</a></figcaption></figure><h4>什麼是謙遜提問（Humble Inquiry）？</h4><blockquote>謙遜提問是一門引導別人打開心房，提出自己不知道答案的問題，而且出於好奇與興趣，與他人建立關係的高超藝術。</blockquote><p>作者彙整了他從事顧問業50餘年的經驗，精煉出謙遜提問的概念，幫助企業在避免災難──特別是上司與下屬的關係建立、良好溝通，謙遜提問是關鍵因素。</p><h4>工作與生活中的三種謙遜</h4><ol><li><strong>基本的謙遜</strong>：位處長者或顯貴達人面前，感到謙卑的謙遜。<br>［來自於地位、血統／不是選擇，而是必然］</li><li><strong>選擇性謙遜：</strong>面對成就非凡的菁英或成功人士，感到心存敬畏的謙遜。<br>［因為成就可累積的文化而選擇向其看齊］</li><li><strong>當下的謙遜: </strong>因為自覺無法獨自完成任務，產生對他人依賴感。<br>就如過去曾當過學生向老師請教、學徒向師傅請益</li></ol><h4>實踐謙遜應該做的三件事</h4><ol><li>少說教，避免單方面告訴他人事情</li><li>讓別人知道我們「聽到了」</li><li>學習使用「謙遜提問」來提問</li></ol><p>而在這個世界上，已經有許多書籍談論「說」、「聽」的技巧與實作，唯「問問題」這項社交藝術較少被深入研究。</p><p>也因為身在鼓勵「說」的文化，不擅於「提問」似乎就變得理所當然，但為什麼只靠「說」不好？ 因為主動的<strong>「說」，本身就是一種上對下的說教感</strong>，特別是當碰上了<strong>不請自來的教</strong>我，更是讓人不自覺地不耐煩，也有被冒犯的感覺。</p><blockquote>若希望與人建立良好的連結，就必須在互動中展現出平等與均衡感。<br>而「謙遜提問」就是投資你的注意力與關心。</blockquote><p>藉著問問題，傳達出「我想聽你說話，也等於向你示弱」。如果真的獲得了有用的資訊，那麼投資便有了回報。得到新知的過程也適時表達感激，並在問與答良性循環，與對方建立起信任。</p><h4>提問的四種分類</h4><ol><li><strong>謙遜提問：</strong>承認自己的無知，不帶任何偏見的虛心求教<br>[所以呢…／發生什麼事?／能夠打個比方說嗎?]</li><li><strong>診斷式提問：</strong>分為感受與反應類、起因與動機類、行動導向、系統性問題<br>[對這種安排，你的感受是?／你覺得他們為什麼選擇這麼做?]</li><li><strong>對質性提問：</strong>提問時<em>加入你自己的想法</em>，但維持問題的形式<br>[你不生氣嗎?／你覺得他們是因為害怕才這麼做嗎?]</li><li><strong>過程導向式提問：</strong>過程導向著重關係本質，讓雙方確認是否達到自己的表達目標，在嘗試化解尷尬的過程，重新來過。<strong><br><em>謙遜:</em></strong><em> </em>[我是不是問太多了? ／這個問題會不會太私人?]<br><strong><em>診斷:</em></strong><em> </em>[你怎麼決定用這麼特別的方式與我分享這些感受?]<br><strong><em>對質:</em></strong><em> </em>[我的問題是不是刺激到你了?]</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/737/1*hYuwpGmznPahaQkSnjPZQw.png" /><figcaption>Source: <a href="https://slideplayer.com/slide/14055841/">https://slideplayer.com/slide/14055841/</a></figcaption></figure><h4>事後檢討與反省自己的行為</h4><p>學會放慢腳步、改變速度、用心、發揮創意，就能有餘裕發展出自省。這在高效團隊中也很常見。例如在Scrum每執行完一輪後，會有retrospective與review；或是任務失敗時的lesson-learned紀錄等等。</p><p>過程檢討要能發揮作用，必須要暫時放下階級文化，讓團隊任何一人都能有話直說，提出彼此的看法。</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4c7005748565" width="1" height="1" alt=""><hr><p><a href="https://medium.com/jimmy-wang/book-summary-mit%E6%9C%80%E6%89%93%E5%8B%95%E4%BA%BA%E5%BF%83%E7%9A%84%E6%BA%9D%E9%80%9A%E8%AA%B2-%E7%B5%84%E7%B9%94%E5%BF%83%E7%90%86%E5%AD%B8%E5%A4%A7%E5%B8%AB%E6%95%99%E4%BD%A0%E8%AC%99%E9%81%9C%E6%8F%90%E5%95%8F%E7%9A%84%E8%97%9D%E8%A1%93-4c7005748565">Book Summary_MIT最打動人心的溝通課：組織心理學大師教你謙遜提問的藝術</a> was originally published in <a href="https://medium.com/jimmy-wang">jimmy-wang</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[系統設計入門：Security and HTTPS]]></title>
            <link>https://medium.com/jimmy-wang/%E7%B3%BB%E7%B5%B1%E8%A8%AD%E8%A8%88%E5%85%A5%E9%96%80-security-and-https-2befb8bf8d4b?source=rss-2c7cfbfab06------2</link>
            <guid isPermaLink="false">https://medium.com/p/2befb8bf8d4b</guid>
            <category><![CDATA[https]]></category>
            <category><![CDATA[tls]]></category>
            <category><![CDATA[ssl]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[design-systems]]></category>
            <dc:creator><![CDATA[ChunJen Wang]]></dc:creator>
            <pubDate>Fri, 20 May 2022 00:13:14 GMT</pubDate>
            <atom:updated>2022-05-20T00:13:14.607Z</atom:updated>
            <content:encoded><![CDATA[<p>網路安全對於所有的系統設計是非常關鍵的，但通常也已經跳脫了原先系統設計的範疇。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GjddSEkCWgpvSAUgJB2InA.png" /></figure><h4>Man-In-The-Middle Attack 中間人攻擊</h4><p>攻擊者截獲在兩端(C-S model)通訊過程中的資料，甚至進行中間資料(ip packet)傳遞過程中的篡改，導致變成惡意攻擊的資料包。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/910/0*udX3OAAK1ZoWhsXo.png" /><figcaption>Source: <a href="https://cheapsslsecurity.com/blog/types-of-man-in-the-middle-attacks/">https://cheapsslsecurity.com/blog/types-of-man-in-the-middle-attacks/</a></figcaption></figure><h3>Encryption 加密</h3><ol><li><strong>Symmetric Encryption 對稱加密</strong><br>- 1 Key，使用同一個密鑰來執行加密和解密<br>- 必須確保這個Key在C-S model中共享不會被竊取<br>- 長度通常設置為128或256位元</li></ol><h4>AES (Advanced Encryption Standard)</h4><p>美國政府公開徵選用來取代 DES 加密法的一種新型加密法，適用於對稱加密，為目前最廣泛運用的方法。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hehWzEhDEd6RrReTX-yraw.png" /><figcaption>Source: <a href="https://www.techtarget.com/searchsecurity/definition/Advanced-Encryption-Standard">https://www.techtarget.com/searchsecurity/definition/Advanced-Encryption-Standard</a></figcaption></figure><p><strong>2. Asymmetric Encryption 非對稱加密<br></strong> - 又稱為公鑰加密<strong><br></strong> - 2 Keys，使用一個密鑰來加密數據，再使用另一個密鑰來解密<br>- 分別有public key與private key</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vulmgjjer4zMrVBfrpfasw.png" /></figure><h3>HTTPS</h3><p>為HTTP + TLS。</p><h4>TLS (handshake), Transport Layer Security</h4><p>TLS，中文為傳輸層安全，是一種安全協議。<br>驗證另一個系統是否支持 TLS，這個過程稱為TLS handshake。</p><h4>SSL (certificate), Secure Sockets Layer</h4><p>用作HTTPS連接中 TLS handshake的一部分。是用來防禦中間人攻擊的手段。安裝了有效 SSL/TLS 證書的網頁在搜索欄中的網站名稱前會顯示“https”。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/813/1*QaabwYcLyGsNt_OEu_ko0w.png" /></figure><p>範例流程如：</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/554/0*h_oa0OzfLlxzWhwx.gif" /><figcaption>Source: <a href="https://www.ibm.com/docs/en/ibm-mq/7.5?topic=ssl-overview-tls-handshake">https://www.ibm.com/docs/en/ibm-mq/7.5?topic=ssl-overview-tls-handshake</a></figcaption></figure><p><em>其他常見的攻擊方式:</em><br>1. <a href="https://cheapsslsecurity.com/blog/types-of-man-in-the-middle-attacks/">8 Types of Man in the Middle Attacks You Need to Know About</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2befb8bf8d4b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/jimmy-wang/%E7%B3%BB%E7%B5%B1%E8%A8%AD%E8%A8%88%E5%85%A5%E9%96%80-security-and-https-2befb8bf8d4b">系統設計入門：Security and HTTPS</a> was originally published in <a href="https://medium.com/jimmy-wang">jimmy-wang</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[系統設計入門：MapReduce]]></title>
            <link>https://medium.com/jimmy-wang/%E7%B3%BB%E7%B5%B1%E8%A8%AD%E8%A8%88%E5%85%A5%E9%96%80-mapreduce-eb5cd8062514?source=rss-2c7cfbfab06------2</link>
            <guid isPermaLink="false">https://medium.com/p/eb5cd8062514</guid>
            <category><![CDATA[mapreduce]]></category>
            <category><![CDATA[design-systems]]></category>
            <category><![CDATA[hadoop]]></category>
            <dc:creator><![CDATA[ChunJen Wang]]></dc:creator>
            <pubDate>Sun, 15 May 2022 01:28:43 GMT</pubDate>
            <atom:updated>2022-05-15T01:28:43.018Z</atom:updated>
            <content:encoded><![CDATA[<p>是一種coding模式，透過各個cluster並行分布式算法。</p><p>MapReduce的組成步驟：</p><ol><li>Map：將資料分割成各個區塊(cluster)，進行Map函數，並將其轉換成中間的key-value pairs。</li><li>Shuffle：重新組織Map層的key-value pairs。</li><li>Reduce：對重新洗牌的key-value pairs進行Reduce函數，並將其轉換為有意義的資料。</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xT6FB3FByt0HzmjinJ0mBg.png" /></figure><h4>以Hadoop的MapReduce為例</h4><p>假如今天想要計算一段字詞出現的頻率，其背後的運算邏輯是如何進行的?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W6YXYF21g0uGnWOlNHReFQ.png" /></figure><p>(1) input資料: 可以是一段文字、一欄資料等等<br>(2) 分割資料<br>(3) 進行字詞比對，計算數量 (<strong>Mapping</strong>)<br>(4) 從新進行計算筆數 (<strong>Shuffing</strong>)<br>(5) 整合計算 (<strong>Reducer</strong>)<br>(6) output資料: 組合成字詞出現頻率表</p><h4>概念出處</h4><p><a href="https://static.googleusercontent.com/media/research.google.com/zh-TW//archive/mapreduce-osdi04.pdf">Dean, J., &amp; Ghemawat, S. (2004). <br>MapReduce: Simplified data processing on large clusters.</a></p><h4>不僅是把資料分割做計算！</h4><p>試想把資料分割，進行Mapping在分布式的系統中，我們有好幾台server可以同時運作，透過分割、Mapping的過程，就可以把一個相當大的程序，直接分派到各台server上去執行。</p><blockquote>原本集中在Master執行的工作，在Mapping後，分派到Slave上執行</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/756/1*j0bmyIr72rmimINLph66xQ.png" /></figure><h4>現實上的挑戰：<br>選擇問題需要使用到的Mapping／Reduce function</h4><p>實際上許多問題並不只是計算詞頻，但我們可以如何將執行工作進行MapReduce的結構，提升計算效率，需要依據要執行的。</p><p>也需要注意分割執行的大小。<br>如 HDFS塊(Hadoop Distributed File System)的大小默認為 64 MB。</p><p>並確保分割的執行的task有被正確執行，如Hadoop MapReduce會以一個Job作為最上層，底下分割出去的task則由task tracker監控，並確保每一段分割執行的task有被完成與其執行時間。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EAT_H7eZBU5BKMcB9vOp_g.png" /></figure><p>參考資料：<br>1. <a href="https://hadoop.apache.org/">Hadoop</a><br>2. <a href="https://static.googleusercontent.com/media/research.google.com/zh-TW//archive/mapreduce-osdi04.pdf">MapReduce: Simplified data processing on large clusters.</a><br>3. <a href="https://www.mssqltips.com/sqlservertip/3222/big-data-basics-part-5-introduction-to-mapreduce/">Big Data Basics — Part 5 — Introduction to MapReduce</a><br>4. <a href="https://www.guru99.com/introduction-to-mapreduce.html">Guru99: What is MapReduce in Hadoop? Architecture | Example</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eb5cd8062514" width="1" height="1" alt=""><hr><p><a href="https://medium.com/jimmy-wang/%E7%B3%BB%E7%B5%B1%E8%A8%AD%E8%A8%88%E5%85%A5%E9%96%80-mapreduce-eb5cd8062514">系統設計入門：MapReduce</a> was originally published in <a href="https://medium.com/jimmy-wang">jimmy-wang</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>