陳子傑
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # GDG Build with AI 臺北場 - Gemini 2.0 Flash最新功能動手做 個人活動整理筆記 > [time=2025/2/12] > [name=製作人:陳子傑 x NTPU GDG on campus] - [📌Overview](#📌Overview) - [Gemini](#Gemini) - [Vertex AI](#Vertex-AI) - [Google AI Studio](#Google-AI-Studio) - [Google Gen AI SDK](#Google-Gen-AI-SDK) - [📌Gemini 2.0 突出特點](#📌Gemini-2.0-突出特點) - [📌Gemini 2.0 新功能](#📌Gemini-2.0-新功能) - [2.0 Flash Thinking Experimential](#2.0-Flash-Thinking-Experimential) - [2.0 Flash Thinking Experimential with apps](#2.0-Flash-Thinking-Experimential-with-apps) - [📌實際操作一次Google Gen AI SDK(活動現場限定)](#📌實際操作一次Google-Gen-AI-SDK(活動現場限定)) - [環境設定](#📌實際操作一次Google-Gen-AI-SDK(活動現場限定)) - [Config調整參數以調整模型請求](#5.-Config調整參數以調整模型請求) - [多模態輸入](#6.-多模態輸入) - [Live API](#7.-Live-API) - [Thinking Model](#8.-Thinking-Model) ## 📌 Overview ### Gemini - **多模態輸入與輸出**: - 支援文字、圖片、影片、程式碼、音訊等多種格式的輸入。 - 可生成文字、圖片、程式碼等多樣化輸出。 - **超長上下文窗口**: - 上下文窗口可達 **100 萬到 200 萬 Token**。 - 可更好地處理長篇內容,如長達兩小時的影片。 ### Vertex AI Google Cloud 提供的強大機器學習平台,支援開發者建構、部署和擴展機器學習模型。 - **整合 Gemini**:提供對 Gemini 模型的全面支持。 - **生產就緒**:具備模型訓練、部署、監控等功能,可快速部署至生產環境。 ### Google AI Studio 一個基於瀏覽器的免費開發環境,簡單易用,幫助開發者快速使用 Gemini API。 - **直覺式界面**:適合新手開發者進行實驗與原型設計。 ### Google Gen AI SDK 幫助開發者將 Google 生成式 AI(包括 Gemini)整合到應用程式中。 - **簡化整合**:簡單易用的 API,可快速處理模型選擇、參數調整等。 - **多語言支持**:支援 **Python、Java、JavaScript** 等程式語言。 ## 📌Gemini 2.0 突出特點 1. 表現優秀 2. Response可原生生成文字、圖片、音源(直接原生生成,不用額外調用其他模型) 3. Native Tool Use - Code Execution : 能夠在生成程式碼後直接執行測試,無需跳轉到其他環境,生成程式碼後即直接內部試跑認證結果,整合性提升。 - Function Calling : Gemini 2.0 具備直接呼叫函式的能力,讓 AI 模型能更靈活地與外部系統互動,透過函式呼叫,Gemini 2.0 能連接各種不同的 API 或服務,擴展其應用範圍。 4. 不再局限於"一問等一答",Live API 能夠即時處理使用者的輸入,並立即產生回應,無需等待冗長的處理時間。這種即時性使得對話更加流暢自然。 5. Thinking Model,AI 在生成回應前,能進行更深入的分析與推理。 ## 📌Gemini 2.0 新功能 <div style="text-align: center;"><img src="https://hackmd.io/_uploads/Bk6zR2uKJl.png" style="width: 60%; border: 2px solid black; padding: 5px;" /></div> ### 2.0 Flash Thinking Experimential - <div style="text-align: center;"><img src="https://hackmd.io/_uploads/SkDWea_Y1l.png" style="width: 80%; border: 2px solid black; padding: 5px;" /></div> - <div style="text-align: center;"><img src="https://hackmd.io/_uploads/SJTqg6_Fyg.png" style="width: 80%; border: 2px solid black; padding: 5px;" /></div> - Gemini 在此會顯示推理步驟,說明他是如何思考的。以高雄與屏東火車站問題,他就會根據"緯度"去判斷誰比較南端,並且去搜尋兩站的緯度,並最終推理正確答案,不會被"高雄在屏東上方"迷惑到。 ### 2.0 Flash Thinking Experimential with apps 在 Flash Thinking with apps過程中,Gemini會快速調用 **YouTube、Google 地圖、搜尋** 等應用,已獲得即時圖片、影片、音樂、文章等資訊作為思考依據。 現階段(2025/2/11)最主要適合與 YouTube、Google 地圖和搜尋搭配使用。 - <div style="text-align: center;"><img src="https://hackmd.io/_uploads/rJShhp_F1l.png" style="width: 80%; border: 2px solid black; padding: 5px;" /></div> - <div style="text-align: center;"><img src="https://hackmd.io/_uploads/H1dDA6dYJl.png" style="width: 80%; border: 2px solid black; padding: 5px;" /></div> ## 📌實際操作一次Google Gen AI SDK(活動現場限定) ### 1. 建立一個新的GCP專案,並將帳單連結到"GCP試用帳單" ### 2. 到[Vertex-cookbook](https://cloud.google.com/vertex-ai/generative-ai/docs/cookbook)中看到Quickstart ### 3. 在Cookbook中進入"Intro to Gemini 2.0 Flash"的Github後,跳到剛剛建立的專案中,VertexAI -> Colab Enterprise,啟用必要的API後就可以進行 <div style="text-align: center;"><img src="https://hackmd.io/_uploads/rk2fmTOY1e.png" style="width: 80%; border: 2px solid black; padding: 5px;" /></div> <div style="text-align: center;"><img src="https://hackmd.io/_uploads/SkjAXpOKyg.png" style="width: 100%; border: 2px solid black; padding: 5px;" /></div> <div style="text-align: center;"><img src="https://hackmd.io/_uploads/BySi0bYtJe.png" style="width: 100%; border: 2px solid black; padding: 5px;" /></div> 檢查是否有設定專案 ID 和區域,如果沒有則使用預設值或是從環境變數中取得,我們這邊填寫專案的ID,連結到專案後以驅動Gemini工作。 <div style="text-align: center;"><img src="https://hackmd.io/_uploads/SJulgzYFJe.png" style="width: 100%; border: 2px solid black; padding: 5px;" /></div> ### 4. 正式使用Gemini模型 <div style="text-align: center;"><img src="https://hackmd.io/_uploads/rJmtZGKYyl.png" style="width: 100%; border: 2px solid black; padding: 5px;" /></div> 選擇想要的Gemini模型後,就可以使用`client.models.generate_content`填寫請求model以及我們prompt,使Gemini模型回答答案 ### 5. Config調整參數以調整模型請求 <div style="text-align: center;"><img src="https://hackmd.io/_uploads/HyLByl5Ykx.png" style="width: 100%; border: 2px solid black; padding: 5px;" /></div> 每次呼叫模型時,於請求中包含參數值,以控制模型如何產生回應,模型會根據不同的參數值影響生成文本的創造性、隨機性和品質。 #### 調整模型參數 | 參數 | 說明 | 範圍 | |------|------|------| | **temperature** | 控制隨機性(值越高,創意性越高) | `0 ~ 1` | | **top_p** | 確保生成詞語的多樣性 | `0 ~ 1` | | **top_k** | 選擇概率最高的 K 個詞來生成 | `1 ~ 100` | | **candidate_count** | 生成候選回應數量,然後選擇其中最佳的一個 | `1 ~ 10` | | **seed** | 如果每次都使用相同的種子,模型生成的文本將會是相同的,可用於重現結果 | `任意整數` | | **max_output_tokens** | 限制最大輸出長度 | `50 ~ 4096` | | **stop_sequences** | 設定停止生成的關鍵字 | `文字字串` | | **presence_penalty** | 懲罰已經出現過的詞語 | `-2 ~ 2` | | **frequency_penalty** | 懲罰高頻出現的詞語 | `-2 ~ 2` | ### 6. 多模態輸入 我們在 prompt 的時候,可以將多種形態的資料當作輸入,只要在 contents 內輸入 Part 物件,並指定對應的 mime_type 即可,我們可以將"本地或雲端的圖片、文件檔、程式碼、音檔、影片檔"的url上傳上去,而Gemini即會根據輸入做回答 <div style="text-align: center;"><img src="https://hackmd.io/_uploads/H1RRVx5K1g.png" style="width: 100%; border: 2px solid black; padding: 5px;" /></div> >[!Note] >需要使用 Part 物件來封裝不同形態的資料,並指定對應的 mime_type,以告知模型資料的類型。 > ![image](https://hackmd.io/_uploads/BkDAHg5Yyg.png) > 以上圖為例,我們要上傳pdf檔案,那我們就要**填寫其pdf的url**,以及宣告資料**application/pdf** ### 7. Live API 將上方選取的model切換到gemini-2.0-flash-exp,即可使用具有Live API的model 透過 LiveConnectConfig 設定回應模態(文字或語音)和工具(如語音設定、函數呼叫、程式碼執行、Google 搜尋),即可與 Gemini 進行即時互動。 例如,可以傳送文字 prompt 並接收文字或語音回應,或使用函數呼叫來擴展模型功能,甚至執行程式碼或進行 Google 搜尋。 ### 8. Thinking Model <div style="text-align: center;"><img src="https://hackmd.io/_uploads/rkuDYxcYyx.png" style="width: 100%; border: 2px solid black; padding: 5px;" /></div> 將上方選取的model切換到gemini-2.0-flash-thinking-exp-01-21,即可使用具有Thinking能力的Gemini的模型中 <div style="text-align: center;"><img src="https://hackmd.io/_uploads/H148tgqY1x.png" style="width: 100%; border: 2px solid black; padding: 5px;" /></div> GenerateContentConfig(thinking_config=ThinkingConfig(include_thoughts=True)),在Config中要求模型在回應中包含思考過程。 而最終 Gemini 在產生回答的同時,也會一併輸出它的思考步驟,讓你更了解它是如何一步步得出結論。 ## GDG Build with AI 臺北場 - Gemini 2.0 Flash最新功能動手做 個人活動整理筆記 - [HackMD 版本](https://hackmd.io/1UkNDGXLSUamVmpfBD8xVg#8.-Thinking-Model) - [Medium 版本](https://medium.com/@jerry109a/gdg-build-with-ai-%E8%87%BA%E5%8C%97%E5%A0%B4-gemini-2-0-flash%E6%9C%80%E6%96%B0%E5%8A%9F%E8%83%BD%E5%8B%95%E6%89%8B%E5%81%9A-d357f3df96db)

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully