日本語の分散表現の計算方法まとめ

単語単位の分散表現

  • Word2vec
    • 自然言語処理における分散表現の一つのオリジナル
    • 基本原理くらいは知っていてもいいかもしれない
    • gensimがよく使われる
  • Fasttext で文書分類問題までやったった
    • fastと名前がついているだけあってfacebookが公開しているモデルは高速に動作する
    • 分散表現とクラス分類に対応していたり、利便性が高い
    • 特にこのモデルで利用されている分かち書きの特徴から未知語に強いとされている
  • 日本語Wikipediaで学習済みのBERTが公開されているので使い方メモ
    • Google の検索エンジンにも採用されている、らしい
    • 自然言語処理の研究を大きく変えたモデル
    • 関連する技術であるTransformerは自然言語処理だけでなく、画像処理の界隈にも流用された
    • huggingfaceで日本語版のBERTも色々と公開されている
  • 日本語に対応したT5
    • この日本語版のモデルの作者が公開しているサンプルがわかりやすい
    • また同じ作者がSBERTのモデルも公開している

機械学習の基礎からモデルの仕組みまで体系的に学びたい方へ

[Read More]

poetry環境でstreamlitを実行する方法

症状

  • streamlitをpoetryを使ってインストールした場合に、streamlitが実行できない
  • poetry add streamlitでstreamlitを追加した場合、通常のシェルからはstreamlitのパスが通っていない
  • which streamlitの実行結果でなにもでてこない

対処

  • poetry からシェルを実行する
  • poetry shell
  • streamlit run sample.py
  • streamlitコマンドが実行できるようになる
  • 仮想環境にstreamlitをインストールした場合には通常のシェルからはstreamlitを実行できない
  • その場合の対処法は公式サイトに載っている

関連記事

参考リンク


関連書籍

[Read More]

pycharmからpoetryで環境の作成ができない

症状

pycharmでinterpreterの指定にエラーが出た。 改めてpoetryの環境構築を行おうとしたところ、以下のエラーが出た。

ModuleNotFoundError No module named 'virtualenv.activation.xonsh' at <frozen importlib._bootstrap>:984 in _find_and_load_unlocked

解決方法

pip3 uninstall virtualenv

原因

  • anyenvのアップデートをかけたのが悪かったか?

反省

  • 不用意なアップデートは不具合の原因になる

関連記事


関連書籍

[Read More]

日本語で学習済みのT5がhugging face で公開されたので使い方メモ

T5(Text-To-Text Transfer Transformer) とは

  • 事前学習における入出力を文に統一してしまうことで、 複数の形式の問題に対しても適応できる様式となった。
  • モデルの基本構造としては Transformer が使われており、その点はBERTと共通している。
  • 事前学習の形式をすべてテキストによる指定にするというアイデアはGPT-3などでも用いられている。
    • 0 shot learning など入力文で模範解答例を入力するだけで、出力を操作するということも行われている
    • “操作の指定:入力文1、出力に期待する文、操作の指定:入力文2"で、“出力文2"が得られるという次第

できること

  • 下流のタスクとして転移学習を行うことで以下のようなことが実行できる。
    • 文書分類
    • タイトル生成
    • 文章生成
    • 生成要約

機械学習の基礎からモデルの仕組みまで体系的に学びたい方へ

[Read More]

Building a python environment with poetry on mac os

Pip is a major method of installing python libraries.

poetry is a more advanced version control tool for development environments.

It seems to have official support for pyenv integration.

I’ll write down how to install it on mac os and what I got stuck.

Advantages of poetry

  • Can organize library dependencies.
    • There are some unexpected side effects depending on the version of the library.
    • Trying to recreate the environment can cause errors with library versions and installation order.
    • Building the environment is an inevitable part of human work, so it should be automated if possible.
    • Also, it seems to be able to update the library version to take dependencies into account.
    • And it keeps a record of the status.
  • Is it possible to separate the dependency records by git branch?
  • The libraries you can install are comparable to pip
    • Does it have the same references as pypy?
  • Usability is not much different from pip
    • Poetry add instead of pip install
  • It recognizes virtual environments created with pyenv and works with them.

I’m going to install it because it seems to be a convenient way to build an environment without much effort.

[Read More]

Why is fasttext so fast?

Features of fasttext

  • Improved objective function
    • Consideration of negative samples
    • This should not affect training time.
  • Change in optimization method
    • Use of stochastic optimization
    • If it affects the learning time, it should be this one
  • Implementation in C language
    • This is the most effective, isn’t it?

If we implement it in ## pytorch, it won’t be much different from word2vec. It would depend on the amount of data to be trained.

[Read More]

word2vecでteratailの検索システムっぽいものを作る

概要

分散表現を用いた検索システムを作る。

  1. teratailから質問をスクレイピングする。
  2. スクレイピングした文章をもとにword2vecを学習する。
  3. word2vecによって得られた分散表現をもとにcosine similarityを計算して、クエリと質問文の類似度を得る。
  4. 類似度をもとにソートする。

ソース

teratail_w2v_question.ipynb

関連書籍

[Read More]

アテンションを用いた画像処理モデルの作成

アテンションを用いた画像処理モデルの作成のまとめ

画像認識にアテンションという機構を付与して、判断の根拠を可視化しました。

前振り

画像認識についてはもう深層学習が人間を超えてから(2015)しばらく経っています。

[Read More]

AI(深層学習) を用いて観賞魚の品種識別

AI を用いて観賞魚の品種識別のまとめ

  1. AI はもはや普通の人間を超える性能を発揮している

  2. 深層学習系の手法がメジャー

  3. デバイスは2 万円〜から利用が可能

前振り

仕事がらAIについて調べております。調べると言ってもプレスリリースを漁るといったものではなく、主に公開されている論文やソースコードを読みこなして自力でAIを構築できるように取り組んでいます。

[Read More]

ポートフォリオ

実績

🚀 最新プロジェクト(2023-2025)

フルスタックWebアプリケーション

  • X Favorites Gallery - X(Twitter)いいねギャラリー + AIレコメンド

    • X Favorites Gallery LP / アプリを開く
    • 技術スタック: Next.js + React + PostgreSQL + pgvector, Chrome拡張, Docker
    • 成果: いいねしたコンテンツをAI(DINOv2)が自動レコメンド、NSFW自動フィルタリング対応
  • tsuzukan(続刊) - 漫画・小説の続刊管理アプリ

    [Read More]