Po-Chuan Chen
    • 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
    • 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 Versions and GitHub Sync Note Insights 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
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # Transformer Notes Sequence-to-sequence (Seq2seq) 輸入一段句子,輸出一段句子,輸出句子長度由機器決定。 E.g. Speech recognition, Machine translation, Speech translation ... * 台語語音翻譯系統 ![](https://i.imgur.com/8ovl5cC.png) 自然語言處理通常都可以用 Sequence-to-sequence 的模型去進行類似 Q&A 的使用 但自行為特定任務訓練模型效果會更佳 ## Seq2seq for Syntactic Parsing 語句文法剖析 [Grammar as Froeign Language](https://arxiv.org/abs/1412.7449) ![](https://i.imgur.com/UqsfaqS.png) ## Seq2seq for Multi-label Classification 在物件中,每個物件有一至數個 class。輸入一篇文章,機器決定輸出 class 數目跟類型。 ![](https://i.imgur.com/IU4oemn.png) ## Seq2seq for Objection Detection ![](https://i.imgur.com/upm6PNB.png) ## Encoder 給一排向量,輸出一排向量 Encoder 當中 block 需要坐多層 layer 的事情,包括 input layer 使用 self-attention 輸出 $a$,並加上原先輸入 vector $b$ 運用 **layer normalization**,計算同一個 example 同一個 feature 不同 dimension mean $m$ 跟 standard deviation $\sigma$ > **Batch normalization** 計算同一個 dimension 不同的 feature 不同 example mean $m$ 跟 standard deviation $\sigma$ layer normalization 的輸出就是 fully connected network 的輸入, 之後 layer normalization 輸出再與 fully connected network 輸出相加 最後再經過一次 layer normalization,才得到 encoder 當中每層 block 的輸出 ![](https://i.imgur.com/DonoQqR.png) 而此 encoder 設計可以更改, 下方也提供為何要使用 layer normalization 不使用 batch normalization 的原因 ![](https://i.imgur.com/y1SLC61.png) ## Decoder 把 encoder 輸出讀入 decoder Begin 代表開始 Decoder 經過 Softmax 並給予分數再輸出 E.g. 單詞出現機率 (長度為常見方塊字數目) 接下來 decoder 輸入除了 Begin 還有剛才 decoder 輸出 (E.g. 機),重複上述操作,以此類推 ![](https://i.imgur.com/8x0vP8T.png) Self-attention $\rightarrow$ Masked Self-attention 後者不考慮接下來 input 的資訊,$a^1$ 不考慮 $a^2, a^3, a^4$,$a^2$ 不考慮 $a^3, a^4$ 以此類推 Decoder token 是接連產生的,並非平行產生,類似文字接龍 要讓 Decoder 要在方塊字新增 **END** 來停止 Decoder 繼續執行產生 sequence ![](https://i.imgur.com/lXcASSK.png) ### Decoder-None-autoregressive (NAT) NAT 透過一連串 BEGIN 當作輸入,平行化輸入 並透過另一個 predictor 或是觀察 output 哪個輸出 END(在 END 後的 token 忽略) 決定輸出長度 但 NAT 效能不如 AT (原因 Multi-modality) ### Cross attention ![](https://i.imgur.com/Tre4wlE.png) ![](https://i.imgur.com/c9KorSw.png) 下一步產生 token "機" 時的步驟 ![](https://i.imgur.com/pBTUXGB.png) cross attention 的方式不唯一,不一定要由 encoder 最後一層當作 decoder 輸入 > Teacher forcing: use ground truth as input 最後希望結果 cross-entropy 越小越好 ![](https://i.imgur.com/mLyk0qu.png) 其中 decoder 的輸入是 ground truth ## Tips ### Copy Mechanism Chat-bot 複製 decoder 的 input,從使用者的輸入作為輸出 Summarization 文章摘要 (document $\rightarrow$ Model $\rightarrow$ summary) ### Guide Attention 要求機器去做 attention 時有固定方式 ![](https://i.imgur.com/kElZ3MC.png) ### [Beam Search](https://ithelp.ithome.com.tw/articles/10208587) 用比較有效率的方式,找到 decoder 最佳解,但不見得會幫助到模型 如果模型輸出結果固定,有助於 decoder,反之,若需要有創造力,結果不固定則 decoder 結果不佳 ![](https://i.imgur.com/4IMJA2F.png) Exposure bias: 訓練時的資訊為正確,但測試時會有錯誤資訊 給 Decoder 錯誤的資訊來訓練可以解決,Scheduling sampling ![](https://i.imgur.com/fCQ7voJ.png)

    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