Google Research has open sourced the Language Interpretability Tool (LIT) platform for understanding and visualizing NLP models. I would like to try it out.
All 3 articles are planned. ** 1. Execute Language Interpretability Tool (LIT) in Windows 10 environment (1. Environment construction) [This article] ** 2. Execute Language Interpretability Tool (LIT) in Windows 10 environment (2. Function check) 3. Run Language Interpretability Tool (LIT) in Windows 10 environment (3. Original model)
In this article, we will describe the ** environment construction procedure ** in the ** Windows 10 Home environment **.
The Language Interpretability Tool (LIT) is a tool for understanding and visualizing NLP models.
The browser-based UI has the following features: (Excerpt from the paper)
If you want to know more details, please refer to the following.
--The paper is here --GitHub is here --Click here for user guide (https://github.com/PAIR-code/lit/blob/main/docs/user_guide.md)
I feel like I can't say anything unless I touch this kind of tool system, so I decided to try it out.
This time, in order to set up a server using Docker, install ** Docker Desktop for Windows ** in ** Windows 10 Home environment **.
When I tried to install Docker Desktop for Windows, I got the following error in my environment.
Docker Desktop requires Windows 10 Pro/Enterprise (15063+) or Windows 10 Home (19018+).
It looks like ** Windows needs to be updated ** before installation.
Follow the steps below to update Windows 10 Home. ** Windows Start Menu → Settings → Run Update from Windows Update ** It didn't end even after waiting for about an hour, but it ended when I slept and woke up.
When I saw it in the morning, it was safely upgraded to the following version.
I will actually install it. Click ** Download for Windows (stable) ** from the URL below to download the installer. https://www.docker.com/products/docker-desktop
When I double-clicked on the installer and followed the steps, I ran into the following error: It looks like ** I need to update the Linux kernel **. Click the link as instructed.
You will be taken to the MS documentation, so ** download the Linux kernel update package **.
Run the downloaded ** wsl_update_x64.msi **. It ends in an instant.
After that, go back to the procedure and finish all the steps ** Docker Desktop for Windows installation is finished **.
Articles of people who hit a similar error https://tech.guitarrapc.com/entry/2020/04/21/034236
Difference between "Docker Toolbox" and "Docker Desktop for Windows" https://fumidzuki.com/knowledge/1033/
Finally, by executing the sample program ** quickstart_sst_demo.py **, set up a server on Docker and set up a server. You will see it in your browser from the host side.
In LIT README, the environment is created with conda, so Prepare the virtual environment and then configure the settings so that the host can access the server.
Before you start preparing the virtual environment, make a ** change the memory allocation of WSL2 **. If you don't do this, by default ** 80% of your PC's memory will be allocated **, and in my case it's a 16GB PC, so about 13GB of memory will be allocated.
The procedure is simple: create a **. Wslconfig ** file in **% UserProfile% ** on the host side and specify the memory allocation. 3GB was enough to run the demo.
~/.wslconfig
[wsl2]
memory=3GB
** Pull and launch the Docker container containing Anaconda. ** ** From the command line: (The container name ** lit_env ** can be changed arbitrarily.) Reference: https://hub.docker.com/r/continuumio/anaconda3
docker pull continuumio/anaconda3
docker run -it --name lit_env continuumio/anaconda3 /bin/bash
When you start the Docker container, the default virtual environment name ** base is activated **.
Next, ** install the required packages **. Basically, proceed according to the README procedure, but if it is left as it is, an error will occur, so I have changed it a little. Reference: https://github.com/pair-code/lit/issues Reference: https://github.com/yarnpkg/yarn/issues/7329
git clone https://github.com/PAIR-code/lit.git ~/lit
# Set up Python environment
cd ~/lit
conda env create -f environment.yml
conda activate lit-nlp
conda install cudnn cupti # optional, for GPU support
conda install -c pytorch pytorch # optional, for PyTorch
# Build the frontend
cd ~/lit/lit_nlp/client
######I don't have yarn so I will install it
#Simply"apt-get install yarn"If so, an error will occur after that, so execute the following
curl https://deb.nodesource.com/setup_12.x | bash
curl https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
apt-get update && apt-get install -y nodejs yarn postgresql-client
######
yarn && yarn build
The installation of the package etc. is completed, and the preparation of the virtual environment is completed.
All I have to do is hit the sample program, With the sample as it is **, I started a server to listen on localhost of Docker container, Since it cannot be accessed from the host **, rewrite the sample program so that the server is set up on ** 0.0.0.0. ** **
First, ** install vim **.
apt-get install vim
Run the following command to open the ** server_flags.py ** file. (If necessary, make a backup before editing.)
vi /root/lit/lit_nlp/server_flags.py
Rewrite the following part and save.
#flags.DEFINE_string('host', '127.0.0.1', 'What host address to serve on.')
flags.DEFINE_string('host', '0.0.0.0', 'What host address to serve on.')
Later, I will put in the port forwarding option and hit the ** docker run ** command, so I will save the container as an image. First, exit.
exit
Run the ** docker commit ** command and save the container named ** lit_env ** as an image. (It is saved as ** lit_env_img **, but the name is of course arbitrary.)
docker commit lit_env lit_env_img
If you follow the LIT README, you will later launch the server with **-port5432 **. .. So, execute the ** docker run ** command with the port forwarding option specified as ** port on the container side as 5432 **. (Of course, the port number on the host side is arbitrary.)
docker run -it -p 5432:5432 lit_env_img /bin/bash
Run a demo of the emotion classification task, which is a sample program. It seems that it is fine tuning about 3 epoch.
conda activate lit-nlp
cd ~/lit
python -m lit_nlp.examples.quickstart_sst_demo --port=5432
It is complete when the following message is output.
Starting Server on port 5432 You can navigate to 0.0.0.0:5432
Access the following URL from the browser on the host side.
http://127.0.0.1:5432/
You should be able to access it normally.
This is the end of the environment construction procedure under the Windows 10 Home environment.
This time I changed various settings to avoid the error. As you can see from the LIT Issue, Since there have been quite a few exchanges in the past week, including the contents, There may be updates in the near future. If that happens, I think it will be easier to build an environment.
Next time, I would like to take a look at various LIT functions!