webmaster-kazu.com

テクノロジー・データ分析・実践ログ・その他

【Python】外部データとLLMの間のシンプルで柔軟なインターフェイス「gpt-index」のインストール

カテゴリ: Python【初歩から現場実務的なもの】

GPTが作成するインデックスで、外部情報を整理してクエリに答えるように設計されたライブラリ「gpt-index」のインストールについて解説します。

「gpt-index(https://github.com/jerryjliu/gpt_index,https://gpt-index.readthedocs.io/en/latest/)」は、大規模な外部知識ベースを大規模言語モデル(Large-scale Language Model:LLM)で容易に利用できるように設計されたデータ構造群からなるプロジェクト。

■Python

今回のPythonのバージョンは、「3.8.5」を使用しています。(Windows10)(pythonランチャーでの確認)

■gpt-indexをインストールする

gpt-indexをインストールを行いますが、今回はpipを経由してインストールを行うので、まずWindowsのコマンドプロンプトを起動します。

pip install gpt-index

起動後、上記のコマンドを入力し、Enterキーを押します。

なお、今回は、pythonランチャーを使用しており、Python Version 3.8.5にインストールを行うために、バージョンの切り替えを行います。

py -3.8 -m pip install gpt-index

切り替えるために、上記のコマンドを入力し、Enterキーを押します。

Defaulting to user installation because normal site-packages is not writeable

Collecting gpt-index

Downloading gpt_index-0.2.7.tar.gz (91 kB)

---------------------------------------- 91.2/91.2 kB 1.3 MB/s eta 0:00:00

Installing build dependencies ... done

Getting requirements to build wheel ... done

Preparing metadata (pyproject.toml) ... done

Requirement already satisfied: pandas in c:\users\user_\appdata\roaming\python\python38\site-packages (from gpt-index) (1.5.2)

Collecting langchain

Downloading langchain-0.0.65-py3-none-any.whl (166 kB)

---------------------------------------- 166.1/166.1 kB 2.5 MB/s eta 0:00:00

Collecting dataclasses-json

Using cached dataclasses_json-0.5.7-py3-none-any.whl (25 kB)

Collecting nltk

Downloading nltk-3.8.1-py3-none-any.whl (1.5 MB)

---------------------------------------- 1.5/1.5 MB 1.8 MB/s eta 0:00:00

Collecting openai

Downloading openai-0.26.1.tar.gz (55 kB)

---------------------------------------- 55.3/55.3 kB 1.5 MB/s eta 0:00:00

Installing build dependencies ... done

Getting requirements to build wheel ... done

Preparing metadata (pyproject.toml) ... done

Requirement already satisfied: numpy in c:\users\user_\appdata\roaming\python\python38\site-packages (from gpt-index) (1.24.1)

Collecting tenacity

Downloading tenacity-8.1.0-py3-none-any.whl (23 kB)

Collecting transformers

Downloading transformers-4.25.1-py3-none-any.whl (5.8 MB)

---------------------------------------- 5.8/5.8 MB 3.2 MB/s eta 0:00:00

Collecting marshmallow-enum<2.0.0,>=1.5.1

Using cached marshmallow_enum-1.5.1-py2.py3-none-any.whl (4.2 kB)

Collecting typing-inspect>=0.4.0

Using cached typing_inspect-0.8.0-py3-none-any.whl (8.7 kB)

Collecting marshmallow<4.0.0,>=3.3.0

Downloading marshmallow-3.19.0-py3-none-any.whl (49 kB)

---------------------------------------- 49.1/49.1 kB 2.4 MB/s eta 0:00:00

Requirement already satisfied: requests<3,>=2 in c:\users\user_\appdata\roaming\python\python38\site-packages (from langchain->gpt-index) (2.28.1)

Requirement already satisfied: PyYAML<7,>=6 in c:\users\user_\appdata\roaming\python\python38\site-packages (from langchain->gpt-index) (6.0)

Collecting SQLAlchemy<2,>=1

Downloading SQLAlchemy-1.4.46-cp38-cp38-win_amd64.whl (1.6 MB)

---------------------------------------- 1.6/1.6 MB 5.0 MB/s eta 0:00:00

Requirement already satisfied: pydantic<2,>=1 in c:\users\user_\appdata\roaming\python\python38\site-packages (from langchain->gpt-index) (1.10.4)

Requirement already satisfied: tqdm in c:\users\user_\appdata\roaming\python\python38\site-packages (from nltk->gpt-index) (4.64.1)

Collecting regex>=2021.8.3

Downloading regex-2022.10.31-cp38-cp38-win_amd64.whl (267 kB)

---------------------------------------- 267.7/267.7 kB 1.3 MB/s eta 0:00:00

Collecting joblib

Downloading joblib-1.2.0-py3-none-any.whl (297 kB)

---------------------------------------- 298.0/298.0 kB 3.7 MB/s eta 0:00:00

Collecting click

Using cached click-8.1.3-py3-none-any.whl (96 kB)

Requirement already satisfied: aiohttp in c:\users\user_\appdata\roaming\python\python38\site-packages (from openai->gpt-index) (3.8.3)

Requirement already satisfied: python-dateutil>=2.8.1 in c:\users\user_\appdata\roaming\python\python38\site-packages (from pandas->gpt-index) (2.8.2)

Requirement already satisfied: pytz>=2020.1 in c:\users\user_\appdata\roaming\python\python38\site-packages (from pandas->gpt-index) (2022.7.1)

Collecting huggingface-hub<1.0,>=0.10.0

Downloading huggingface_hub-0.11.1-py3-none-any.whl (182 kB)

---------------------------------------- 182.4/182.4 kB 647.4 kB/s eta 0:00:00

Requirement already satisfied: packaging>=20.0 in c:\users\user_\appdata\roaming\python\python38\site-packages (from transformers->gpt-index) (23.0)

Requirement already satisfied: filelock in c:\users\user_\appdata\roaming\python\python38\site-packages (from transformers->gpt-index) (3.9.0)

Collecting tokenizers!=0.11.3,<0.14,>=0.11.1

Downloading tokenizers-0.13.2-cp38-cp38-win_amd64.whl (3.3 MB)

---------------------------------------- 3.3/3.3 MB 5.0 MB/s eta 0:00:00

Requirement already satisfied: typing-extensions>=3.7.4.3 in c:\users\user_\appdata\roaming\python\python38\site-packages (from huggingface-hub<1.0,>=0.10.0->transformers->gpt-index) (4.4.0)

Requirement already satisfied: six>=1.5 in c:\users\user_\appdata\roaming\python\python38\site-packages (from python-dateutil>=2.8.1->pandas->gpt-index) (1.16.0)

Requirement already satisfied: certifi>=2017.4.17 in c:\users\user_\appdata\roaming\python\python38\site-packages (from requests<3,>=2->langchain->gpt-index) (2022.12.7)

Requirement already satisfied: idna<4,>=2.5 in c:\users\user_\appdata\roaming\python\python38\site-packages (from requests<3,>=2->langchain->gpt-index) (3.4)

Requirement already satisfied: urllib3<1.27,>=1.21.1 in c:\users\user_\appdata\roaming\python\python38\site-packages (from requests<3,>=2->langchain->gpt-index) (1.26.13)

Requirement already satisfied: charset-normalizer<3,>=2 in c:\users\user_\appdata\roaming\python\python38\site-packages (from requests<3,>=2->langchain->gpt-index) (2.1.1)

Collecting greenlet!=0.4.17

Using cached greenlet-2.0.1-cp38-cp38-win_amd64.whl (190 kB)

Requirement already satisfied: colorama in c:\users\user_\appdata\roaming\python\python38\site-packages (from tqdm->nltk->gpt-index) (0.4.6)

Collecting mypy-extensions>=0.3.0

Using cached mypy_extensions-0.4.3-py2.py3-none-any.whl (4.5 kB)

Requirement already satisfied: aiosignal>=1.1.2 in c:\users\user_\appdata\roaming\python\python38\site-packages (from aiohttp->openai->gpt-index) (1.3.1)

Requirement already satisfied: frozenlist>=1.1.1 in c:\users\user_\appdata\roaming\python\python38\site-packages (from aiohttp->openai->gpt-index) (1.3.3)

Requirement already satisfied: async-timeout<5.0,>=4.0.0a3 in c:\users\user_\appdata\roaming\python\python38\site-packages (from aiohttp->openai->gpt-index) (4.0.2)

Requirement already satisfied: yarl<2.0,>=1.0 in c:\users\user_\appdata\roaming\python\python38\site-packages (from aiohttp->openai->gpt-index) (1.8.2)

Requirement already satisfied: attrs>=17.3.0 in c:\users\user_\appdata\roaming\python\python38\site-packages (from aiohttp->openai->gpt-index) (22.2.0)

Requirement already satisfied: multidict<7.0,>=4.5 in c:\users\user_\appdata\roaming\python\python38\site-packages (from aiohttp->openai->gpt-index) (6.0.4)

Building wheels for collected packages: gpt-index, openai

Building wheel for gpt-index (pyproject.toml) ... done

Created wheel for gpt-index: filename=gpt_index-0.2.7-py3-none-any.whl size=137798 sha256=15a17945ac71bd44be2379522f26ddbbababf6f8f0b4e59cface495dfe5a97fe

Stored in directory: c:\users\user_\appdata\local\pip\cache\wheels\62\de\59\44e6048bc03cd0833f75687f1c9a461af2022f466ba48ca067

Building wheel for openai (pyproject.toml) ... done

Created wheel for openai: filename=openai-0.26.1-py3-none-any.whl size=67355 sha256=c5a3869ac65a2ce97e65eaf4f51cfa4fe4ffaa11bb7b00fff88c7f95fd9d06ef

Stored in directory: c:\users\user_\appdata\local\pip\cache\wheels\2f\9c\55\95d3609ccfc463eeffb96d50c756f1f1899453b85e92021a0a

Successfully built gpt-index openai

Installing collected packages: tokenizers, mypy-extensions, typing-inspect, tenacity, regex, marshmallow, joblib, greenlet, click, SQLAlchemy, nltk, marshmallow-enum, huggingface-hub, transformers, openai, langchain, dataclasses-json, gpt-index

Successfully installed SQLAlchemy-1.4.46 click-8.1.3 dataclasses-json-0.5.7 gpt-index-0.2.7 greenlet-2.0.1 huggingface-hub-0.11.1 joblib-1.2.0 langchain-0.0.65 marshmallow-3.19.0 marshmallow-enum-1.5.1 mypy-extensions-0.4.3 nltk-3.8.1 openai-0.26.1 regex-2022.10.31 tenacity-8.1.0 tokenizers-0.13.2 transformers-4.25.1 typing-inspect-0.8.0

Enterキーを押すと、インストールが開始され、上記のように「Successfully installed」と表示されます。これが表示されれば、gpt-indexが正常にインストールされたことになります。

なお、今回はgpt-indexのバージョン0.2.7をインストールしました。