kkume
    • 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
    # NLP: Doc2Vec ## 過去回 [第1回:NLP Outline](https://hackmd.io/@kkume/HyCr7NNOD) [第2回:Word2Vec](https://hackmd.io/@kkume/ByfWVUEdP) ## 元論文 https://cs.stanford.edu/~quocle/paragraph_vector.pdf ## 要点 * **Document(文章)の分散表現が得られる** * **Word2VecのDocument version** * **Word2Vecと同じく、Neural Network のモデルである** * **PV-DM(Distributed Memory Model of Paragraph Vectors)とPV-DBOW(Distributed Bag of Words version of Paragraph Vector)がある** ## 文書の分散表現 Word2vecでは単語の分散表現を扱った ==**Doc2Vecでは文書の分散表現を扱う**== ![](https://i.imgur.com/aouT4Of.png) ## BoW (Bag-of-Words) 単語はOne-Hot表現によって数値化できた。 では、**文書はどうやって数値(ベクトル)化すべきか?** そのひとつの方法が ==**Bag-of-Words**== である。 BoWでは、単語の出現をカウントすることでベクトル化する。 ![](https://i.imgur.com/b4wS7eZ.png) ### BoWの問題点 当然だが、語順を無視しているので、文章の意味の全ては捉えることができない。 あくまで、文章全体のトピックのようなものを捉えるに過ぎない。 ## Doc2Vec ==Document ID==を使ってDocumentの分散表現を獲得するモデルである。 ![](https://i.imgur.com/4dQ04ZR.png) ### 注意点というか所感 * **==既存のコーパスのDocumentを分類するために学習するもの==** * **未知なるDocumentの分散表現を得るものではない** Word2Vecとの対比が多いが、個人的にはそれはミスリードしやすいと思う。 ### PV-DM(Distributed Memory Model of Paragraph Vectors) 上の図の左側にあたるモデル。 下記は論文内の図。論文ではParagraph id (このページではDocument ID)と呼んでいる。 ![](https://i.imgur.com/N1xlQOc.png) 上の図を自分の絵で説明してみる。 --- ① ![](https://i.imgur.com/hWGooj9.png) 3種類のDocumentを持ったコーパスがあるとする。それぞれのDocumentはIDが割り振られている。 ---- ② ![](https://i.imgur.com/wqNPJdP.png) Documentをひとつ選び、さらに単語をひとつ選ぶ。 今回は「だった」を選択する。 選択した単語から==X手前の単語==を取得する。 今回の場合、手前3単語まで選択する。「初めて」「の」「海外旅行」 それぞれの単語をOneHotベクトルに変換する。 Document IDもOneHotベクトルに変換する。Documentが3つしかなかったら、3次元のOneHot。 ---- ③ ![](https://i.imgur.com/TarOn9Z.png) 適当なネットワークを用意して、Weightをかけて、分散表現を得る。 ここで、赤の分散表現は、==Documentの分散表現==になっている。 そして、単語の分散表現と、Documentの分散表現を連結する。 ---- ④ ![](https://i.imgur.com/uXvMkjU.png) 連結した後、適当なWeightをかけて、単語のOneHot次元に変換する。 Softmaxをかけて確率化。 CrossEntropyでLoss計算する ---- ⑤ ![](https://i.imgur.com/7Nj6gGs.png) 学習において、==単語の分散表現のWeightは固定==する。固定というか、あらかじめ、==Word2Vecで単語の分散表現を事前学習したWeight==を使用する。 なので、実際にBack propagation によって学習されるWeightは赤と青の箇所である。 そして、学習して得られたWeightを掛けたものが、==あるDocument IDの分散表現==になっている ---- ### PV-DBOW(Paragraph Vector without word ordering: Distributed bag of words) PV-DMでは、単語の順番を意識していたり、Word2Vecで事前学習したりと学習に時間がかかった。こっちは、学習が早いけど精度が悪い。 あるDocument ID から単語をランダムにN個サンプリングして、そのN個を分類するモデルちなっている。割愛 ![](https://i.imgur.com/KFXZLjE.png) ## Doc2Vec の使い方 [参照](https://qiita.com/g-k/items/5ea94c13281f675302ca#doc2vec%E3%81%A7%E3%81%A7%E3%81%8D%E3%82%8B%E3%81%93%E3%81%A8)

    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