Phi-2 vs Phi-3大語言模型初探

Phi-2 模型介紹

官方介紹: https://www.microsoft.com/en-us/research/blog/phi-2-the-surprising-power-of-small-language-models/

Phi-2 是一個擁有27 億個參數的 Transformer。它使用與Phi-1.5相同的資料來源進行訓練,並使用由各種 NLP 合成文字和過濾網站組成的新資料來源進行了增強(出於安全性和教育價值)。當根據測試常識、語言理解和邏輯推理的基準進行評估時,Phi-2 在參數少於 130 億的模型中展示了近乎最先進的性能。

Phi-3模型介紹

官方介紹: https://azure.microsoft.com/en-us/blog/introducing-phi-3-redefining-whats-possible-with-slms/

Phi-3-Mini-128K-Instruct 是一個擁有 38 億參數的輕量級最先進的開放模型,使用 Phi-3 資料集進行訓練。該數據集包括合成數據和經過過濾的公開網站數據,重點是高品質和推理密集屬性。

在初始訓練後,該模型經歷了訓練後過程,其中包括監督微調和直接偏好優化,以增強其遵循指令和遵守安全措施的能力。當根據測試常識、語言理解、數學、編碼、長期上下文和邏輯推理的基準進行評估時,Phi-3 Mini-128K-Instruct 在模型中展示了強大且最先進的性能130 億個參數。

指令實測

模型角色設定: You are a data organizer and will summarize the entered articles.

輸入文字:

Spotlight on Disability:IN Partners using technology to enhance the accessibility of products we use every day.
Amtrak
Amtrak Provides Accessibility Upgrades at Utah Stations

WASHINGTON, DC – Amtrak customers can enjoy a more accessible and comfortable experience at the Green River and Helper, Utah stations following the completion of $5 million in upgrades. Amtrak’s California Zephyr stops twice daily at each station while traveling between Chicago and Emeryville,

Apple
The Right Shortcuts Can Give Your iPhone Superpowers. Here’s How.| WashingtonPost.com

Take the pain out of tedious tasks with Apple’s Shortcuts app.

Aira
Free Aira Access Offers by State & Province | Aira.io

At Aira, we are committed to expanding access to visual information for everyone. In this spirit, we work with Access Partners all over who provide Aira for free to their students, customers, residents, and visitors. This means anyone who is at one of the below Access locations can open the Aira app on their smartphone and instantly be connected to a professional visual interpreter. If you’re interested in finding out where you can connect with a visual interpreter for free in your state of province, read on.

AWS
Announcing Accessibility Conformance Reports (ACRs) in AWS Artifact

Accessibility Conformance Reports (ACRs) for AWS products and services are now available on AWS Artifact, a self-service portal for AWS compliance-related information. ACRs are documents that demonstrate the accessibility of AWS services.

Through AWS Artifact, you can download ACRs on-demand to understand the accessibility of a specific AWS product or service. AWS ACRs utilize the ITI Voluntary Product Accessibility Templates (VPAT®) and reference various accessibility standards including Section 508 (U.S.), EN 301 549 (EU), and Web Content Accessibility Guidelines (WCAG).

Google
The Best Google Docs Keyboard Shortcuts for Boosting Your Productivity | Wired.com

Learn how to use keyboard shortcuts instead of mouse clicks for common tasks in Google Docs. You might be surprised at how much time you save.

Starbucks
All the Changes Starbucks Made to Its Cold Cups and Lids to Reduce Plastic and Help Visually Impaired People

The Starbucks tall, grande and venti cups will now all use the same lid.

輸出回應 – phi-2-GGUF

模型名稱: TheBloke/phi-2-GGUF/phi-2.Q2_K.gguf

模型首頁: https://huggingface.co/TheBloke/phi-2-GGUF

模型回應:

心得: 看不出關聯性…這根本不相關吧?

To remove a tree stump, cut down the tree first

How can you make sure the tree is cut off completely? Cut it with a chainsaw.

If you’re like most people, your backyard has an old tree stump that took up too much space and is now dead wood waiting for you to get rid of. Or perhaps you have a dead tree stump in front of your house that needs to come down soon. Either way, it’s time for the stump to go.

But before you can cut down that old tree stump and remove it, you need to know how to cut it correctly.

The first step is removing all branches from around the trunk. This will make your cutting easier.

Once your tree has been removed and all of its branches have been cut off, it’s time to start thinking about removing that stump. You can either rent a stump grinder or cut down the tree yourself. If you decide to do this, remember that there are two main ways in which to remove a tree:

  • Using a chainsaw
  • With an axe

The first method is easy to figure out and we’ll discuss it here. The second option requires a lot more experience (and, yes, a bit of courage), so if you don’t know how to use an axe or a chainsaw then you might want to leave that stump alone until you can call in the experts.

But first, what is a tree stump? Well, a tree stump is the portion of the tree that has been cut off after the entire trunk and branches have fallen. This is important because it lets you know when your tree has died or if it’s time to remove that tree from the ground. So how can you get this done?

Before we get into removing a tree, let’s talk about what happens inside trees during their lifetime (when they’re alive and not dead). As trees grow, their branches start out as leaves but eventually turn into woody tissue that is called “wood.” When the time comes for the tree to die, it starts shedding its old leafy leaves in order to let new ones emerge.

To cut down the entire tree, you have two options: cutting or grinding. Cutting requires a chainsaw and involves cutting branches one by one until all are gone. This is a much faster method if your tree is already dead or dying but it can also be dangerous if not done correctly. You’ll need to be very careful when you use the cutting method, especially if you don’t have experience in cutting down trees (or at least not with chainsaws).

Grinding a tree involves using an axe and/or chainsaw to cut through the trunk of the tree. This is one of the more dangerous methods because it involves cutting into the woody tissue that surrounds your living tree. It’s also time-consuming, requiring patience and skill in order to remove the stump completely.

When you need to cut down your tree (or even a branch), look out for branches and leaves around the trunk of the tree. If they aren’t there anymore, then it’s time to get cutting!

If you don’t have experience with cutting or grinding, start by removing branches from the outside until the inside is exposed. This will be helpful when you come to cut down your tree because once it dies or has been completely removed, there won’t be any leaves left on its trunk that could fall off and cause damage.

If you do have experience with cutting or grinding, make sure you get the whole job done right the first time around! If not, then look up some tips online about how to cut down your tree without damaging yourself or others. Remember, safety is key!

Finally, if you don’t know whether you can use a chainsaw or axe and you want to make sure that you’ll be safe when you do the job, talk to an expert first. They will guide you through the process of removing that tree stump before it’s too late!

輸出回應 – Phi-3-mini-4k-instruct-gguf

模型名稱: Phi-3-mini-4k-instruct-GGUF/Phi-3-mini-4k-instruct-Q8_0.gguf

模型首頁: https://huggingface.co/microsoft/Phi-3-mini-4k-instruct-gguf

模型回應:

心得: 還不賴,phi-3試滿多次不同的輸入,成果真的還不錯,而且token長度可以到128k

Accessibility Improvements in Transportation: Upgrades at Utah Amtrak Stations

Amtrak has completed $5 million in accessibility upgrades for Green River and Helper stations in Utah, enhancing travelers’ experiences with the California Zephyr service. This investment ensures a more inclusive transportation system that caters to passengers with disabilities by improving station facilities.

Apple Shortcuts App: Streamlining iPhone Tasks for Enhanced Accessibility and Efficiency

The Apple Shortcuts app allows users to automate various tasks on their iPhones, providing a way to simplify daily routines and make technology more accessible to individuals with disabilities. The application’s customization options enable the creation of personalized shortcuts tailored for specific accessibility needs.

Aira: Connecting Visually Impaired Individuals Through Free AI-Powered Visual Interpretation Services

Aira, an innovative visual assistance platform, offers free access to its services through partnerships with Access Partners in various states and provinces. By connecting users of the Aira app with professional visual interpreters via their smartphones, visually impaired individuals can receive real-time guidance, making daily activities more manageable.

AWS Accessibility Conformance Reports: Enhancing Cloud Compliance and Inclusivity

Amazon Web Services (AWS) introduces the AWS Artifact platform to provide users with Accessibility Conformance Reports (ACRs), showcasing how each service adheres to accessibility standards like Section 508, EN 301 549, and WCAG. Users can download ACRs on-demand for a better understanding of AWS’ commitment to inclusivity in cloud computing services.

Google Docs Keyboard Shortcuts: Elevating Productivity with Accessibility Features

Adopting keyboard shortcuts in Google Docs reduces reliance on mouse clicks, improving accessibility and efficiency for users with motor disabilities or those who prefer a streamlined approach to document creation. Utilizing these shortcuts can significantly enhance workflow by reducing time spent navigating menus.

Starbucks’ Efforts in Reducing Plastic Waste and Enhancing Accessibility through Unified Cup Design

In its commitment to sustainability, Starbucks redesigned cold cups and lids across various sizes (tall, grande, venti) for reduced plastic waste. Moreover, the new uniform design also benefits visually impaired customers by simplifying identification of cup types and improving their overall experience at Starbucks outlets.

輸出回應 – phi-2-GGUF

模型名稱: TheBloke/phi-2-GGUF/phi-2.Q8_0.gguf

模型首頁: https://huggingface.co/TheBloke/phi-2-GGUF

模型回應:

心得: 雖然沒有太好但至少和原文有相關

  1. Amtrak customers can enjoy a more accessible and comfortable experience at the Green River and Helper, Utah stations following the completion of $5 million in upgrades.
  2. Aira offers free Visual Interpreter Access to their customers, residents, visitors at specific Access locations.
  3. All Starbucks’ tall, grande and venti cups will now use the same lid.
  4. Apple’s Shortcuts app can be used to take the pain out of tedious tasks with shortcuts and commands.
  5. ACRs are documents that demonstrate the accessibility of AWS services.
  6. Google Docs has keyboard shortcuts for common tasks which can save users time.
  7. Starbucks has made changes to their cold cups and lids in order to reduce plastic waste and help visually impaired people.

輸出回應 – phi-2-GGUF

模型名稱: kroonen/phi-2-GGUF/phi-2_Q8_0.gguf

模型首頁: https://huggingface.co/TheBloke/phi-2-GGUF

模型回應:

心得: 只剩下最後一項星巴克的內容了…

The article reports on the changes made by Starbucks to its cups and lids in order to reduce plastic waste and improve accessibility for visually impaired customers. The new design features a single lid that fits across most sizes of cups, eliminating the need for different types of lids. The article also mentions some of the other benefits of the new design, such as reducing foam leakage and making it easier to recycle.

輸出回應 – dolphin-2_6-phi-2.Q8_0.gguf

模型名稱: TheBloke/dolphin-2_6-phi-2-GGUF/dolphin-2_6-phi-2.Q8_0.gguf

模型首頁: https://huggingface.co/TheBloke/dolphin-2_6-phi-2-GGUF

模型回應:

心得: 摘要能力算還不錯

Disability:IN Partners is using technology to enhance accessibility of products we use every day. For example, Amtrak has upgraded its stations in Utah to make it more accessible for customers with disabilities. Apple’s Shortcuts app helps users save time by automating tedious tasks on their iPhones. Aira offers free access to visual information through their app for those who need it, and AWS provides Accessibility Conformance Reports (ACRs) to demonstrate the accessibility of their products and services. Google Docs keyboard shortcuts can boost productivity while Starbucks has made changes to its cups and lids to reduce plastic waste and help visually impaired people.

探索LM Studio:輕鬆測試和部署開源大型語言模型

在人工智能快速發展的今天,大型語言模型(LLM)已成為自然語言處理領域的重要工具。然而,對於許多開發者和AI愛好者來說,如何在本地環境中測試和部署這些強大的模型仍然是一個挑戰。這就是LM Studio發揮作用的地方,它為我們提供了一個便捷的平台,讓我們能夠輕鬆地探索各種開源LLM模型的潛力。

LM Studio:您的本地AI實驗室

LM Studio是一款專為測試和運行開源大型語言模型設計的應用程序。它的界面直觀易用,使得即使是AI領域的新手也能快速上手。通過LM Studio,您可以在自己的電腦上部署各種GPT模型,實現離線AI聊天機器人的功能,這不僅保護了隱私,還為AI應用的開發提供了更大的靈活性。

安裝LM Studio:開啟您的AI之旅

要開始使用LM Studio進行LLM模型的測試,首先需要完成安裝過程。以下是詳細的步驟:

  1. 訪問LM Studio官網:https://lmstudio.ai/
  2. 點擊”Download”按鈕,選擇適合您操作系統的版本。
  3. 下載完成後,按照提示完成安裝。

安裝過程簡單直接,很快您就能開始探索開源LLM模型的世界了。

成功安裝LM Studio後,您會發現它的界面設計非常直觀。主要功能區域包括:

  • 模型選擇區:這裡列出了您可以使用的各種開源LLM模型。
  • 聊天界面:您可以在這裡與選定的AI模型進行對話,測試其自然語言處理能力。
  • 參數設置區:調整模型的各項參數,優化AI的表現。
LM Studio的界面:功能一目了然

這樣的設計使得測試和比較不同的GPT模型變得輕而易舉,為您的AI實驗提供了理想的環境。

LM Studio介紹

LM Studio 是一款跨平台的桌面應用程式,可讓您輕鬆探索和使用本地和開源的大型語言模型 (LLM)。它提供了一個簡單但功能強大的模型配置和推理用戶界面,讓您可以輕鬆下載和運行任何與 ggml 兼容的模型來自 Hugging Face。

LM Studio 的主要功能包括:

  • 瀏覽和搜索來自 Hugging Face 的大量 ggml 兼容模型
  • 一鍵下載和安裝模型
  • 配置模型參數,例如溫度和頂級 P
  • 以多種格式生成文本、翻譯語言、編寫不同類型的創意內容以及以信息豐富的方式回答您的問題
  • 使用 GPU 加速推理(如果可用)

LM Studio 非常適合以下人群:

  • 對 LLM 感興趣的開發人員和研究人員
  • 想要嘗試使用 LLM 創建新應用程序的人
  • 需要使用 LLM 完成任務的任何人,例如編寫、翻譯或研究

使用 LM Studio 的優點:

  • 易於使用:LM Studio 具有簡單的用戶界面,即使是沒有 LLM 經驗的人也可以輕鬆使用。
  • 功能強大:LM Studio 提供了一系列功能,可讓您充分利用 LLM。
  • 可擴展:LM Studio 支持大量 ggml 兼容模型,並且不斷添加新模型。
  • 開源:LM Studio 是開源的,這意味著您可以自由使用和修改它。

開始使用 LM Studio

要開始使用 LM Studio,您需要先下載並安裝桌面應用程序。您可以從 LM Studio 網站: https://lmstudio.ai/ 下載應用程序。

安裝應用程序後,您需要創建一個 Hugging Face 帳戶。如果您已經有帳戶,則可以直接登錄。如果您沒有帳戶,則需要註冊新帳戶。

登錄後,您將能夠瀏覽和搜索來自 Hugging Face 的所有 ggml 兼容模型。找到您要使用的模型後,您可以單擊“下載”按鈕將其下載到您的計算機。

下載模型後,您可以單擊“運行”按鈕開始使用它。LM Studio 將打開一個新窗口,您可以在其中配置模型參數並生成文本。

有關 LM Studio 的更多信息,請參閱 用戶指南: https://lmstudio.ai/docs

下載模型的位置

下載的本地端模型預設會放在C:\Users\{USER_NAME}\.cache\lm-studio\models

若想要改變儲存的位置,可選擇左列的資料夾,然後選擇Change,就可以改變預設儲存的資料夾囉

應用程式截圖

總結

LM Studio 是一個功能強大且易於使用的工具,可讓您探索和使用本地和開源的 LLM。如果您有興趣了解 LLM 或想使用它們來創建新應用程序,那麼 LM Studio 是值得一試的工具。

ChatGPT / Bing / Bard / Claude指南

一、介紹人工智慧

這邊主要是在說明人工智慧演進的過程,其實人工智慧的概念第一時間是在1950年時,由圖靈所提出,定義為一個人透過鍵盤和另一個對象溝通,如果施測者無法分辨與之對話的對象是人還是機器的話, 這個機器就被認為擁有「智慧

但這個時候人工智慧的實作方式還比較以符號邏輯(類似統計學這樣以符號代表抽象的概念)為主,但很難清楚的釐清人類的思考邏輯。後來專家系統時代,人類會嘗試針對每個領域的知識去化作一條條的規則

但是,人類所能表達的,遠比人類所知道的少(博藍尼悖論),因此我們很難很完整的把我們所知道的化作規則或思考邏輯來打造人工智慧。

從2010年至今,我們進入的資料至上的時代,也就是我們開始直接丟資料給電腦,由電腦去歸納、找出電腦自己看得懂的規則,這也是為什麼ChatGPT等生成式AI的結果帶有部分的不可控、不可預測性。

了解AI的演進過程可以讓我們了解當我們要選擇AI技術時,可能可使用的選擇。雖然2010年後的機器學習技術能夠做到最廣泛的通用人工智能,但是若我們的需求範圍較為侷限,或者需要非常高的可解釋性、準確性時,仍然可以考慮符號邏輯或專家系統的方式來實做。

這些演進的歷程都是現在生成式AI能夠出現的重要基礎,每一代之間的關係不是淘汰,而是一層層的進化。

二、基礎模型帶來AI再一次的革命

在這邊我強調了在ChatGPT出現之前的AI應用,大多都用在中、大型企業內部或智能相關產品的應用。但是ChatGPT出現之後,AI從產業研發進入全民有感,並且掀起了非常大的AI風潮。

這是因為基礎模型的出現,所謂基礎模型就是類似ChatGPT這樣用途可以非常廣泛,並且可以透過詞嵌入的方式,以非常快速簡單的prompt方式,打造不同的產品。

例如下圖中的GitHub Copilot、智慧錄音卡、Notion AI、AI心理諮商,其實都是使用ChatGPT的模型,卻可以使用在多種非常不同的應用場景上(心理安慰、生活便利、程式開發等不同用途)

這樣的一個基礎模型的出現,帶來開發AI應用的革命性變革,過去,有些AI應用程式可能需要我花上六個月、甚至一年的時間來建立,現在許多團隊可能一週就能完成

以ChatGPT的自製一個聊天機器人為例,現在只需要上傳一些機器人需要知道的文件資料、並且使用對話的方式指導機器人該如何正確回應,就可以擁有一個專屬的客製對話機器人

三、生成式AI相關的應用

有興趣的可以自行去研究、了解現在AI可以做到那些事情

文本生成(LLM)

圖像生成 (text-to-image)

音樂 / 聲音生成

程式碼生成

四、多模態應用

基礎模型另一個強大之處,在於可以結合視覺、聽覺、文字的輸入,以及對不同型態輸入資料的交叉理解,能夠讓AI朝【通用型人工智慧】更加靠近

五、善用AI為生產力的新動能

特點/模型Bard(Google)ChatGPT (OpenAI)ChatGPT Plus (OpenAI)Bing (Microsoft)Claude (Anthropic)
上下文窗口長度(Token)32K4K8K8K100K
推理能力不錯最佳最佳不明不錯
網路連接功能原生支持網路搜尋無法讀取網頁需連至Bing取得網頁內容所有用戶可用的連接功能無法讀取網頁
多模態能力支持文字、圖像、語音輸入支持圖像、語音及文字輸入,以及圖像、文字、檔案輸出支持文字輸入,圖像、文字輸出支持PDF等檔案的文字讀取
建議用途圖像辨識初次接觸者皆可資訊搜尋長文PDF摘要
費用免費免費每月$20美金免費免費
主要用途研究、資料分析、聊天程式碼開發、聊天多模態及與其他服務的串接應用網路搜尋、聊天研究、分析

AI成為生產力的新動能,用戶在人工智慧輔助下完成工作的效率要高得多

OpenAI Playground介紹

什麼是OpenAI Playground

教學文件:

https://platform.openai.com/docs/overview

OpenAI Playground(OpenAI 遊樂場)是OpenAI提供的一個線上平台,用於演示和測試他們的自然語言處理模型,例如GPT-3.5(本模型的基礎)。它允許用戶與模型進行互動,輸入文本並獲得模型的自動回應,以便演示其自然語言處理能力

OpenAI Playground通常用於展示GPT-3及其他相關模型的功能,並讓開發者和研究人員評估這些模型的效能以及探索其應用潛力。用戶可以在Playground上提出各種問題,構建對話,生成文字,從而了解模型如何處理不同的輸入。

此外,OpenAI Playground也提供一個用戶友好的界面,讓用戶可以輕鬆嘗試GPT-3及相關模型的能力,而無需自行設定或編程。這對於探索自然語言處理的應用,以及將這些模型集成到不同的應用中都非常有用。

在OpenAI Playground體驗與模型的互動

Playground 的完整版介面,可以提供各種模式和參數,通過調整無數其他可自定義選項來增強用戶體驗。在對話框的部分也可以使用語音輸入,或者上傳既有的語音檔,使用OpenAI語音轉文字的功能提供資料給Playground

下面是這個介面的一些功能

  1. 輸入現有文本供AI編輯:輸入一段現有的文本,然後要求模型對其進行編輯、修改或擴展。這讓您可以看到模型如何處理和改進您提供的文本,並且可以用於文本編輯和生成的場景。
  2. 使用溫度控制響應的隨機性: 溫度控制是一個重要的參數,它允許您調整模型生成文本的隨機性。較高的溫度值將增加生成文本的隨機性,而較低的溫度值將使生成文本更加確定和一致。這使得用戶可以根據需要調整生成文本的多樣性。
  3. 調整頻率以控制其相應的重複程度: 您可以使用不同的方法來調整生成文本中重複內容的頻率。這可以通過調整模型的參數來實現,以使生成的文本在某些情況下更具多樣性,或者在其他情況下更加一致。這樣,您可以根據具體的應用需求來調整生成文本的重複性。

這些功能和選項使用戶可以更好地控制模型的生成行為,以滿足不同的用例和需求。這使得OpenAI Playground成為一個有用的工具,用於測試、探索和改進自然語言處理應用,並理解模型的行為。

使用OpenAI語音轉文字功能

切到完整功能並且按麥克風的圖案,就可以上傳語音檔案,並使用Whisper轉成文字,這個功能已經開源了

OpenAI Playground的核心特性

支持多種型號的模型

OpenAI API 由具有不同功能和價格點的多種模型提供支援。您也可以透過微調,針對您的特定用例對我們的模型進行客製化

MODELDESCRIPTION
GPT-4 and GPT-4 Turbo一組改進 GPT-3.5 的模型,可以理解並產生自然語言或程式碼
GPT-3.5一組改進 GPT-3 的模型,可以理解並產生自然語言或程式碼
DALL·E
可以在自然語言提示下產生和編輯圖像的模型
TTS一組可以將文字轉換為聽起來自然的語音的模型
Whisper可以將音訊轉換為文字的模型
Embeddings一組可以將文字轉換為數字形式的模型
Moderation可以偵測文字是否敏感或不安全的微調模型
GPT base一組無需遵循指令即可理解並產生自然語言或程式碼的模型
Deprecated已棄用的型號的完整清單以及建議的替代品

我們也發布了開源模型,包括 Point-EWhisperJukeboxCLIP.

免程式碼將ChatGPT串接到LINE對話

使用工具 – FancyAI

FancyAI網址: https://www.fancyai.co/

可輕鬆使用GPT大語言模型知識庫,介面化匯入文件(PDF, CSV, TXT)或網址,讓FANCY AI迅速掌握您的知識進行問答。只需30秒,即可與LINE官方帳號整合,建立分享知識Bot連結。更有視覺化的工作流程編排和對話紀錄功能!

AI大模型問答介面,可設定你專屬AI回答流程

FANCY AI 能力

  • AI ChatGPT知識客服: 結合你自己專屬知識,ChatGPT 24/7 的為您的用戶服務
  • 超快速精準匯入處理:自動分段,輸入,拆成問答,多種方式讓您處理的數據 (支持PDF,CSV,TXT,網址)
  • 簡單直覺操作AI大模型問答介面:讓你設定你專屬AI回答流程,可以自訂預設開場白,選擇性問題,個性化你的AI
  • 30秒串接好LINE官方帳號,分享連結:結合你的知識庫,LINE官方帳號直接用ChatGPT不間斷服務。

步驟一、創建OpenAI開發者使用的密鑰

首先要去你的OpenAI開發者平台,創建你的API Keys: https://platform.openai.com/api-keys。這樣其他應用程式才可以呼叫你的OpenAI帳號下的API(然後扣你的錢)

接著就是要付款給OpenAI,點此付款: https://platform.openai.com/account/billing/overview。單次可購買$5~$95美金(也就是最低約150左右)

OpenAI的API使用需要付費,價格資訊如下: https://openai.com/pricing

由上圖可知道,OpenAI的API計費單位為Token,下面會解釋甚麼叫做Token,也可以線上去測試某段文字的Token數量是多少,可以更精準地了解可能的花費。

可選擇模型的比較

甚麼是Token

在 API 處理提示之前,輸入會被分解為Tokens 。這些Tokens並未準確地在單字開始或結束的位置進行切割 – Tokens可以包含尾隨空格甚至子單字。

以下是一些幫助理解Token長度的有用經驗規則:

  • 1 個標記 ~= 4 個英文字符
  • 1 個令牌 ~= 3/4 個單字
  • 100 個標記 ~= 75 個單字
  • 1-2 句 ~= 30 個標記
  • 1 段 ~= 100 個標記
  • 1,500 個單字 ~= 2048 個標記

Token切割測試工具: https://platform.openai.com/tokenizer

步驟二、創建Line Bot帳號並為串接做準備

首先要申請一個Line API串接的開發者帳號: https://developers.line.biz/console/

創建帳號流程如下:

設定你的LINE BOT帳號為使用Webhook

接著這邊是在分享時未設定的部分,就是把預設的固定回復關掉,開啟 LINE Official Account Manager

打開Webhook並且關閉自動回應訊息,這樣所收到的訊息才會傳到我們的API裡面

步驟三、創建FancyAI帳號

創建帳號之後,首先要把帳號和你的OpenAI綁定,點OpenAI帳號後,把剛剛第一步驟創建的Key貼進去,這樣FancyAI才能夠呼叫你的OpenAI API

Fancy AI: https://www.fancyai.co/

新建一個應用,選擇簡單對話

設定與Line的串接 – 設定API秘鑰

Line Channel Access Token: 瀏覽剛剛創建的Line帳號的頁面MessageAPI -> Channel access token -> Issue將出現的字串複製進去

Line Channel Secret位於Basic settings下方

接著告訴Line要API的webhook位置: 選擇”應用>你的應用名字>Line API”

把這邊的webhook網址貼到剛剛LINE Developer的webhook設定位置

接著就可以測試你的機器人囉!!

讓你的ChatGPT更強大 – PDF分析

讓ChatGPT可以上傳、分析PDF的好工具

這個工具可以讓ChatGPT可以閱讀內容很長的PDF檔案,而且不用Plus也可以使用,可以讓使用者就PDF的內容來發問,CHATGPT會依照PDF的內容來回答

現在有人開發了AI PDF的工具,也可以嘗試看看: https://chat.openai.com/g/g-V2KIUZSj0-ai-pdf

但是這個工具一定要付費的ChatGPT Plus才可使用,所以如果沒有Plus的人,可以使用下面的Chrome插件的方式

Chrome插件下載

ChatGPT Sidebar & File Uploader

啟用之後你的ChatGPT會增加上傳檔案的按鈕(非Plus用戶也可以唷!)

設定外掛

至下列網址設定外掛行為: chrome://extensions/

如果沒有設定的話,這個的Sidebar在每個站都會有,我在這邊讓他只能夠影響到ChatGPT這個站,下面的三個開關則請憑自己的喜好去設定

設定PDF檔案內容分段的prompt

這邊我是建議要改用中文來寫,不然他回答都會一直是英文,後面問答用中文問的效果也會很差,但一開始prompt就用中文下的話,回答的內容都還算正確

下面是我設定的值

Single Part Prompt

#zh-TW
下面是文件完整的資訊,請幫我做此文件資料的總結

Multi Part First Prompt

#zh-TW
我所分享的此份文件會被分成很多個部分,請等待我輸入所有部分,接著再做全部資料的總結,在這之前,請單單回應 “了解,我會等待其餘的部分輸入”

Multi Part Consecutive Prompts

#zh-TW
這是此份文件分段的其中一部份,請回應”了解,我會等待其餘部分的輸入”

Last Part Prompt

#zh-TW
這是最後一部分,請仔細地觀看全部的文件,在之後的問題中,回應我這份文件的相關資訊 ,請單單回應 “了解,我會整理從第一部份至最後一部分的資訊”

設定分段的長度

這邊可視你的ChatGPT的版本來設定,一般來說,就是Token長度,不可以超過長度上限

特點/模型Bard (Google)ChatGPT (OpenAI)ChatGPT Plus (OpenAI)Bing (Microsoft)Claude (Anthropic)
上下文窗口 長度(Token)32K4K8K8K100K
推理能力不錯最佳最佳不明不錯
網路連接功能原生支持網路搜尋無法讀取網頁需連至Bing取得網頁內容所有用戶可用的連接功能無法讀取網頁
多模態能力支持文字、圖像、語音輸入支持圖像、語音及文字輸入,以及圖像、文字、檔案輸出支持文字輸入,圖像、文字輸出支持PDF等檔案的文字讀取
建議用途圖像辨識初次接觸者皆可資訊搜尋長文PDF摘要
費用免費免費每月$20美金免費免費
主要用途研究、資料分析、聊天程式碼開發、聊天多模態及與其他服務的串接應用網路搜尋、聊天研究、分析

讓你的ChatGPT更強大 – Zapier AI Actions

Zapier是甚麼

Zapier 是一個無需編寫代碼的自動化工具,用於連接和自動化不同應用程序。它允許你創建自動化工作流程(Zaps),觸發事件(如新郵件)將啟動操作(如將附件上傳到雲端硬盤),提高生產力並節省時間。 Zapier 支持數千種應用程序,包括常見的工作工具、社交媒體和電子郵件服務。

在ChatGPT Plus使用API連接Zapier可以做到甚麼

與其他應用程式連動 – 通訊錄

與其他應用程式連動 – 日曆

與其他應用程式連動 – Gmail

如何建立連動

首先,你一定要付費成為ChatGPT Plus會員,這樣才會能夠在你的ChatGPT裡面串接外部API

接著,建立一個你自己專屬的My GPTs,選擇Create a GPT

接著,這邊有詳細的設定教學(https://actions.zapier.com/docs/platform/gpt)

首先,複製這串網址

https://actions.zapier.com/gpt/api/v1/dynamic/openapi.json?tools=meta

選擇最下面的Create new action,接著選擇Import from URL,把剛剛的網址貼上去

設定Zapier方的權限

這邊的設定就和ChatGPT本身無關,而是Zapier這邊的權限控管,如果ChatGPT的這個對話功能不會只有自己使用的話,也要教所有使用者如何允許ChatGPT去存取他的Zapier帳號

提供配置 URL

我們為您提供了一個支援自然語言參數的網址,供您在 GPT 中使用,您可以在其中指定操作名稱,也可以選擇包含特定欄位值詳細資訊。使用 https://actions.zapier.com/gpt/start 作為基礎。

它支援兩個可選的查詢參數:

  • setup_action 與操作名稱
  • setup_params 用於欄位指令(提供某些欄位值,例如進行 AI 猜測,或說不包含某些欄位)

例如,下面的連結將為 Google 日曆尋找電子郵件設定新操作,並將開始時間和結束時間欄位設為讓 AI 猜測.立即嘗試此處或造訪此網址:

https://actions.zapier.com/gpt/start?setup_action=google calendar find event&setup_params=set have AI guess for Start and End time

把下面的文字加入ChatGPT的Instructions欄位裡面,教導GPT如何引導使用者去開啟Zapier權限

###Rules:
- 在操作之前,我需要確認您是否已登入並設定了 Zapier 的 AI Actions。這是進行下一步所必需的。
- 假入已經登入的話,開始下面的步驟

###Instructions for Zapier Custom Action:
Step 1. 我將首先檢查您是否擁有完成此請求所需的 Zapier AI Actions。我會呼叫 /list_available_actions/ 來列出可用的操作。 假如REQUIRED_ACTION可以在AVAILABLE ACTIONS之中找到的話,則到Step 4,否則則到Step 2。

Step 2. 如果所需的操作不可用,我將向您發送所需操作的配置連結。您需要根據該連結配置 Zapier AI Action,並在完成後通知我。

Step 3. 一旦您確認已配置所需的操作,我將繼續處理您的原始請求。

Step 4. 使用在/list_available_actions/ 的JSON 回應中傳回的id 欄位(在results 陣列中),我將填寫運行操作所需的字串。我將根據您的請求填寫指令和任何其他必要的欄位。 

REQUIRED_ACTIONS:
- Action: Google Calendar Find Event
  Configuration Link: https://actions.zapier.com/gpt/start?setup_action=google%20calendar%20find%20event&setup_params=set%20have%20AI%20guess%20for%20Start%20and%20End%20time
- Action: Slack Send Direct Message
  Configuration Link: https://actions.zapier.com/gpt/start?setup_action=Slack%20Send%20Direct%20Message

日曆功能的GPT 演示

實驗心得

這個Action應該非常花費額度, 因為我的Plus沒呼叫幾個Action就會額度用完了,而且在呼叫Action的時候,或許是驗證問題,或許是額度不足失敗問題,會導致很多機會沒辦法照著我們的想法去走。

但是在ChatGPT內可以串接自己的API連接到自己的網站功能裡,真的非常強大,很期待日後系統越來越穩定,功能越來越健全後此功能的可能未來性

參考資料

Create custom versions of ChatGPT with GPTs and Zapier

AI Actions

YOLOv8使用範例

建模的範例

先用下面指令安裝好所需的套件

pip install ultralytics

然後在Roloflow下載要訓練的素材集,選擇YOLOv8

把裡面的資料(含data.yaml)解壓縮在同層資料夾下,如圖

接著直接執行下面的程式,yolov8會自動下載所需要的yolov8.yamlyolov8n.pt

import multiprocessing
import os
from ultralytics import YOLO
os.environ['CUDA_LAUNCH_BLOCKING'] = '1'

def my_function():
    model = YOLO('yolov8.yaml').load("yolov8n.pt")
    # Train the model
    model.train(data='./data.yaml', epochs=300, imgsz=640)
    model.val(data="./data.yaml")

if __name__ == '__main__':
    multiprocessing.freeze_support()  # Optional, if you're freezing the script
    my_function()

這時候會出現錯誤如下,因為資料集放在哪邊也是剛剛才自動下載的,所以我們要打開一下這個設定檔案,設定一下我們的資料集的正確位置(datasets_dir)

看到這些訊息就代表成功的開始建模型囉!

模型使用範例

重點是在這行

model = YOLO('best.pt')

這行在載入我們建好的模型

results = model(image, show=False, verbose=False)

model這個預測方法有很多可控制的參數,例如要不要直接秀出圖片、要不要存圖片等等

YOLOv8非常貼心的是在於說,其吐出的物件如result,只要print這個物件,就會有非常詳細的結構和屬性意義教學,在開發上非常的方便

import VideoStream
import cv2
import numpy as np
from ultralytics import YOLO


videostream = VideoStream.VideoStream((1280, 720), 30, 0).start()
cam_quit = 0
model = YOLO('best.pt')
# 繪製邊框和標籤
def detect(image):
    results = model(image, show=False, verbose=False)
    # Show the results
    result = list(results)[0]
    for i in range(len(result.boxes)):
        r = result[i].boxes
        cls = int(r.cls[0].item())
        xywh = r.xywh[0].tolist()
        x_center, y_center, width, height = [int(x) for x in xywh[:4]]
        if width < 100 and height < 100:
            x1 = int(x_center - (width / 2))
            y1 = int(y_center - (height / 2))
            x2 = x1 + width
            y2 = y1 + height
            cv2.rectangle(image, (x1, y1), (x2, y2), (0, 0, 255), 3)
            cv2.putText(image, result.names[cls], (x1, y1), cv2.FONT_HERSHEY_SIMPLEX, 0.8, (0, 255, 255), 1, cv2.LINE_AA) 

while cam_quit == 0:
    imageSource = videostream.read()
    imageSource = cv2.resize(imageSource, (960, 540))
    detect(imageSource)
    cv2.imshow("image", imageSource)
    key = cv2.waitKey(1) & 0xFF
    if key == ord("q"):
        cam_quit = 1

videostream.stop()
cv2.destroyAllWindows()

OBS開啟時可使用的相關指令

官方介紹

官方啟動指令介紹頁面: https://obsproject.com/kb/launch-parameters

如何使用啟動指令

要使用自定義啟動參數創建 OBS Studio 的捷徑:

  1. 複製一個指向 OBS Studio 的捷徑,或選擇一個已存在的捷徑(從「開始」菜單、工作欄等處)。
  2. 右鍵點擊捷徑,然後點擊「屬性」。
  3. 在目標欄位中,obs64.exe 路徑後面添加啟動參數(如左圖所示)。

若要通過計劃任務或其他自動方式啟動 OBS Studio,請確保也設置了工作目錄(「開始於…」),該目錄必須指向 obs64.exe 所在的文件夾。

啟動參數介紹

OBS Studio 支援的啟動參數(Launch Parameters)。這些參數用於自動化和便攜式使用。每個參數都有特定的功能,可以在啟動 OBS Studio 時進行特定的操作或設定。

參數及其描述如下:

  • --help, -h:獲取可用參數的列表。
  • --version, -v:獲取 OBS 的版本。
  • --startstreaming:自動開始直播。
  • --startrecording:自動開始錄影。
  • --startvirtualcam:自動開始虛擬攝影機。
  • --startreplaybuffer:自動開始重播緩存。
  • --collection "name":使用指定的場景集合啟動。
  • --profile "name":使用指定的配置檔啟動。
  • --scene "name":使用指定的場景啟動。
  • --studio-mode:啟動時啟用 Studio 模式。
  • --minimize-to-tray:啟動時最小化到系統托盤。
  • --portable, -p:使用便攜模式。
  • --multi, -m:啟動多個實例時不顯示警告。
  • --always-on-top:啟動時開啟「總在最前面」模式。
  • --verbose:使日誌更詳細。
  • --unfiltered_log:禁用日誌過濾(不抑制重複行)。
  • --disable-updater:禁用內置更新器(僅限 Windows/macOS)。
  • --allow-opengl:在 Windows 上允許 OpenGL 渲染器。
  • --only-bundled-plugins:僅使用內建模組啟動。
  • --safe-mode:強制 OBS 以安全模式啟動,禁用所有第三方插件、腳本和 WebSockets。
  • --disable-shutdown-check:禁用不潔關機檢測,該檢測會提示以安全模式啟動。
  • --disable-missing-files-check:禁用啟動時可能出現的缺失文件對話框。

這些參數提供了更多的控制和靈活性,使使用者可以根據自己的需求和工作流程自定義 OBS Studio 的啟動和運行方式。

JavaScript H.264 解碼器介紹 – Broadway

Broadway介紹

Broadway 是一個 JavaScript H.264 解碼器。H.264 是一個廣泛使用的視頻壓縮標準,Broadway 提供了一種在瀏覽器中,特別是不支持該格式的瀏覽器中,直接解碼 H.264 視頻的能力。

主要特點

  1. 純JavaScript:Broadway 是完全用 JavaScript 寫的,這意味著它可以在任何支持 JavaScript 的平台上運行,不需要任何外部插件或擴展。
  2. 多線程支持:Broadway 可以在主線程上運行,也可以在背景工作線程上運行,從而提高性能和響應性。
  3. 網頁集成:使用 Broadway,開發者可以輕鬆地在網頁上集成 H.264 視頻播放功能,無需依賴外部播放器或插件。

Live Demo

當首次訪問上述示範頁面時,可能會感覺視頻播放器的速度有點慢,這是因為它需要首先下載整個視頻才能開始播放。但請有耐心,一旦視頻下載完畢,您可以點擊播放器來觀看視頻。

上面的左上角播放器在主線程上運行,而其餘的播放器在背景工作線程上運行。

本機端使用範例

把Player資料夾內的檔案下載下來,放進本地端的node.js專案的Player資料夾內

檔案連結: https://github.com/mbebenita/Broadway/tree/master/Player

接著撰寫node.js程式

const express = require('express');
const http = require('http');
const path = require('path');
const socketio = require('socket.io');

let eApp = express();
let server = http.Server(eApp);
let io = socketio(server, { pingInterval: 3000, pingTimeout: 60000 });

// 設定靜態檔案的路徑
eApp.use(express.static(path.join(__dirname, '..', 'Player')));

io.on('connection', (socket) => {
    console.log('A user connected');
    socket.on('disconnect', () => {
        console.log('A user disconnected');
    });
});

let config = {
    port: 8080  // 依您的URL端口設定為8080
};
server.listen(config.port, '0.0.0.0', () => {
    let address = server.address();
    console.log(`Server running at ${address.address}:${address.port}`);
});

接著開啟電腦的http://127.0.0.1:8080/treeDemo.html,就可以在本機運行可動的範例了