2022 社群自救會
      • 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
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
    • 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 No publishing access yet

      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.

      Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Explore these features while you wait
      Complete general settings
      Bookmark and like published notes
      Write a few more notes
      Complete general settings
      Write a few more notes
      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
    • Make a copy
    • Transfer ownership
    • Delete this note
    • 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 Help
Menu
Options
Make a copy 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
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
  • 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 No publishing access yet

    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.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    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
    # Final Project Report - Stance Detection - 組員 1 - 學號: - 姓名: - 組員 2 - 學號: - 姓名: - 組員 3 - 學號: - 姓名: ## I. 介紹 ### 1. Stance Detection 立場檢測 立場(Stance)是描述對事物、事件或目標看法的態度,而這樣的態度,往往會在說話者(作者)在敘述文字訊息時呈現出來。因此立場檢測任務就是給予一個說話者討論的"主題(topic)"與"說話者對目標的陳述(text)"後,檢測說話者隱含的立場。 因此立場檢測也可以說是有條件地對文字進行分類的任務,所謂的條件也就是得根據不同的主題來做判斷。 常見的立場會被概括成 3 個分類分別是 支持(favor or pro)、反對(against or con)或 無意見(none or neutral)。 ### 2. 立場檢測的困難 如同先前所述,立場檢測是有條件的任務。雖然本質上是文本分類,但實際上如果不依照主題數切分成數個模型進行分類,而是將其統整成單一模型來做分類,則準確率通常沒有前者高。而這主要是因為不同主題之前的資訊分布並不相似的緣故,例如政治類與經濟類的主題,可能具有不同的用字遣詞分布。 因此這也意味著立場檢測模型先天上很難具有廣泛的適應能力,因此能否有有效的解決此問題,讓模型更具備泛化能力是立場檢測任務當前最主要的議題。 ### 3. 資料集 我們這次將使用 [SemEval-2016 Task 6](https://alt.qcri.org/semeval2016/task6/) 資料集,簡稱 Semt6,它是一份很知名的立場檢測資料集,其從 Twitter 上收集,有 6 個主題,共 4870 筆樣本,3 種立場分類:支持(Favor)、反對(Against)與中立(None)。 我們將使用 Tweet、Stance topic 與 Stance,這個 3 個特徵。 <center> <img src="https://i.imgur.com/BV7GISA.png" style="zoom: 33%;" /> <br> <div style="color:orange; border-bottom: 1px solid #d9d9d9; display: inline-block; color: #999; padding: 2px;">表 1: SemEval-2016 Stance Dataset 的樣本範例 [Mohammad et al. 2016b] </div> </center> #### 欄位說明 * Tweet: 說話者的敘述 * Topic: 說話者在討論的主題 * Stance: 說話者對當前主題所持有的立場(Favor, Against, None) * Sentiment: 說話者持有的情感 ### 4. 貢獻 * 如上述,當前立場檢測模型訓練若要達到比較好的效果需依照不同主題各別訓練,在這邊我們提供了一種可以廣泛適應各個主題的單一模型作法。其作法主要是透過結合 Commonsense knowledge Graph (ConceptNet) 的方式,引入外部的知識,來加強主題和敘述文字之間的關聯性。 * 我們自行從 ConceptNet 取得的外部知識後,也成功找出方法建立出有用的知識圖(後續單獨的 GCN 模型測試可以看出這點)。 * 測試外部知識對於 SemEval-2016 Task 6 資料集有多少實質上的提升。 ## II. 參考文獻 ### 1. ConceptNet - 外部知識關係圖 <center> <img src="https://i.imgur.com/rmfgXOE.png" style="zoom: 50%;" /> <br> <div style="color:orange; border-bottom: 1px solid #d9d9d9; display: inline-block; color: #999; padding: 2px;">圖 1: ConceptNet 官方介紹圖 [https://conceptnet.io/] </div> </center> ConceptNet 是一個免費的語義網絡,有提供簡易的 API 讓使用者提取字詞間的關係知識。在此做為我們的建圖的資訊,也是我們引用的外部知識,其可以促進敘述與主題之間關係訊息的傳遞,讓後續模型有更好的推理能力。 ### 2. 外部知識圖的使用 這部份我們參考了 [Rui Liu et al. enhancing zero-shot and few-shot stance detection with commonsense knowledge graph (2021)](https://aclanthology.org/2021.findings-acl.278.pdf) 的作法(論文中並未附帶程式碼,僅提供概念,實際實作是由我們自行完成)。 他們的目標與我們近似,也是需要透個更加泛化的模型來對未知或少數資料的主題進行立場分類。但其比起我們更具焦在 Zero-shot 和 Few-shot 的任務上,我們這邊較專注於 Semt6 資料集效果的提升,也因此與他們實驗用的資料集有所也不同。 論文作者在探討時發現,並不是每個敘述內的詞都會出現在主題中,也就導致難以去建立 text 與 topic 之間的關係,也使得模型進行推理時,無法直接從字詞資訊建構關聯。 而為了解決這樣的缺點,論文作者引入了外部知識 - ConceptNet,使其能從 ConceptNet 的資訊中建構出詞與詞的關係,藉此強化模型的泛化與推理能力。 我們從中效法這樣的精神,也採用 ConceptNet 作為外部知識,並自行爬取 ConceptNet 上的資訊。接著,參考論文中建圖的方法,建立本次專題所需的外部知識圖,但實際建構的方式,還是與論文中的做法有所差異。 首先,我們使用所有在 text 和 topic 內的字詞(此處是指經過前處理後剩餘的詞,例如: 去 stop words 後)。由於他們的資料集內的文字數較多,因此是只挑選幾個較為重要的單詞。其次,我們有限制從 ConceptNet 中獲取的最大關係數,避免攝取到關係太遠的詞。最後,我們使用的 node feature 也與論文中不同。 由於我們先前對圖如何與其他模型的搭配並不太熟悉,因此也從作者他們的架構中學習,例如何處適合將 Graph Embedding 的資訊串接在模型中。這也使得我們能在後續的方法中有感受到 Graph Embedding 的效果,但我們的 Graph Encoder 還是與文獻中的不同,因此串接的作法上還有些許改善的空間。 ## III. 方法 ### 1. 建立知識圖 這邊透過一個例子來介紹我們如何建知識圖。首先圖 2 是主題為 Feminist Movement 的一篇 tweet 的內文。圖上有 topic、stance 和 text,這些都會由 Semt6 資料集提供。 <center> <img src="https://i.imgur.com/FoVEH7P.png" style="zoom:33%;" /> <br> <div style="color:orange; border-bottom: 1px solid #d9d9d9; display: inline-block; color: #999; padding: 2px;">圖2: 範例 tweet 樣本 </div> </center> 我們將 Text 和 Topic 內的每個字放入 ConceptNet 做查詢並爬取下來。從 ConceptNet 爬抓下來的格式會是 $R = (u, r, v)$。其中 $u$ 與 $v$ 分別是被查詢與回應的單詞,皆會被當作圖形的 node,而 $r$ 是 $u$ 與 $v$ 之間的關係,將被當作兩點之間的 edge。因此我們就建構出圖 3 這樣的知識圖 $G$。 <center> <img src="https://i.imgur.com/LA4UyDK.png" style="zoom:33%;" /> <br> <div style="color:orange; border-bottom: 1px solid #d9d9d9; display: inline-block; color: #999; padding: 2px;">圖3: 範例知識圖 (節點的顏色是為了解適用) </div> </center> 圖 3 中為了解釋方便,我們將節點上了顏色。綠色是 topic,而藍色是 tweet 內的 text,而橘色就是從 ConceptNet 得到外部知識。圖中有些節點沒有邊則表示無法取得與其他的節點之間的關係。但可以看見有些藍色節點有透過橘色節點或直接與綠色節點串聯,這也表示我們成功的將 text 與 topic 之間的關係建構出來。因此該 $G = (V, E)$ 將可以提供模型具備一定的推理的能力,$V$ 是 $u$, $v$ 的集合,而 $E$ 是 $r$ 的集合。 我們成功建立了知識圖後,要解決的是 node feature 的問題。在這邊我們嘗試了不同的 node feature 設定,最終使用了在 twitter 上訓練的 GloVe (Jeffrey Pennington et al., 2014) 的 word embedding 作為 feature。由於 node 本身就是單詞,因此也很容易能餵入 GloVe 取得 embedding。 ### 2. 模型架構 圖 4 是我們的模型的整體架構,其由兩個子模型所構成,分別是 BERT 和 GCN。模型的輸入是 x 和 t,分別表示 tweet 的 text 和 topic。 將 x 和 t 丟入 BERT 外也會丟入 ConceptNet,再將從 ConceptNet 獲得的訊息建構成圖再放入 GCN 計算該筆資料的 knowledge graph embedding。而 GCN 的部分建構成像是如圖 5 這樣串接了數層 Conv、BatchNorm、ReLu、Dropout。 <center> <img src="https://i.imgur.com/MYDrD9H.png" style="zoom:33%;" /> <br> <div style="color:orange; border-bottom: 1px solid #d9d9d9; display: inline-block; color: #999; padding: 2px;">圖 4: 模型的整體架構 </div> </center> <center> <img src="https://i.imgur.com/tjFrxbL.png" style="zoom:100%;" /> <br> <div style="color:orange; border-bottom: 1px solid #d9d9d9; display: inline-block; color: #999; padding: 2px;">圖 5: GCN 的架構 </div> </center> ## IV. 實驗 ### 1. 實驗設置 此次使用 Semt6 資料集作為實驗資料。而我們提供了 3 種模型的實驗數據,分別是 BERT、GCN 和 BERT+GCN。其中 BERT 和 GCN 是我們的 Baseline 模型。 我們的實驗都是在 GPU 型號為 Nvidia RTX 3090 24GB 上進行,並觀測到單一的 BERT 配置需 10 GB 的內存,單一的 GCN 需 2GB,而 BERT+GCN 則接近 12 GB。 而我們評估模型的基準是測試集的準確率,此外每次實驗都進行五次並取這的平均。 ### 2. 實驗一 此實驗中,Semt6 的各個 topics 都會有一部份用作訓練與測試,以便我們觀察 BERT+GCN 的配置是否能有效提升性能。 表 2 為 BERT、GCN、BERT+GCN,這 3 個模型的 test accuracy,各有 5 次實驗的數據,最後再取平均。 | 項目\次數 | 第 1 次 | 第 2 次 | 第 3 次 | 第 4 次 | 第 5 次 | 平均 | | --------- | --------- | --------- | --------- | --------- | --------- | --------- | | BERT | 0.592 | 0.603 | 0.587 | 0.589 | 0.604 | 0.595 | | GCN | 0.537 | 0.545 | 0.547 | 0.540 | 0.544 | 0.543 | | BERT+GCN | **0.623** | **0.609** | **0.613** | **0.610** | **0.612** | **0.613** | <center> <div style="color:orange; border-bottom: 1px solid #d9d9d9; display: inline-block; color: #999; padding: 2px;">表 2: 實驗一的結果 </div> </center> ### 3. 實驗一結果與討論 #### A. 知識圖的建立是否有效 為了驗證我們的知識圖建立是否為有效,這邊可以直接觀察 GCN 的實驗結果。而 GCN 的準確率都有達到 0.5 左右,也證實了我們的知識圖能提供一定的知識讓模型具有一定的判斷能力。 #### B. 三個模型表現比較 從平均結果來看 BERT+GCN 結果是最好的,比起 BERT 提升 3 %,而 GCN 則是最低。 這也表示了 BERT+GCN 的配置確實能提升性能,但因為與 BERT 的差異並不太大,但我們認為還是有改善的空間。 #### C. 學習率設置 圖 6 呈現的是三個模型的準確率變化,可以看到在同樣的學習率設置上,GCN 的訓練準確率上升曲線比較平緩,表示成長緩慢。而 BERT 和 BERT+GCN 在經過幾個 epoch 就馬上達到 99% 的準確率並有 overfittig 的現象。 <center> <img src="https://i.imgur.com/SInzCCF.png" style="zoom:100%;" /> <br> <div style="color:orange; border-bottom: 1px solid #d9d9d9; display: inline-block; color: #999; padding: 2px;">圖 6: 三模型的準確率成長歷史 </div> </center> 因此若要達到較好的訓練結果,在學習率設置上,由於 BERT 參數量多學習率要小,而 GCN 參數小所以學習率可以調大,但在 BERT+GCN 的配置上,卻會出現問題,因為很難同時找出滿足這兩個子模型的學習率。我們這邊測試後最終選擇比較傾向 BERT 那邊的學習率。 #### D. Node feature 的選擇 我們一開始對 node feature 使用隨機生成 embedding 來作為 feature 的 nn.embedding,此時是認為 node feature 是可以訓練的參數,因此可以先隨機給予並在後續微調。但在訓練的過程中發現會導致無法收斂的問題。因此後來改用 Glove embedding 並關閉會被模型調整的風險後,表現有上升許多。 圖 7 是我們的實驗結果。 <center> <img src="https://i.imgur.com/nmX1fQE.png" style="zoom:33%;" /> <br> <div style="color:orange; border-bottom: 1px solid #d9d9d9; display: inline-block; color: #999; padding: 2px;">圖 7: 比較在不同的 node feature 選擇下,GCN 的成長變化 </div> </center> ### 4. 實驗二 此實驗中,Semt6 的各個 topics 會輪流當測試集,其餘的 topics 會當訓練集,即 6 個主題中,其中 1 個用作測試,其餘 5 個用作訓練。其實驗的目的是測試模型在未看見的主題上的泛化能力。因為有 6 個主題,因此會有 6 項的實驗結果並呈現在表 3 中。 | 項目\主題名稱 | A | FM | CC | DT | LA | HC | | ------------- | --------- | --------- | --------- | --------- | --------- | --------- | | GCN | **0.607** | 0.483 | 0.371 | 0.419 | **0.583** | 0.501 | | BERT | 0.597 | 0.545 | 0.438 | **0.505** | 0.526 | 0.601 | | BERT+GCN | 0.603 | **0.556** | **0.459** | 0.49 | 0.544 | **0.612** | <center> <div style="color:orange; border-bottom: 1px solid #d9d9d9; display: inline-block; color: #999; padding: 2px;">表 3: 實驗二的結果 </div> </center> (此處 topic 名稱為縮寫,A 對應 "Atheism",FM 對應 "Feminist Movement",CC 對應 "Climate Change is a Real Concern", DT 對應 "Donald Trump",LA 對應 "Legalization of Abortion",HC 對應 "Hillary Clinton") ### 5. 實驗二結果與討論 在 6 個主題項目中,GCN 有 2 個主題領先,BERT 則有 1 個,而 BERT+GCN 則有 3 個。 整體看下來 BERT+GCN 並沒有辦法在全部的主題項目中拿下優勢,但未獲勝的項目也與 BERT 或 GCN 差異並不太大,或許 BERT+GCN 仍有調整的空間。而 BERT 基本上略遜色於 BERT+GCN,此結果也有符合我們的期待。但 GCN 則出乎意料之外,有 2 個主題項目的分數遠大於其他項目的分數,也甚至贏過 BERT。我們推測這兩個主題項目內,知識圖資訊的建立可能更為完善。 ## V. 結論 透過此次的專題,我們認識到如何將圖狀的外部知識引入到任務中使用。同時也發現到一模型與圖卷積模型的結合,除了能具備此模型的能力外,還能藉由圖卷積模型引入外部知識進一步提升整體性能,相信在未來這樣的混和搭配也將是研究的一大趨勢。 此外,透過兩個實驗項目的檢驗,能得出我們的設置確實是有效的方式。但我們 BERT+GCN 確實還是稍有缺陷,或許是我們對這樣模型的混和搭配還不熟練的緣故,這也是我們未來會努力改善的方向。

    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
    Sign in via Google Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    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