Docker Compose를 이용한 설치를 한 상황을 기준으로 하겠다.

  - https://www.whatwant.com/entry/Apache-Airflow-install

 

[ Status ]

    - Docker Compose를 이용해서 Apache Airflow를 설치한 상태이다.

 

> docker ps

 

    - 하지만, example들이 엄청 많이 보인다.

        . 공부하기 위해 참조할 수는 있지만, 삭제해도 다시 살아나고..... 지워버리고 싶은 상황이다.

 

http://localhost:8090/home

 

[ Docker Compose Down ]

    - 현재 설치된 것을 모두 지워버려야 한다.

 

> docker compose down

 

> docker compose down

 

[ Edit docker-compose.yaml ]

    - YAML 파일의 내용을 살짝 바꿔줘야 한다.

 

> nano docker-compose.yaml

 

> nano docker-compose.yaml

 

    - 빨간 박스에 있는 것 처럼, 해당 값을 false로 변경해주면 된다.

 

[ Re-install ]

    - 이제 설치/실행 진행하면 된다.

 

❯ docker compose up airflow-init


❯ docker compose up

 

    - 그리고 웹브라우저 다시 열고 접속하고 로그인 하면... 깨끗한 화면을 볼 수 있다!

 

http://localhost:8090/home

 

깔끔!

반응형

'AI_ML > MLOps' 카테고리의 다른 글

Apache Airflow install (아파치 에어플로우 설치)  (1) 2024.05.04

▷ Basic Info ...

    - MLOps에 대해서 공부를 하다보면 누구나 한 번 이상 꼭 듣게 되는 도구 ... Apache Airflow !!!

    - 공식 사이트를 방문해보면 바람개비와 함께 산뜻한 페이지가 반긴다.

        . https://airflow.apache.org/

 

https://airflow.apache.org/

 

    - 하지만, 우리같은(?) 도구쟁이들은 GitHub 사이트가 더 좋다 ^^

        . https://github.com/apache/airflow

 

https://github.com/apache/airflow

 

    - 최신병에 걸려있기 때문에(^^), 릴리즈 정보를 확인해봐야 한다.

        . https://airflow.apache.org/announcements/

 

https://airflow.apache.org/announcements/

 

▷ Prerequisites

    - 기본적으로 POSIX 호환 운영체제에서 Python만 있으면 설치는 가능하다.

        . Linux 배포판 및 MacOS가 기본적인 지원 운영체제이지만

        . WSL2에서도 실행은 가능하다. 다만, 주력 지원 환경은 아니기에 Production 환경으로는 추천하지 않는다.

        . Kubernetes 환경에서 동작 가능한 것이지 설치할 때 필수 환경은 아니다.

 

    - 메모리는 최소 4GB 이상이 필요하다.

 

    - 설치할 때 SQLite를 같이 포함해서 설치를 진행할 수 있지만, Production에서는 별도 DB 구성을 추천한다.

 

https://airflow.apache.org/docs/apache-airflow/2.9.0/installation/prerequisites.html

 

▷ Environments

    - 설치 과정을 함께할 운영체제는 Ubuntu 20.04 환경이다.

        . Airflow는 Debian 계열하고 제일 친한 것 같다. 그렇다면 Ubuntu가 최선이지 않을까!?

 

❯ lsb_release -a

No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.6 LTS
Release: 20.04
Codename: focal

 

    - 일단 메모리 상황을 점검해보자.

        . 메모리는 마음대로 할 수 있는 것이 아니니 부족하다면... 다른 서버를 찾아야 한다 ㅠ

 

❯ free -h

                  total        used          free       shared    buff/cache   available
Mem:       7.8Gi       679Mi       6.4Gi          13Mi          677Mi        6.8Gi
스왑:        2.0Gi          0B         2.0Gi

 

    - Python 버전을 확인해보자.

        . Python 버전 관리를 위해서는 Pyenv를 사용하는 것을 권장합니다 !!!

        . https://www.whatwant.com/entry/pyenv

 

❯ pyenv --version   

pyenv 2.3.9-11-g3d83bcdb


❯ python --version

Python 3.8.16

 

▷ Install #1 - PyPI + venv

    - Apache Airflow를 설치하는 여러 방법이 있는데,

      PyPI를 이용하는 방법과 Docker를 이용하는 방법에 대해서 살펴보고자 한다.

 

① pyenv

    - Python 3.10 버전 환경에서 설치를 해보고자 한다.

    - pyenv를 이용해서 원하는 버전을 설치하도록 하겠다.

 

❯ pyenv versions  

  system
* 3.8.16 (set by /home/chani22/.pyenv/version)

# 사용하고자 하는 버전이 설치되어 있는지 확인


❯ pyenv install -l

Available versions:
  2.1.3
  2.2.3
...

# 설치가 가능한 버전 확인


❯ pyenv install 3.10.9

Downloading Python-3.10.9.tar.xz...
-> https://www.python.org/ftp/python/3.10.9/Python-3.10.9.tar.xz
Installing Python-3.10.9...
Installed Python-3.10.9 to /home/chani22/.pyenv/versions/3.10.9

 

② workspace / venv

    - Airflow를 설치할 디렉토리를 확보하고,

    - Python venv를 이용하여 가상환경까지 생성해보자.

 

❯ mkdir airflow

❯ cd airflow

❯ pyenv local 3.10.9 

❯ python -m venv .venv

❯ ls -al

합계 16
drwxrwxr-x 3   chani22 chani22 4096  4월 29 01:18 .
drwxr-xr-x 3    chani22 chani22 4096  4월 29 01:16 ..
-rw-rw-r-- 1      chani22 chani22      7  4월 29 01:16 .python-version
drwxrwxr-x 5   chani22 chani22 4096  4월 29 01:18 .venv

❯ source .venv/bin/activate

 

③ ENV

    - 설치에 필요한 정보들을 위해서 환경 변수들을 설정해준다.

    - "/srv/install/airflow" 디렉토리는 위에서 만들어 놓은 것을 사용해도 된다.

    - "AIRFLOW_VERSION"은 지금 현재 가장 최신 버전을 선택했다.

    - "PYTHON_VERSION"의 경우에 그냥 명시적으로 "3.10"이라고 설정해버려도 된다.

    - "CONSTRAINT_URL" 역시 그냥 명시적으로 버전을 지정할 수도 있다.

 

❯ export AIRFLOW_HOME=/srv/install/airflow

❯ export AIRFLOW_VERSION=2.9.0

❯ export PYTHON_VERSION="$(python -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")')"

❯ export CONSTRAINT_URL="https://raw.githubusercontent.com/apache/airflow/constraints-${AIRFLOW_VERSION}/constraints-${PYTHON_VERSION}.txt"


❯ echo $PYTHON_VERSION

3.10


❯ echo $CONSTRAINT_URL

https://raw.githubusercontent.com/apache/airflow/constraints-2.9.0/constraints-3.10.txt

 

④ install

    - 준비 끝. 설치 시작!

 

❯  pip install "apache-airflow==${AIRFLOW_VERSION}" --constraint "${CONSTRAINT_URL}"

...


❯ pip list | grep airflow                                                          

apache-airflow                                          2.9.0
apache-airflow-providers-common-io       1.3.0
apache-airflow-providers-common-sql     1.11.1
apache-airflow-providers-fab                    1.0.2
apache-airflow-providers-ftp                     3.7.0
apache-airflow-providers-http                   4.10.0
apache-airflow-providers-imap                 3.5.0
apache-airflow-providers-smtp                 1.6.1
apache-airflow-providers-sqlite                3.7.1

 

⑤ DB init

    - 그냥 실행하는 방법도 있지만, 하나씩 차근차근 셋업하는 것을 추천한다.

 

❯ airflow db migrate

DB: sqlite:////srv/install/airflow/airflow.db
Performing upgrade to the metadata database sqlite:////srv/install/airflow/airflow.db
[2024-04-29T02:20:10.674+0900] {migration.py:216} INFO - Context impl SQLiteImpl.
[2024-04-29T02:20:10.710+0900] {migration.py:219} INFO - Will assume non-transactional DDL.
[2024-04-29T02:20:10.713+0900] {migration.py:216} INFO - Context impl SQLiteImpl.
[2024-04-29T02:20:10.714+0900] {migration.py:219} INFO - Will assume non-transactional DDL.
INFO  [alembic.runtime.migration] Context impl SQLiteImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
INFO  [alembic.runtime.migration] Running stamp_revision  -> 1949afb29106
Database migrating done!

 

⑥ make admin account

    - 관리자 계정을 만들어주자.

    - "--role Admin" 부분만 잘 지켜주고, 나머지는 각자 취향대로.

 

❯ airflow users create --username whatwant --firstname whatwant --lastname boss --role Admin --email whatwant@whatwant.com

...
Password:
Repeat for confirmation:
[2024-04-29T02:31:53.165+0900] {override.py:1516} INFO - Added user whatwant
User "whatwant" created with role "Admin"

 

⑦ run

    - 이제 웹 UI를 확인해보자.

 

airflow webserver --port 8080

 

    - 웹브라우저를 실행해서, 다음 주소로 접속하면 된다.

        . http://localhost:8080

 

http://localhost:8080/

 

    - 앞에서 생성한 계정과 패스워드를 이용해서 Sign in 하면 된다.

 

http://localhost:8080/

 

    - 뭔가 화면은 나왔는데, 위에 뭔가 알람이 많이 보인다.

 

⑧ notice

    - 어?! 그런데 뭔가 경고같은 메시지가 보인다.

 

notice

 

    - 가장 위에 있는 메시지를 보면 실행중인 "scheduler"가 안보인단다. 해결해보자.

 

⑨ scheduler

    - 새로운 터미널을 추가로 띄워서 scheduler를 실행하면 된다.

 

new terminal

 

   - 터미널을 새로 띄우면 Python 가상환경도 추가 설정해야 한다.

 

❯ cd airflow

# 앞에서 진행했던 airflow 디렉토리로 이동


❯ source .venv/bin/activate


❯ airflow scheduler

 

    - 웹브라우저를 reload(F5) 하면 갑자기 못보던 샘플 DAGs 가 보인다.

 

http://localhost:8080/home

 

    - 상단에 보이는 알람 메시지가 3개에서 2개로 줄어들었다.

    - 나머지 2개는 production 환경에서 SQLite나 SeuentialExecutor를 사용하지 말라는 메시지다. 일단 무시!

 

http://localhost:8080/dags/example_params_trigger_ui/grid?tab=graph

 

    - Sample을 하나 선택해서 살펴보면 뭔가 멋지다! ^^

 

 

▷ Install #2 - Docker + Compose

    - docker를 이용한 airflow 설치를 해보자.

    - 그냥 docker image를 이용한 실행말고, 여러 모듈들을 같이 구성하기 위해 docker compose를 사용하겠다.

    - https://airflow.apache.org/docs/apache-airflow/2.9.0/howto/docker-compose/index.html

 

① docker / docker-compose

    - docker 및 docker-compose가 설치되어 있어야 한다.

        . Ubuntu 20.04 기준으로 Quick-Guide는 다음과 같다.

 

❯ mkdir docker 

❯ cd docker      

❯ wget https://download.docker.com/linux/ubuntu/dists/focal/pool/stable/amd64/containerd.io_1.6.31-1_amd64.deb

❯ wget https://download.docker.com/linux/ubuntu/dists/focal/pool/stable/amd64/docker-buildx-plugin_0.14.0-1\~ubuntu.20.04\~focal_amd64.deb

❯ wget https://download.docker.com/linux/ubuntu/dists/focal/pool/stable/amd64/docker-ce-cli_26.1.1-1\~ubuntu.20.04\~focal_amd64.deb

❯ wget https://download.docker.com/linux/ubuntu/dists/focal/pool/stable/amd64/docker-ce_26.1.1-1\~ubuntu.20.04\~focal_amd64.deb

❯ wget https://download.docker.com/linux/ubuntu/dists/focal/pool/stable/amd64/docker-compose-plugin_2.27.0-1\~ubuntu.20.04\~focal_amd64.deb


❯ ls -al

합계 109212
drwxrwxr-x 2 chani22 chani22     4096  5월  1 10:31 .
drwxr-xr-x 4 chani22 chani22     4096  5월  1 10:29 ..
-rw-rw-r-- 1 chani22 chani22 29821672  4월 11 21:01 containerd.io_1.6.31-1_amd64.deb
-rw-rw-r-- 1 chani22 chani22 29650176  4월 30 01:48 docker-buildx-plugin_0.14.0-1~ubuntu.20.04~focal_amd64.deb
-rw-rw-r-- 1 chani22 chani22 14601364  5월  1 00:17 docker-ce-cli_26.1.1-1~ubuntu.20.04~focal_amd64.deb
-rw-rw-r-- 1 chani22 chani22 25267932  5월  1 00:17 docker-ce_26.1.1-1~ubuntu.20.04~focal_amd64.deb
-rw-rw-r-- 1 chani22 chani22 12478416  5월  1 00:17 docker-compose-plugin_2.27.0-1~ubuntu.20.04~focal_amd64.deb


❯ sudo dpkg --install containerd.io_1.6.31-1_amd64.deb 

❯ sudo dpkg --install docker-ce-cli_26.1.1-1\~ubuntu.20.04\~focal_amd64.deb 

❯ sudo dpkg --install docker-ce_26.1.1-1\~ubuntu.20.04\~focal_amd64.deb    

❯ sudo dpkg --install docker-buildx-plugin_0.14.0-1\~ubuntu.20.04\~focal_amd64.deb 

❯ sudo dpkg --install docker-compose-plugin_2.27.0-1\~ubuntu.20.04\~focal_amd64.deb 


sudo usermod -aG docker $USER

# 터미널 재시작


❯ docker --version

Docker version 26.1.1, build 4cf5afa


❯ docker compose version

Docker Compose version v2.27.0

 

② download YAML

    - airflow 설치 과정을 위한 디렉토리 만들고

    - docker-compose YAML 파일을 다운로드 받자

 

❯ mkdir airflow-docker

❯ cd airflow-docker

❯ wget https://airflow.apache.org/docs/apache-airflow/2.9.0/docker-compose.yaml

--2024-05-01 10:44:57--  https://airflow.apache.org/docs/apache-airflow/2.9.0/docker-compose.yaml
airflow.apache.org (airflow.apache.org) 해석 중... 151.101.2.132, 2a04:4e42::644
다음으로 연결 중: airflow.apache.org (airflow.apache.org)|151.101.2.132|:443... 연결했습니다.
HTTP 요청을 보냈습니다. 응답 기다리는 중... 200 OK
길이: 11197 (11K)
저장 위치: `docker-compose.yaml'

docker-compose.yaml                 100%[==========================================>]  10.93K  --.-KB/s    / 0s       

2024-05-01 10:44:57 (45.5 MB/s) - `docker-compose.yaml' 저장함 [11197/11197]

 

    - YAML 파일 내용을 살펴보면 알겠지만, 많은 서비스가 별도의 docker로 구성되어 있다.

        . airflow-scheduler

        . airflow-webserver

        . airflow-worker

        . airflow-triggerer

        . airflow-init

        . postgres

        . redis

 

    - 그래서 메모리가 충분히 필요한데, 최소 4GB / 권장 8GB 이다.

 

③ mkdir

    - 여러 종류의 파일들을 저장할 디렉토리들을 만들어 놓자.

        . ./dags - you can put your DAG files here.
        . ./logs - contains logs from task execution and scheduler.
        . ./config - you can add custom log parser or add airflow_local_settings.py to configure cluster policy.
        . ./plugins - you can put your custom plugins here.

 

❯ mkdir -p ./dags ./logs ./plugins ./config


❯ ls -al

합계 36
drwxrwxr-x 6 chani22 chani22  4096  5월  1 10:53 .
drwxr-xr-x 5 chani22 chani22  4096  5월  1 10:44 ..
drwxrwxr-x 2 chani22 chani22  4096  5월  1 10:53 config
drwxrwxr-x 2 chani22 chani22  4096  5월  1 10:53 dags
-rw-rw-r-- 1 chani22 chani22 11197  4월  8 20:42 docker-compose.yaml
drwxrwxr-x 2 chani22 chani22  4096  5월  1 10:53 logs
drwxrwxr-x 2 chani22 chani22  4096  5월  1 10:53 plugins

 

④ UID

    - airflow가 실행될 UID도 설정해주자.

 

❯ echo -e "AIRFLOW_UID=$(id -u)" > .env


❯ cat .env

AIRFLOW_UID=1000

 

⑤ Customizing

    - YAML 파일을 수정할 수도 있다.

    - port만 살짝 바꿔봤다. (각자 취향)

 

❯ nano docker-compose.yaml

 

⑥ Initialize the database

    - DB 초기화를 진행하자.

 

❯ docker compose up airflow-init

 

    - 잘 실행되면 아래와 같은 화면이 나온다.

 

❯ docker compose up airflow-init

 

    - 아래와 같이 Permission denied 상황이 나올 수도 있는데,

      sock 파일의 권한을 조정하거나 그래도 안되면 재부팅 한 번 해주면 잘 된다.

 

❯ docker compose up airflow-init

permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.45/containers/json?all=1&filters=%7B%22label%22%3A%7B%22com.docker.compose.config-hash%22%3Atrue%2C%22com.docker.compose.project%3Dairflow-docker%22%3Atrue%7D%7D": dial unix /var/run/docker.sock: connect: permission denied


❯ sudo chown root:docker /var/run/docker.sock

 

    - 현재 상태를 확인해보면 다음과 같다.

 

❯ ls -al

합계 40
drwxrwxr-x 6 chani22 chani22  4096  5월  1 11:00 .
drwxr-xr-x 5 chani22 chani22  4096  5월  1 10:44 ..
-rw-rw-r-- 1 chani22 chani22    17  5월  1 10:55 .env
drwxrwxr-x 2 chani22 chani22  4096  5월  1 10:53 config
drwxrwxr-x 2 chani22 root     4096  5월  1 10:53 dags
-rw-rw-r-- 1 chani22 chani22 11197  5월  1 11:00 docker-compose.yaml
drwxrwxr-x 2 chani22 root     4096  5월  1 10:53 logs
drwxrwxr-x 2 chani22 root     4096  5월  1 10:53 plugins


❯ docker ps

CONTAINER ID   IMAGE          COMMAND                   CREATED         STATUS                   PORTS      NAMES
1dfae6410fa0   postgres:13    "docker-entrypoint.s…"   4 minutes ago   Up 4 minutes (healthy)   5432/tcp   airflow-docker-postgres-1
466bc0539812   redis:latest   "docker-entrypoint.s…"   4 minutes ago   Up 4 minutes (healthy)   6379/tcp   airflow-docker-redis-1

 

⑦ Run Airflow

    - 이제 Airflow를 실행하자.

 

  docker compose up

...

 

   - 뭔가 잔뜩 메시지가 흘러나온다.

 

❯ docker compose up

 

    - 웹브라우저를 열어서 접속해보자.

        . http://localhost:8090/

        . 접속 정보: airflow / airflow

 

http://localhost:8090/

 

    - 어!? 뭔가 되게 깔끔한 화면이 나온다.

 

http://localhost:8090/home

 

    - Container 정보를 살펴보자.

 

> docker ps

 

 

우와~~~~ 뭔가 엄청 길었다.

추가적으로 살펴볼 것이 많이 남아있지만 일단 "설치 후 실행"이라는 것에 주안점을 두었다.

 

"운영" 측면에서는 더 알아봐야할 것이 많겠지만 지금은 여기까지만~~~ ^^

반응형

'AI_ML > MLOps' 카테고리의 다른 글

Airflow remove Example DAGs (에어플로우 예제 삭제)  (0) 2024.05.04

AI / ML 공부를 하면 무조건(?) 사용하게 되는 "주피터 노트북(Jupyter Notebook)"

 

pandas, numpy, scikit-learn 등 착실하게 공부를 해야하는 것은 맞지만

모든 것들을 외워서 사용하기에는 어려움이 많고, 또 일일이 타이핑을 하는 것이 효율적이지도 않다.

 

그래서 Jupyter Notebook을 사용하면서 도움을 주는 기능들에 대해서 하나씩 알아보자.

 

 

① 자동 완성(auto complete) : Tab

  - IDE를 사용하거나 리눅스 커맨드 창에서 bash 또는 zsh 등을 사용할 때, 가장 많이 사용하는 tab !!!

  - 그런데, Jupyter Notebook에서 아래와 같이 타이핑을 하다가 tab을 눌러도 .... 아무런 반응이 없다.

 

 

  - import를 먼저 실행해서 "pd"가 뭔지 알려줘야 자동완성 기능을 사용할 수 있게 된다.

 

 

② 툴팁 (Tool Tip) : Shift + Tab 

  - 함수의 파라미터(parameter)들이 뭐가 있는지 확인하고 싶다면? Shift-Tab을 눌러주면 된다 !!!

 

 

③ 툴팁 (Tool Tip) : ?

  - pop-up으로 뜨는 툴팁이 조금 불편하다면, "?"를 이용해도 된다.

  - 함수명 뒤에 "?"를 타이핑하고, 실행을 시키면 밑에 출력이 된다.

 

 

 

④ Display parameter : set_config

  - scikit-learn의 model을 사용하다보면 parameter들을 확인해보고 싶을 때가 있다.

 

 

  - model에서 명시적으로 입력한 parameter 값만 확인이 되는데,

  - 현재 default로 지정된 parameter 값을 포함해서 전체 내역을 확인하고 싶을 때가 있다

 

  - scikit-learn 환경설정을 통해서 해결할 수 있다.

 

 

  - 이제 어떤 parameter로 해당 모델이 실행되는지 눈으로 확인할 수 있다 !!!

 

 

⑤ 도움말 (Help) : help

  - 자고로 도움말은 help !!!

 

 

  - 예쁘게 출력되진 않지만, 많은 정보를 보여준다.

 

반응형

AI를 이용한 코딩을 한다고 할 때, 제일 먼저 떠오르는 것은 GitHub의 Copilot이다.

개인적으로도 정말 애정하는 것이 바로 Copilot이다.

 

그러던 중, 요즘 많은 관심을 받고 있다는 'GPT Pilot'이라는 것을 알게 되었다.

응?! ChatGPT + Copilot ????

- https://github.com/Pythagora-io/gpt-pilot

GPT Pilot

 

타이틀만 보면 왠지 짝퉁 느낌이 많이 들지만, 사람들의 엄청난 관심을 받은 것을 보면 사짜는 아닌 것 같다 ^^

Star 숫자를 보면 거의 1만5천 ... 부럽다.

Fork, Star

 

정체를 설명한 글을 살펴보면

무려 개발 속도를 20배나 빠르게 해준단다!!!

20x faster

 

그런데, 설명을 보면 Copilot의 아류작이 아니라 Auto-GPT의 아류작인 것으로 보인다.

Copilot처럼 IDE Extension 방식으로 인터페이스 하는 것이 아니라 CLI 환경에서의 티키타카 방식이다.

 

그러면 이 프로젝트는 왜 만들어진 것일까? 목적이 무엇일까? 그리고 한계점을 무엇일까?

aim

 

GPT-4를 이용해서 개발자가 실무에서 얼마나 도움을 받을 수 있는지를 확인하고자 하는 목적이며,

결국 5% 정도는 개발자가 관여를 해야한다는 점을 밝히고 있다.

 

 

지금까지 배경에 대해서는 충분히 알아봤으니 일단 한 번 부딪혀보자 !!!

 

▶ Requirements

   - Python 3.9-3.12

   - PostgreSQL (선택 사항, 기본값은 SQLite)

 

티키타카를 하면서 진행을 하기 위해서는 진행되고 있는 내용을 기억해야할 저장소가 필요하기에 DB가 필수라고 한다.

 

① Python

   - 원하는 버전의 Python을 편하게 사용하려면 pyenv를 활용하는 것을 추천한다.

      . https://www.whatwant.com/entry/pyenv

❯ pyenv versions      
  system
* 3.8.16 (set by /home/chani22/.pyenv/version)

❯ pyenv install --list | grep 3.9.
...
  3.9.15
  3.9.16
...

❯ pyenv install 3.9.16
Downloading Python-3.9.16.tar.xz...
-> https://www.python.org/ftp/python/3.9.16/Python-3.9.16.tar.xz
Installing Python-3.9.16...

❯ pyenv global 3.9.16

❯ python --version  
Python 3.9.16

 

② PostgreSQL

   - 음... 기본값으로 SQLite를 사용하게 되어있으므로, 일단 빠른 진행을 위해 지금은 생략 ^^ (절대 귀찮아서가 아닙... ^^)

 

▶ install / clone

GPT Pilot 사용하기 위해 clone 및 설정을 진행해보자.

 

① clone

❯ git clone https://github.com/Pythagora-io/gpt-pilot.git
'gpt-pilot'에 복제합니다...

❯ cd gpt-pilot

 

② 필요 패키지 설치

❯ python -m venv pilot-env

❯ source pilot-env/bin/activate

❯ pip install -r requirements.txt

 

③  환경 파일 생성

❯ cd pilot

❯ mv .env.example .env

 

▶ Key 등록

OPENAI가 아닌 AZURE, OPENROUTER도 사용할 수 있다는데, 우린 그냥 OPENAI를 사용하는 것으로 하자.

- https://platform.openai.com/api-keys

API keys

 

새로 secret key를 생성해보자.

Create

 

생성된 key 복사 잘 해서 입력하고, 저장하자.

.env

 

▶ DB Init

사실 지금은 별게 없는데, 나중에 PostgreSQL을 사용하게 되면 보충해야할 영역인 것 같다.

❯ python db_init.py

 

▶ Start (#1)

일단 시작해보자.

Start #1

 

GPT 4 API를 사용할 수 없단다!

 

어!? 나는 유료 사용자인데?!

세금 포함해서 무려 22$를 지불하고 있는데, 이게 뭔 헛소리야!?

 

▶ GPT4 API

그동안 채팅만 했지 API를 사용하지를 않았더니.... 이런 무식한 상황이 ^^

결재 정보를 등록해야 GPT4 API를 사용할 수 있다.

- https://platform.openai.com/account/billing/payment-methods

Payment methods

 

Payment 정보를 등록하자.

Add payment details

 

"Add payment details"를 클릭하면 된다.

card info

 

최소 5$ 결제를 해야 한다.

치사한 XX

purchase

 

통장에 돈을 넣어놔야 뭔가 사용권을 주는 그런 느낌...

5$

 

사용할 수 있는 API들은 다음과 같이 확인할 수 있다.

- https://platform.openai.com/account/limits

limits

 

▶ Start (#2)

아까 에러난 상황에서 위와 같이 GPT4 API를 사용할 수 있게 해놓고

이어서 시작하려고 하면 ... 그래도 안된다.

 

시간이 좀 지나면 되는 걸 수도 있지만 잘 안되어서 사용하던 터미널 종료 하고

secret key 재발급 받고, .env 파일에 다시 입력한 뒤에 다음과 같이 다시 진입하였다.

 

❯ cd /path/gpt-pilot   # gpt-pilot 루트 경로

❯ source pilot-env/bin/activate

❯ cd pilot

❯ python main.py

 

만들어보고자 하는 사례는 "GitHub 관련 뉴스를 수집해서 보여주는 웹페이지"로 해봤다.

 

❯ python main.py

------------------ STARTING NEW PROJECT ----------------------
If you wish to continue with this project in future run:
python main.py app_id=448522d6-d6d2-4fe3-be2b-33c731dac5eb
--------------------------------------------------------------

? What is the project name? GitHub_News


? Describe your app in as much detail as possible. Develop a webpage that aggregates and displays news about GitHub.

? Which platforms do you want to support with this application: web, mobile or both? web

? Does the content need to be updated in real-time? Or is a daily/weekly update sufficient? daily

? Do you have specific sources in mind that the application should scrape for GitHub news or should it search widely across the internet? no

? Do you want to include a user login system or should the webpage be publicly accessible to anyone without login? no

{"technologies": ["Node.js", "MongoDB", "Mongoose", "Bootstrap", "Javascript", "cronjob", "Socket.io"]}

? Please set up your local environment so that the technologies listed can be utilized. When you're done, write "DONE" 

 

물어보는 것에 대답을 해주면 된다.

그런데 ...

 

...

🚀 Now for the actual development...

Implementing task #1:  Setup Node.js server

To complete task one, let's outline the steps necessary. We need to:

1. Initialize NPM and download the necessary packages. 
2. Build a basic Express app and put it in server.js.

**Step 1: Initialize NPM and download necessary packages.**

To initialize NPM in your current directory and fetch necessary libraries, run the following commands in your terminal:

```
npm init -y
npm install express
```

...

--------- EXECUTE COMMAND ----------
Can I execute the command: `node --version` with 2000ms timeout?
? If yes, just press ENTER

 

잘 진행하다가 갑자기 node 관련해서 에러가 발생했는데...

뭔가 무한루프에 빠진 느낌으로 계속 node 관련해서 벗어나지를 못하는 것이다!

 

▶ node

GPT Pilot은 기본적으로 node를 아주 선호한다.

그런데, node를 설치까지는 해주지 못하는 것으로 보인다.

그러면, 직접 설치를 해줘야지.... ㅠㅠ

 

pyenv처럼 여러 버전의 node를 관리할 수 있는 nvm을 이용해서 node를 설치하자.

- https://www.whatwant.com/entry/npm

 

그리고 지금 사용하고 있는 터미널을 종료하고,

다시 GPT Pilot을 시작하자.

 

❯ cd /path/gpt-pilot   # gpt-pilot 루트 경로

❯ source pilot-env/bin/activate

❯ cd pilot

❯ python main.py

 

▶ Start (#3)

같은 설명을 줘도 뒤에 따라오는 질문들은 바뀐다.

그것에 따라 진행하는 소스코드 내용도 바뀐다.

즉, 할 때 마다 다른 결과물이 나올 수 있다는 말이다.

 

❯ python db_init.py 

------------------ STARTING NEW PROJECT ----------------------
If you wish to continue with this project in future run:
python main.py app_id=c06e0511-9f0f-4b1f-9c49-1347fc82d116
--------------------------------------------------------------

? What is the project name? GitHub_News


? Describe your app in as much detail as possible. Develop a webpage that aggregates news about GitHub.

? Should the news aggregation be real-time or periodically updated? daily

? Should the aggregated news be categorized based on specific topics or tags associated with GitHub? no

? Do you have any specific sources in mind from where the news about GitHub should be aggregated? no

? Is there a limit to the number of news items to be displayed or stored at any given time? 15

? Would you like the app to have an archive feature where older news can be accessed? no

Project Summary:

The "GitHub_News" app will be a webpage designed to aggregate news about GitHub. The content on this webpage will be updated daily without categorizing into specific topics or tags. There are no prescribed sources from where the news about GitHub should be aggregated. The number of news items displayed or stored at any given time will be limited to 15. There will be no archive feature, hence older news items won't be accessible.

{"technologies": ["Node.js", "MongoDB", "Mongoose", "Jest", "Bootstrap", "Vanilla JavaScript", "cronjob"]}

? Please set up your local environment so that the technologies listed can be utilized. When you're done, write "DONE" 

 

"DONE"을 하고 나면 스스로 뭔가 코딩을 시작한다.

필요한 패키지들 설치도 하고 DB도 생성하고....

 

 ...

Dev step 1

First, you need to initialize npm for your new Node.js project. Run the following command:

```bash
npm init -y
```

This will create a file 'package.json' in your project directory and will be used to store metadata about your app and also track the dependencies of your app such as Express, Mongoose, etc. 

Next, you'll require several Node.js packages to develop the app, and for the current task, you need to install Express, Mongoose, and node-cron. Run the following command to install these dependencies:

```
npm install express mongoose node-cron
```

Next, you also need to set up your main application file. Let's call it 'app.js'. 

/app.js
```javascript
const express = require('express');
const mongoose = require('mongoose');
const cron = require('node-cron');

const app = express();

//Express body parser middleware
app.use(express.json());
app.use(express.urlencoded({ extended: false }));

app.get('/', (req, res) => {
    res.send('Hello World!');
});

// Define your port
const PORT = process.env.PORT || 3000;

// Starting the server
app.listen(PORT, () => {
    console.log(`App running on port ${PORT}`);
});
```

To test the set up, run the server with the command:

```
node app.js
```

Dev step 2

{"tasks": [{"type": "command", "command": {"command": "npm init -y", "timeout": 2500, "success_message": "created a new package.json file"}}, {"type": "command", "command": {"command": "npm install express mongoose node-cron", "timeout": 10000, "success_message": "added packages"}}, {"type": "code_change", "code_change": {"name": "app.js", "path": "app.js", "content": "const express = require('express');\nconst mongoose = require('mongoose');\nconst cron = require('node-cron');\n\nconst app = express();\n\n//Express body parser middleware\napp.use(express.json());\napp.use(express.urlencoded({ extended: false }));\n\napp.get('/', (req, res) => {\n    res.send('Hello World!');\n});\n\n// Define your port\nconst PORT = process.env.PORT || 3000;\n\n// Starting the server\napp.listen(PORT, () => {\n    console.log(`App running on port ${PORT}`);\n});"}}, {"type": "command", "command": {"command": "node app.js", "timeout": 5000, "success_message": "App running on port 3000", "command_id": "run_server"}}]}


--------- EXECUTE COMMAND ----------
Can I execute the command: `npm init -y` with 2500ms timeout?
? If yes, just press ENTER 


answer: 
CLI OUTPUT:Wrote to /srv/workspace/gpt-pilot/workspace/GitHub_News/package.json:
CLI OUTPUT:{
CLI OUTPUT:  "name": "github_news",
CLI OUTPUT:  "version": "1.0.0",
CLI OUTPUT:  "description": "",
CLI OUTPUT:  "main": "index.js",
CLI OUTPUT:  "directories": {
CLI OUTPUT:    "test": "tests"
CLI OUTPUT:  },
CLI OUTPUT:  "scripts": {
CLI OUTPUT:    "test": "echo \"Error: no test specified\" && exit 1"
CLI OUTPUT:  "keywords": [],
CLI OUTPUT:  "author": "",
CLI OUTPUT:  "license": "ISC"
Saving file /package.json

Dev step 3

DONE


--------- EXECUTE COMMAND ----------
Can I execute the command: `npm install express mongoose node-cron` with 10000ms timeout?
? If yes, just press ENTER 


answer: 

Saving file /package.json

Saving file /package.json

Dev step 5

{"thoughts": "From developer's description, they say the 'npm install' command took longer than 10,000 milliseconds to execute and was therefore terminated. This could be due to slow network speeds or the npm registry taking a longer time to respond. It could be a transient issue that could be resolved by trying again.  Or it could be a more persistent issue related to firewall restrictions or other network related issues.", "reasoning": "First, we want to confirm that we have network connection, then we can try testing the npm service by attempting to install a small, commonly used package (like 'lodash') to see if it also hangs. If the 'lodash' package installation succeeds without hanging, we can then try re-running the initial command as it may have been a transient npm registry issue.", "steps": [{"type": "command", "command": {"command": "ping -c 5 npmjs.com", "timeout": 5000, "success_message": "5 packets transmitted, 5 received"}, "check_if_fixed": false}, {"type": "command", "command": {"command": "npm install lodash", "timeout": 10000, "success_message": "+ lodash"}, "check_if_fixed": false}, {"type": "command", "command": {"command": "npm install express mongoose node-cron", "timeout": 30000, "success_message": "+ express\n + mongoose\n + node-cron"}, "check_if_fixed": true}]}


--------- EXECUTE COMMAND ----------
Can I execute the command: `ping -c 5 npmjs.com` with 5000ms timeout?
? If yes, just press ENTER 


answer: 
CLI OUTPUT:PING npmjs.com (104.19.154.92) 56(84) bytes of data.
CLI OUTPUT:64 바이트 (104.19.154.92 (104.19.154.92)에서): icmp_seq=1 ttl=51 시간=3.70 ms
CLI OUTPUT:64 바이트 (104.19.154.92 (104.19.154.92)에서): icmp_seq=2 ttl=51 시간=6.01 ms
CLI OUTPUT:64 바이트 (104.19.154.92 (104.19.154.92)에서): icmp_seq=3 ttl=51 시간=3.63 ms
CLI OUTPUT:64 바이트 (104.19.154.92 (104.19.154.92)에서): icmp_seq=4 ttl=51 시간=3.58 ms
CLI OUTPUT:64 바이트 (104.19.154.92 (104.19.154.92)에서): icmp_seq=5 ttl=51 시간=5.32 ms
CLI OUTPUT:--- npmjs.com 핑 통계 ---
CLI OUTPUT:5 패킷이 전송되었습니다, 5 수신되었습니다, 0% 패킷 손실, 시간 4005ms
Saving file /package.json

Dev step 6

DONE


--------- EXECUTE COMMAND ----------
Can I execute the command: `npm install lodash` with 10000ms timeout?
? If yes, just press ENTER 


answer: 
CLI OUTPUT:
CLI OUTPUT:added 1 package, and audited 2 packages in 573ms
Saving file /package.json

Dev step 7

DONE


--------- EXECUTE COMMAND ----------
Can I execute the command: `npm install express mongoose node-cron` with 30000ms timeout?
? If yes, just press ENTER 


answer: 
CLI OUTPUT:
CLI OUTPUT:added 86 packages, and audited 88 packages in 3s
CLI OUTPUT:12 packages are looking for funding
CLI OUTPUT:  run `npm fund` for details
Saving file /package.json

Dev step 8

DONE
Saving file /package.json

Dev step 9

NO
Saving file /package.json
Saving file /app.js
Can you check if the app works please? Here is a description of what should be working: 

Testing this task doesn't involve any API requests or writing any code. Instead, we will check whether the server is running properly and dependencies are installed correctly via npm. 

To do this, a human user should perform the following steps:

1. In the terminal, navigate to the project directory using the command `cd /path-to-your-project-directory`.

2. To test if the server runs without any issues, type the following command in your terminal:

```bash
node app.js
```

You should see a response saying 'App running on port 3000'. This verifies that the server is running properly with the specified dependencies.

3. Press `Ctrl + C` to stop the server.

4. Next, verify that the dependencies are installed correctly. Open the 'package.json' file and under 'dependencies', it should list the following:

```json
"dependencies": {
    "express": "version-number",
    "mongoose": "version-number",
    "node-cron": "version-number"
}
```
The 'version-number' should represent the installed version of each package.

If the server runs correctly and the 'package.json' file lists the correct dependencies, the task has been successfully completed.


If you want to run the app, just type "r" and press ENTER and that will run `node app.js`
? If something is wrong, tell me or type "continue" to continue. 


Can you check if the app works please? Here is a description of what should be working: 

Testing this task doesn't involve any API requests or writing any code. Instead, we will check whether the server is running properly and dependencies are installed correctly via npm. 

To do this, a human user should perform the following steps:

1. In the terminal, navigate to the project directory using the command `cd /path-to-your-project-directory`.

2. To test if the server runs without any issues, type the following command in your terminal:

```bash
node app.js
```

You should see a response saying 'App running on port 3000'. This verifies that the server is running properly with the specified dependencies.

3. Press `Ctrl + C` to stop the server.

4. Next, verify that the dependencies are installed correctly. Open the 'package.json' file and under 'dependencies', it should list the following:

```json
"dependencies": {
    "express": "version-number",
    "mongoose": "version-number",
    "node-cron": "version-number"
}
```
The 'version-number' should represent the installed version of each package.

If the server runs correctly and the 'package.json' file lists the correct dependencies, the task has been successfully completed.


If you want to run the app, just type "r" and press ENTER and that will run `node app.js`
? If something is wrong, tell me or type "continue" to continue. r


CLI OUTPUT:App running on port 3000

^C
CTRL+C detected. Stopping command execution...
Can you check if the app works please? Here is a description of what should be working: 

Testing this task doesn't involve any API requests or writing any code. Instead, we will check whether the server is running properly and dependencies are installed correctly via npm. 

To do this, a human user should perform the following steps:

1. In the terminal, navigate to the project directory using the command `cd /path-to-your-project-directory`.

2. To test if the server runs without any issues, type the following command in your terminal:

```bash
node app.js
```

You should see a response saying 'App running on port 3000'. This verifies that the server is running properly with the specified dependencies.

3. Press `Ctrl + C` to stop the server.

4. Next, verify that the dependencies are installed correctly. Open the 'package.json' file and under 'dependencies', it should list the following:

```json
"dependencies": {
    "express": "version-number",
    "mongoose": "version-number",
    "node-cron": "version-number"
}
```
The 'version-number' should represent the installed version of each package.

If the server runs correctly and the 'package.json' file lists the correct dependencies, the task has been successfully completed.


If you want to run the app, just type "r" and press ENTER and that will run `node app.js`
? If something is wrong, tell me or type "continue" to continue. r


CLI OUTPUT:App running on port 3000
^C
CTRL+C detected. Stopping command execution...
? If something is wrong, tell me or type "continue" to continue. continue


Implementing task #2:  Set up MongoDB and create a Mongoose schema for storing the GitHub news

To complete the task "Set up MongoDB and create a Mongoose schema for storing the GitHub news", we need to make some changes to the existing file and create new ones.

Here is the required code.


**/config/db.js**
```
const mongoose = require('mongoose');

// Replace this with your MONGOURI.
const MONGOURI = "mongodb://localhost:27017/github_news_db";

const InitiateMongoServer = async () => {
  try {
    await mongoose.connect(MONGOURI, {
      useNewUrlParser: true,
      useUnifiedTopology: true
    });
    console.log("Connected to the Database :: MongoDB");
  } catch (e) {
    console.log(e);
    throw e;
  }
};

module.exports = InitiateMongoServer;
```

The MONGOURI should be replaced with the actual address where MongoDB is running.

Next, a schema for the news needs to be created.

**/models/News.js**
```
const mongoose = require('mongoose');

const NewsSchema = mongoose.Schema({
  title: String,
Saving file /package.json
Saving file /app.js

Dev step 12

To complete the task "Set up MongoDB and create a Mongoose schema for storing the GitHub news", we need to make some changes to the existing file and create new ones.

Here is the required code.


**/config/db.js**
```
const mongoose = require('mongoose');

// Replace this with your MONGOURI.
const MONGOURI = "mongodb://localhost:27017/github_news_db";

const InitiateMongoServer = async () => {
  try {
    await mongoose.connect(MONGOURI, {
      useNewUrlParser: true,
      useUnifiedTopology: true
    });
    console.log("Connected to the Database :: MongoDB");
  } catch (e) {
    console.log(e);
    throw e;
  }
};

module.exports = InitiateMongoServer;
```

The MONGOURI should be replaced with the actual address where MongoDB is running.

Next, a schema for the news needs to be created.

**/models/News.js**
```
const mongoose = require('mongoose');

const NewsSchema = mongoose.Schema({
  title: String,
  description: String,
  url: String,
  date: Date
});

module.exports = mongoose.model('News', NewsSchema);
```

Finally, we should call the function to connect to the database at the start of our application.

**/app.js**
```
const express = require('express');
const cron = require('node-cron');
const InitiateMongoServer = require('./config/db');

const app = express();
app.use(express.json());
app.use(express.urlencoded({ extended: false }));

InitiateMongoServer();

app.get('/', (req, res) => {
  res.send('Hello World!');
});

const PORT = process.env.PORT || 3000;

app.listen(PORT, () => {
  console.log(`App running on port ${PORT}`);
});
```

In the above code we required the db.js file and initiated the Mongo server using the function "InitiateMongoServer". dB.js file handles the connection to MongoDB.

To test this task, you can just run the server and if server logs "Connected to the Database :: MongoDB" message, that means MongoDB is connected successfully. If there are any errors in connection, it will also be logged to console.
Use the following command to start the server:

```bash
node app.js
```
Saving file /package.json
Saving file /app.js

Dev step 13

{"tasks": [{"type": "code_change", "code_change": {"name": "db.js", "path": "/config/db.js", "content": "const mongoose = require('mongoose');\n\nconst MONGOURI = \"mongodb://localhost:27017/github_news_db\";\n\nconst InitiateMongoServer = async () => {\n  try {\n    await mongoose.connect(MONGOURI, {\n      useNewUrlParser: true,\n      useUnifiedTopology: true\n    });\n    console.log(\"Connected to the Database :: MongoDB\");\n  } catch (e) {\n    console.log(e);\n    throw e;\n  }\n};\n\nmodule.exports = InitiateMongoServer;"}}, {"type": "code_change", "code_change": {"name": "News.js", "path": "/models/News.js", "content": "const mongoose = require('mongoose');\n\nconst NewsSchema = mongoose.Schema({\n  title: String,\n  description: String,\n  url: String,\n  date: Date\n});\n\nmodule.exports = mongoose.model('News', NewsSchema);"}}, {"type": "code_change", "code_change": {"name": "app.js", "path": "/app.js", "content": "const express = require('express');\nconst cron = require('node-cron');\nconst InitiateMongoServer = require('./config/db');\n\nconst app = express();\napp.use(express.json());\napp.use(express.urlencoded({ extended: false }));\n\nInitiateMongoServer();\n\napp.get('/', (req, res) => {\n  res.send('Hello World!');\n});\n\nconst PORT = process.env.PORT || 3000;\n\napp.listen(PORT, () => {\n  console.log(`App running on port ${PORT}`);\n});"}}, {"type": "command", "command": {"command": "node app.js", "timeout": 10000, "success_message": "Connected to the Database :: MongoDB"}}]}

Updated file /srv/workspace/gpt-pilot/workspace/GitHub_News/config/db.js
Updated file /srv/workspace/gpt-pilot/workspace/GitHub_News/models/News.js
Updated file /srv/workspace/gpt-pilot/workspace/GitHub_News/app.js

--------- EXECUTE COMMAND ----------
Can I execute the command: `node app.js` with 10000ms timeout?
? If yes, just press ENTER 


answer: 
CLI OUTPUT:App running on port 3000
CLI ERROR:(node:26226) [MONGODB DRIVER] Warning: useNewUrlParser is a deprecated option: useNewUrlParser has no effect since Node.js Driver version 4.0.0 and will be removed in the next major version
CLI ERROR:(Use `node --trace-warnings ...` to show where the warning was created)
CLI ERROR:(node:26226) [MONGODB DRIVER] Warning: useUnifiedTopology is a deprecated option: useUnifiedTopology has no effect since Node.js Driver version 4.0.0 and will be removed in the next major version

Saving file /package.json
Saving file /app.js
Saving file /config/db.js
Saving file /models/News.js

Dev step 14

NEEDS_DEBUGGING

Got incorrect CLI response:
stderr:
```
(node:26226) [MONGODB DRIVER] Warning: useNewUrlParser is a deprecated option: useNewUrlParser has no effect since Node.js Driver version 4.0.0 and will be removed in the next major version
Saving file /package.json
Saving file /app.js
Saving file /config/db.js
Saving file /models/News.js

Dev step 15

{"thoughts": "From error messages, it looks like an issue with the database connection. May happen due an unaccessible or inactive MongoDB server or incorrect MONGOURI. Furthermore, there are warnings related to `useNewUrlParser` and `useUnifiedTopology` that have no effect since MongoDB driver version 4.0. First, we need to ensure MongoDB server is running and accessible.", "reasoning": "By checking if MongoDB server is running, and if the URI is correct, we will verify whether the issue exists with the database connection. Also, we can safely remove the warnings by updating the options in the mongoose.connect call as these options are deprecated and have no effect with the updated MongoDB driver version.", "steps": [{"type": "command", "command": {"command": "service mongod status | grep active", "timeout": 3000, "success_message": "active (running)"}, "need_to_see_output": true, "check_if_fixed": false}, {"type": "code_change", "code_change_description": "/config/db.js: Change the 'mongoose.connect' part of the code to `await mongoose.connect(MONGOURI);` This will create a basic connection without the deprecated flags.", "check_if_fixed": false}, {"type": "command", "command": {"command": "node app.js", "timeout": 10000, "success_message": "Connected to the Database :: MongoDB"}, "check_if_fixed": true}]}


--------- EXECUTE COMMAND ----------
Can I execute the command: `service mongod status | grep active` with 3000ms timeout?
? If yes, just press ENTER 

Saving file /package.json
Saving file /app.js
Saving file /config/db.js
Saving file /models/News.js

Dev step 16

{"thoughts": "The deprecated options warning itself won't cause the connection to MongoDB to hang. The initial thoughts are that MongoDB is not running as it's supposed to, or the connection string, MONGOURI, is not correct", "reasoning": "To verify the initial thoughts, we should in order first check the mongo service status and then check if MongoDB is lSaving file /package.json
Saving file /app.js
Saving file /config/db.js
Saving file /models/News.js

Dev step 17

{"thoughts": "It seems like the MongoDB connection is taking longer than expected. This may be due to a misconfiguration in the Database URL.", "reasoning": "We need to check the MongoDB server status and ensure it's up and running. If the MongoDB server is up then the issue might be in the database connection string or MongoDB deprecation warnings. RemoviSaving file /package.json
Saving file /app.js
Saving file /config/db.js
Saving file /models/News.js

Dev step 18

{"thoughts": "It seems that the MongoDB server might not be running or the connection string might be incorrectly specified. Adjusting the connection string and checking if MongoDB service is running should solve the problem.", "reasoning": "In the output logs, we see that the app started but there is no logs on database connection, we need to confirm the Saving file /package.json
Saving file /app.js
Saving file /config/db.js
Saving file /models/News.js

Dev step 19

{"thoughts": "The existing MongoDB connection seems to be failing. The timeouts and deprecation warnings suggest an issue with the connection method or the provided MongoDB URI. There also could be network or firewall issue preventing the connection to MongoDB.", "reasoning": "Looking at the initial output and warnings, it seems to be related to the MongoDB URI or the connection settings. Both warnings are related to deprecated configurations so we should adjust the connection configuration to be compatible with MongoDB 4.0+.", "stSaving file /package.json
Saving file /app.js
Saving file /config/db.js
Saving file /models/News.js

Dev step 20

{"thoughts": "Looking at the error, it seems that there are deprecation warnings for the `useNewUrlParser` and `useUnifiedTopology` flags. We also don't see the 'Connected to the Database :: MongoDB' message which means MongoDB may not be running or there's an issue with connection settings.", "reasoning": "We need to ensure MongoDB is running and connected to successfully start the application. Additionally, because `useNewUrlParser` and `useUnifiedTopology` options are deprecated, we need to update the MongoDB connection options in our code accordingly.", "steps": [{"type": "command", "command": {"command": "service mongod start", "timeout": 3000, "success_message": "Starting MongoDB"}, "need_to_see_output": true, "check_if_fixed": false}, {"type": "code_change", "code_change_description": "Change the MongoDB connection code in the '/config/db.js' file to be `await mongoose.connect(MONGOURI);`. This will establish a basic connection without the deprecated options.", "check_if_fixed": false}, {"type": "command", "command": {"command": "node app.js", "timeout": 10000, "success_message": "Connected to the Database :: MongoDB"}, "check_if_fixed": true}]}


--------- EXECUTE COMMAND ----------
Can I execute the command: `service mongod start` with 3000ms timeout?
? If yes, just press ENTER 


answer: 
Saving file /package.json
Saving file /app.js
Saving file /config/db.js
Saving file /models/News.js

Dev step 21

{"thoughts": "The node server takes a long time to finish indicating that it is waiting for some resource. As we are trying to connect to mongodb at the startup, it indicates that it might not be able to establish a successful connection to mongodb.", "reasoning": "The deprecated warnings are due to outdated mongoose connection settings. However, it should not affect the connection itself. There might be issues with the MongoDB instance (like it's not running or misconfigured). Hence started MongoDB service and checked the connection.", "steps": [{"type": "command", "command": {"command": "service mongod start", "timeout": 3000, "success_message": "Starting MongoDB"}, "need_to_see_output": true, "check_if_fixed": false}, {"type": "command", "command": {"command": "mongo --eval 'db.runCommand({ connectionStatus: 1 })'", "timeout": 3000, "success_message": "'ok' : 1"}, "need_to_see_output": true, "check_if_fixed": false}, {"type": "code_change", "code_change_description": "In the '/config/db.js' file, Change the 'mongoose.connect' part of the code to `await moSaving file /package.json
Saving file /app.js
Saving file /package.json
Saving file /app.js
Saving file /config/db.js
Saving file /models/News.js

Dev step 23
Saving file /package.json
Saving file /app.js
Saving file /config/db.js
Saving file /models/News.js

Dev step 24

{"files": [{"name": "db.js", "path": "/config/db.js", "content": "const mongoose = require('mongoose');\n\nconst MONGOURI = \"mongodb://localhost:27017/github_news_db\";\n\nconst InitiateMongoServer = async () => {\n  try {\n    await mongoose.connect(MONGOURI);\n    console.log(\"Connected to the Database :: MongoDB\");\n  } catch (e) {\n    console.log(e);\n    throw e;\n  }\n};\n\nmodule.exports = InitiateMongoServer;"}]}

Updated file /srv/workspace/gpt-pilot/workspace/GitHub_News/config/db.js
{"type": "command", "command": {"command": "node app.js", "timeout": 10000, "success_message": "Connected to the Database :: MongoDB"}}

 

중간에 에러가 발생하면, 자기가 스스로 그 에러를 해결하기 위해서 또 뭔가를 계속 한다.

 

▶ Quota

계속 이렇게 저렇게 하면서 놀다 보니, 다음과 같은 에러 메시지가 나왔다.

 

...

There was a problem with request to openai API:
API responded with status code: 429. Response text: {
    "error": {
        "message": "You exceeded your current quota, please check your plan and billing details.",
        "type": "insufficient_quota",
        "param": null,
        "code": "insufficient_quota"
    }
}

? Do you want to try make the same request again? If yes, just press ENTER. Otherwise, type 'no'. no


Saving file /package.json
Saving file /app.js
Saving file /config/db.js
Saving file /models/News.js
---------- GPT PILOT EXITING WITH ERROR ----------
Traceback (most recent call last):
  File "/srv/workspace/gpt-pilot/pilot/main.py", line 71, in 
    project.start()
  File "/srv/workspace/gpt-pilot/pilot/helpers/Project.py", line 138, in start
    self.developer.start_coding()
  File "/srv/workspace/gpt-pilot/pilot/helpers/agents/Developer.py", line 52, in start_coding
    self.implement_task(i, dev_task)
  File "/srv/workspace/gpt-pilot/pilot/helpers/agents/Developer.py", line 98, in implement_task
    result = self.execute_task(convo_dev_task,
  File "/srv/workspace/gpt-pilot/pilot/helpers/agents/Developer.py", line 339, in execute_task
    result = self.step_command_run(convo, step, i, success_with_cli_response=need_to_see_output)
  File "/srv/workspace/gpt-pilot/pilot/helpers/agents/Developer.py", line 157, in step_command_run
    return run_command_until_success(convo, data['command'],
  File "/srv/workspace/gpt-pilot/pilot/helpers/cli.py", line 480, in run_command_until_success
    success = convo.agent.debugger.debug(convo, {
  File "/srv/workspace/gpt-pilot/pilot/helpers/Debugger.py", line 63, in debug
    result = self.agent.project.developer.execute_task(
  File "/srv/workspace/gpt-pilot/pilot/helpers/agents/Developer.py", line 344, in execute_task
    result = self.step_code_change(convo, step, i, test_after_code_changes)
  File "/srv/workspace/gpt-pilot/pilot/helpers/agents/Developer.py", line 130, in step_code_change
    return self.test_code_changes(code_monkey, updated_convo)
  File "/srv/workspace/gpt-pilot/pilot/helpers/agents/Developer.py", line 551, in test_code_changes
    llm_response = convo.send_message('development/task/step_check.prompt', {}, GET_TEST_TYPE)
  File "/srv/workspace/gpt-pilot/pilot/helpers/AgentConvo.py", line 99, in send_message
    raise Exception("OpenAI API error happened.")
Exception: OpenAI API error happened.
--------------------------------------------------
? We would appreciate if you let us store your initial app prompt. If you are OK with that, please just press ENTER 

 

이런 !!! 돈이다 !!!

- https://platform.openai.com/usage

Usage

 

API는 돈이다 !!! ㅠㅠ

중간에 쓸데 없이 이것 저것 하다보니..... 돈이다 !!!!

 

 

음... 완제품까지 달려보지는 못했지만, 적당히 잘 가지고 놀아본 것 같다.

 

Copilot Chat 또는 ChatGPT를 이용해서 대화 형식으로 코딩을 해볼 수는 있지만,

그 느낌과는 확실히 다르다는 것은 알 수 있었다.

AutoGPT와 같은 느낌이었는데, 그것보다는 조금 더 고급스러운(진화한) 느낌이다.

 

다만, 필요한 패키지들을 설치한다던지 MongoDB 같은 것을 설치한다던지 해주는 것은 좋았지만

버전간의 호환성이나 deprecated 된 함수들을 사용한다거나 하는 등의 문제는 좀 있는 것 같다.

 

자기 스스로 그런 에러들을 해결하는 방법을 찾아서 해결해나가는 과정이 있기는 하지만

그러기 위해서 API call을 남발하는 모습을 보면 !!! ㅠㅠ

 

그런데, 한 step 씩 뭔가 만들어 나가는 과정을 지켜보면 AI Developer가 멀지 않은 것 같다.

다행인 것은 아직은 AI Assistant 수준을 벗어나지 못한 것 같다는.... ^^

 

아~ 내 돈 !!!!

반응형

kubeflow를 급히 써봐야 할 일이 있어서 minikube 환경에서 설치를 해보려고 했는데...

 

주위에 계신 어떤 한 분이 손쉽게 성공하셨다고 하셔서 나도 그렇게 될거라 믿고 해봤는데,

뭔가의 이유로 잘 진행이 되지 않아서 짜증이 솓구쳐서 결국은 Kubernetes 환경에서 진행했다.

 

 

이하 포스팅은 설치 가이드라기 보다는

Kubeflow 설치 성공한 과정에 대한 기록이다.

 

 

0. Kubernetes

- 다음 링크의 포스트와 동일한 방법으로 설치된 환경이다.

  . https://www.whatwant.com/entry/Kubernetes-Install-1

 

단, 이 때 Kubernetes를 설치한 3대 VM의 Spec은 좀 높여야 한다.

Memory가 부족하면 Kubeflow 설치가 안된다.

memory

 

Processor도 좀 더 잡아주는 것이 좋다.

CPU

 

처음에 4GB memory, 2 core 환경에서 Kubeflow 설치를 진행했을 때 제대로 진행이 안되었다.

 

일부 Pod가 pending 상태에 있길래 살펴봤었는데

자기가 실행될 여유 memory가 있는 worker node가 없어서 였다.

 

테스트가 쉽지 않아서 세부 Spec 조정까지는 못해봤고

8GB memory, 4 core 환경으로 했을 때 성공을 했다.

 

 

1. Kubeflow & Kubernetes version

 

현재 설치되어있는 Kubernetes version은 다음과 같다.

- Kubernetes v1.25.6

kubectl get nodes

 

현재 Kubeflow 최신 Version은 v1.7이다.

https://www.kubeflow.org/docs/releases/kubeflow-1.7/

Kubeflow v1.7

 

다행히 Kubernetes v1.25와 궁합이 잘 맞는다 !!!

 

 

2. How to install Kubeflow

뒤늦게 Kubeflow를 살펴본다 ^^

- https://www.kubeflow.org/

https://www.kubeflow.org/

 

공식 가이드에서 알려주는 설치법에는 어떤 것이 있을까?

How to install

 

① Use a packaged distribution

주로 Cloud 업체에서 maintain 하면서 제공되는 배포판들이다. 즉, 나에겐 쓸모없는....^^

Active Distributions

 

② Use the raw manifests

advanced user를 위한 설치 방법이란다 ^^

Raw Kubeflow Manifests

 

manifests는 GitHub를 통해 배포되고 있다.

- https://github.com/kubeflow/manifests#installation

https://github.com/kubeflow/manifests#installation

 

우리는 이제 manifests를 이용한 Kubeflow 설치를 진행할 것이다.

 

 

3. Prerequisites

앞에서 살펴봤듯이 3개의 사전 준비 항목이 있다.

 

① Kubernetes (up to 1.26) with a default StorageClass

- Kubernetes v1.25에서도 잘 된다 ^^

- 여기서 무심히 넘기면 안되는 항목이 default StorageClass 이다. 뒤에서 깊게 살펴보겠다!

 

② kustomize 5.0.3

Kubernetes native configuration management

최근에는 kubectl 내부에 포함되어 있다고 하는데, manifests를 사용하기 위해서는 별도로 설치를 해줘야 한다.

- https://kubectl.docs.kubernetes.io/installation/kustomize/binaries/

https://kubectl.docs.kubernetes.io/installation/kustomize/binaries/

 

❯ curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"  | bash

❯ sudo install -o root -g root -m 0755 kustomize /usr/local/bin/kustomize

 

가이드에서 요구한 버전은 v5.0.3 이지만, 설치된 버전은 v5.1.1이다.

잘된다 ^^

 

③ kubectl

kubernetes 버전과 동일한 버전의 kubectl을 사용하는 것이 좋다.

Kubernetes node가 아닌 다른 workspace에서 kubectl을 사용하기 위해서는 직접 설치를 해줘야 한다.

 

❯ curl -LO "https://dl.k8s.io/release/v1.25.6/bin/linux/amd64/kubectl"

❯ sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl

 

kubectl을 새로 설치했다면, 자동완성 설정을 해주는 것이 편리하다.

zsh을 사용하는 경우 아래와 같은 명령어를 사용하거나, ~/zshrc에 넣어주면 좋다.

 

 source <(kubectl completion zsh)

 

~/.zshrc 파일에서 plugin에도 추가로 넣어주면 더 좋다.

 

plugins=(kubectl kube-ps1 git zsh-syntax-highlighting zsh-autosuggestions)

 

접근 권한을 얻기 위한 인증 정보(config) 파일을 얻어오는 부분은 여기에서는 생략하겠다.

 

 

4. StorageClass

Kubeflow 설치 관련한 많은 포스팅에서 잘 언급해주지 않는 부분이 바로 이 부분이다.

 

Kubeflow 설치 과정에서 약 4개의 PV(PersistentVolume) 생성을 하게 된다.

- 10Gi 용량의 PV 2개

- 20Gi 용량의 PV 2개

 

60Gi 이상의 PV를 생성할 수 있는 환경이어야 하는 것이다.

 

처음에 간단히 설치한다고 낮은 Spec의 환경에서 설치 진행하면, 이런 부분 때문에 어려움을 겪게 된다.

나도 마찬가지였다. Worer Node의 Disk 용량을 충분히 잡아놓지 않았기 때문이다.

 

그래서, NFS를 이용해서 StorageClass 설정을 진행하기로 했다.

 

① NFS Server 설치

NFS Server를 만드는 방법은 다음 포스팅을 참고하기 바란다.

- https://www.whatwant.com/entry/NFS-Server-Ubuntu-1804

 

② NFS Provisioner

Kubernetes에서 NFS를 사용하기 위한 Provisioner를 설치하자.

- https://github.com/kubernetes-sigs/nfs-subdir-external-provisioner

 

Helm을 이용하려고 하는데, 혹시 Helm이 설치 안되어 있다면 다음과 같이 진행하면 된다.

- https://github.com/helm/helm/releases

 

❯ wget https://get.helm.sh/helm-v3.12.3-linux-amd64.tar.gz

tar zxvf helm-v3.12.3-linux-amd64.tar.gz

sudo install -o root -g root -m 0755 helm /usr/local/bin/helm

 

NFS Provisioner 설치는 다음과 같이 하면 된다.

 

❯ helm repo add nfs-subdir-external-provisioner https://kubernetes-sigs.github.io/nfs-subdir-external-provisioner/

❯ helm install nfs-subdir-external-provisioner nfs-subdir-external-provisioner/nfs-subdir-external-provisioner \                 
    --set nfs.server=192.168.100.153 \
    --set nfs.path=/srv/nfs

❯ kubectl patch storageclass nfs-client -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'

 

잘 되는지 테스트를 해보면 다음과 같다.

 

 kubectl create -f https://raw.githubusercontent.com/kubernetes-sigs/nfs-subdir-external-provisioner/master/deploy/test-claim.yaml -f https://raw.githubusercontent.com/kubernetes-sigs/nfs-subdir-external-provisioner/master/deploy/test-pod.yaml

❯ kubectl delete -f https://raw.githubusercontent.com/kubernetes-sigs/nfs-subdir-external-provisioner/master/deploy/test-claim.yaml -f https://raw.githubusercontent.com/kubernetes-sigs/nfs-subdir-external-provisioner/master/deploy/test-pod.yaml

 

NFS 서버에 생성된 디렉토리와 SUCCESS 파일이 확인되면 된다.

필요 없어진 디렉토리/파일 삭제는, 직접 수작업으로 NFS Server에서 진행하면 된다.

 

 

5. kubeflow install

이제 준비는 끝났다. manifest를 이용한 설치를 진행해보자.

- https://github.com/kubeflow/manifests#install-with-a-single-command

https://github.com/kubeflow/manifests#installation

 

Kubeflow 실제 설치는 정말 쉽다.

kubeflow install

 

❯ git clone https://github.com/kubeflow/manifests.git 

❯ cd manifests   

❯ while ! kustomize build example | kubectl apply -f -; do echo "Retrying to apply resources"; sleep 10; done

 

끝!

 

이제 기다리면 된다. 시간이 좀 걸린다.

k9s

 

모든 Pod가 Running이면 된 것이다.

 

 

6. Service

웹 접근을 위해서는 현재 ClusterIP로 설정되어 있는 서비스를 NodePort 또는 LoadBalancer로 변경해주는 것이 좋다.

ClusterIP

 

설정을 변경해보자.

 

> kubectl edit service istio-ingressgateway -n istio-system

 

type 부분을 수정하고 저장하면 된다.

NodePort

 

다시 확인해보자.

NodePort

 

이제 웹브라우저로 접근하면 된다. (IP는 각자 상황에 맞게, 포트는 위와 같이 확인되는대로)

- http://192.168.100.150:31537/

login

 

기본 계정 정보는 다음과 같다.

- Email: user@example.com

- Password: 1234123 

 

kubeflow

 

수고 많으셨습니다!!!

반응형

ChatGPT가 정말 범지구적인 인기를 얻고있다.

최근에 그 성장세가 주춤해졌다고 뉴스에서 떠들지만, 그래도 여전히 대단한 인기이다.

 

인기를 얻으면 뭐가 따라올까!?

당연히 Anti가 따라온다.

 

그리고, 일종의 sacarsm(빈정댐, 비꼼)도 등장한다.

https://bratgpt.com/

 

뭔가 깔끔하게 잘 만들어진 인터페이스가 먼저 눈에 들어온다.

그리고, 귀찮게 로그인하지 않아도 사용할 수 있다.

오른쪽 위의 X를 누르자.

https://bratgpt.com/

 

"ChatGPT를 따라했네!?"라며 그냥 넘어가지 말고

그 안의 내용물을 좀 살펴보면... 저절로 웃음이 나올 것이다.

 

AI apocalypse ?????? ㅋㅋㅋ

https://bratgpt.com/

 

한글 질문에 한글 대답도 할 줄 안다.

근데, 말투가 상당히 건방지지 않은가 ?! ㅋㅋㅋ

https://bratgpt.com/

 

저런 X가지 없는 말만 하는 것은 아니다.

가끔 말을 듣기도 하고, 실제로 코드를 생성해주기도 한다.

다만, 그다지 긴 대답을 하지는 못해서 큰 기대를 하면 안된다.

 

 

 

BratGPT는 BratAI에서 만들었다고 한다.

https://newsletter.bratai.com/p/bratgpt-unleashing-comical-sassy-powers-ai

 

그런데, 별 내용은 없다.

https://newsletter.bratai.com/

 

애초에 뭘 얻고자 이런 사이트를 운영하고자 하는 것인지는 모르겠지만,

AI 윤리를 생각해보면.... 음... 뭔가 생각해볼 꺼리가 있을 것 같다.

 

ChatGPT를 생각해보면 많은 이슈거리들이 뉴스를 장식하고 있다.

차별적인 발언을 해도 문제고, 가치 판단을 해도 문제고 ... 도덕적으로 완전무결.... 거의 순결해야 한다고 강요하고 있다.

 

과연 이것이 맞는 것일까?!

 

뭐 그냥 그렇다고.... ^^

반응형

아이폰의 등장과 같은, 아니 그보다 더한 파급력을 보여주고 있는 ChatGPT !!!!

 

일부 사람만 사용할 수 있는 어려운 interface가 아니라 누구나 사용할 수 있으며

IT 분야에 제한되지 않는 모든 분야는 물론 일상적인 용도로도 사용할 수 있는

즉, 대중성을 갖고 있기에 이런 어머어마한 인기를 얻는 것이 아닌가 생각된다.

 

모든 사람을 똑똑하게 만들어 줄 수 있는 훌륭한 도구 - ChatGPT !!!

 

이런 ChatGPT의 활용도를 높여주는 많은 서비스들이 우후죽순 쏟아지고 있는데

그 중에서 논문 살펴볼 때 많은 도움을 주는 훌륭한 아이가 있어서 소개하고자 한다.

 

https://www.chatpdf.com/

 

chatpdf.com

 

PDF 문서를 입력으로 주고

그에 대해서 여러가지 질문을 던지거나 요청을 하면 ChatGPT를 이용해 답변을 해주는 서비스다.

 

가격 정책은 다음과 같다.

 

Pricing

 

그리고 로그인 하지 않아도 기본적인 사용은 가능하지만

나의 Chat 내역 기록이 필요하면 로그인 해주는 것이 좋다.

 

login

 

으음?! fIrebase로 구현을 했네!? ^^

다시 한 번 말하지만, 굳이 필요 없다면 로그인 없이도 사용할 수 있다.

 

 

그러면, 일단 오늘 살펴볼 논문을 검색해볼까!?

 

https://paperswithcode.com/

 

https://paperswithcode.com/

 

살펴볼 논문의 Paper 버튼을 통해 다운로드를 받던지

아니면 파일의 경로를 복사하던지 하면 된다.

 

Paper

 

그런 다음 ChatPDF에 파일을 등록하던지 아니면 경로를 입력하면 된다.

 

Drop PDF

 

그러면, 추천하는 질문들도 알려준다.

 

Example questions

 

그 질문 그대로 입력하면 당연히 잘 대답해준다.

 

 

혹시 한글로 물어봐도 대답 잘 해주려나?

 

 

질문은 이해하는데, 답은 영어로 하네?!

뭔가 좀 아쉬운데...

 

 

어!? 된다!!!!

조금 아쉬운데...

 

 

논문 공부하기에 정말 훌륭하지 않은가!?

설명만으로 그치지 않고, 궁금한 것에 대해서 물어볼 수도 있다는 점이 대단하다!!!

 

 

PDF를 업로드 한다고 하면 보안에 대해서는 잘 되어있을까!?

 

FAQ

 

뭐 나름 보안에 신경쓰는 것 같기는 하지만

회사 업무 문서를 업로드해서 사용하는 것에는 절대 권장할 수 없을 것 같다.

 

제목에도 쓴 것 처럼

공부를 위해 논문들을 살펴보는 용도 정도로 사용하기를 권장 드린다.

 

 

아! 그리고 아직은 GPT 3.5 기반이다.

GPT 4.0을 연결하는 것에 대해서는 계속 노력하고 있다고 한다.

반응형

ChatGPT의 인기에 힘입어

이제는 AI/ML을 공부하지 않는 분들도 누구나 알고 있다는 트랜스포머(Transformer)

 

너무나 훌륭한 공부 자료들이 많기에

여기에서는 그 자료들을 알아보도록 하겠다.

 

 

1. Paper

- "Attention Is All You Need"

  . https://arxiv.org/abs/1706.03762#

- 2017년도에 Ashish Vaswani 외 7명이 작성한 15 pages, 5 figures 구성된 논문

  . 논문에 포함된 그림의 수준이 정말 '역시 구글'이다.

 

model architecture

 

 

2. Review

- [딥러닝 기계 번역] Transformer: Attention Is All You Need (꼼꼼한 딥러닝 논문 리뷰와 코드 실습)
  . https://www.youtube.com/watch?v=AA621UofTUA 

  . 구독자가 16만명이 넘는 "동빈나"님의 멋진 리뷰

 

- Transformer 외에도 나동빈님의 많은 리뷰들이 담겨있다.

  . https://github.com/ndb796/Deep-Learning-Paper-Review-and-Practice#natural-language-processing-자연어-처리

 

 

동빈나 - Transformer 리뷰

 

- Code Practice

  . https://github.com/ndb796/Deep-Learning-Paper-Review-and-Practice/blob/master/code_practices/Attention_is_All_You_Need_Tutorial_(German_English).ipynb 

  . 위 링크에서 "Open in Colab"을 선택하면 Colab을 통해서 실행해볼 수 있다.

  . "Drive로 복사" 선택

Colab

 

  . 오래 전에 만들어진 코드이다 보니 지금 실행하면 맞지 않는 부분이 있으니 아래와 같이 수정하자.

import spacy

# spacy_en = spacy.load('en') # 영어 토큰화(tokenization)
# spacy_de = spacy.load('de') # 독일어 토큰화(tokenization)

spacy_en = spacy.load('en_core_web_sm')
spacy_de = spacy.load('de_core_news_sm')

 

 

3. More Detail

- 트랜스포머(Transformer) 심층 분석

  . https://wandb.ai/wandb_fc/korean/reports/-Transformer---Vmlldzo0MDIyNDc
  . 아래와 같이 몇 몇 부분에 대한 개선 방안을 엿볼 수 있다.

 

 

sample

 

- Transformer Positional Encoding

  . https://hongl.tistory.com/231

  . Positional Encoding에서 사용되는 sin/cos 함수에 대한 고찰

 

Transformer Positional Encoding

 

- Tensorflow 공식 가이드

  . https://www.tensorflow.org/text/tutorials/transformer?hl=ko

 

tensorflow

 

  . Colanb에서 실행을 선택하면 아래와 같이 예쁘게 표현된 encoder-decoder 애니메이션을 볼 수 있다.

 

encoder-decoder

 

 

4. Visualize

- Jay Alammar: The Illustrated Transformer

  . https://jalammar.github.io/illustrated-transformer/

 

The Illustrated Transformer

 

 

5. Extra

- Hugging Face

  . https://huggingface.co/

  . 자연어 처리를 공부/활용하는 분이라면 누구나 아는 그 곳

 

Hugging Face

 

- Transformers (신경망 언어모델 라이브러리) 강좌

  . https://wikidocs.net/book/8056

  . Hugging Face 사용법을 배울 수 있는 너무나 좋은 교재

 

Transformer 강좌

 

- Transformers.js

  . 트랜스포머를 브라우저에서 실행할 수 있도록 해주는 JS

  . https://xenova.github.io/transformers.js/

  . BERT, ALBERT, DistilBERT, T5, T5v1.1, FLAN-T5, GPT2, BART, CodeGen, Whispe 등 지원

 

Transformer.js

 

여기까지~

반응형

+ Recent posts