Skip to content

Commit

Permalink
Add LIT kernel
Browse files Browse the repository at this point in the history
  • Loading branch information
takumiohym committed Sep 10, 2024
1 parent 06b3995 commit 8bd7a91
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 10 deletions.
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ kernels: \
object_detection_kernel \
pytorch_kfp_kernel \
langchain_kernel \
langchain_components_kernel
langchain_components_kernel \
lit_kernel

.PHONY: clean
clean:
Expand Down Expand Up @@ -65,6 +66,10 @@ pytorch_kfp_kernel:
gemini_kernel:
./kernels/gemini.sh

.PHONY: lit_kernel
lit_kernel:
./kernels/lit.sh


.PHONY: tests
tests:
Expand Down
33 changes: 33 additions & 0 deletions kernels/lit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash
#
# To build the kernel: ./kernels/lit.sh
# To remove the kernel: ./kernels/lit.sh remove
#
# This scripts will create a ipython kernel named $ENVNAME

ENVNAME=lit_kernel
KERNEL_DISPLAY_NAME="LIT kernel"

source ~/.bashrc

# Cleaning up the kernel and exiting if first arg is 'remove'
if [ "$1" == "remove" ]; then
echo Removing kernel $ENVNAME
jupyter kernelspec remove $ENVNAME
conda env remove -n $ENVNAME -y
exit 0
fi

conda create -n $ENVNAME python=3.10.14 -y
conda activate $ENVNAME

# Install packages using a pip local to the conda environment.
conda install pip
pip install ipykernel
# Adds the conda kernel.
DL_ANACONDA_ENV_HOME="${DL_ANACONDA_HOME}/envs/$ENVNAME"
python -m ipykernel install --prefix "${DL_ANACONDA_ENV_HOME}" --name $ENVNAME --display-name "$KERNEL_DISPLAY_NAME"

pip install tensorflow==2.14.1 lit-nlp keras_nlp

conda deactivate
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,44 @@
"* Customize the Model for interpretability methods"
]
},
{
"cell_type": "markdown",
"id": "09254b64-3602-4f7a-aff9-6d826b8c2b8f",
"metadata": {},
"source": [
"## Setup\n",
"This lab needs a special kernel to run, please run the following cell. "
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "a41b3fcd-f4ea-48bd-8ce7-13e9c4911d62",
"execution_count": null,
"id": "e99c369c-4da9-41d2-8bad-7b65390e5e75",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 1000
},
"id": "a41b3fcd-f4ea-48bd-8ce7-13e9c4911d62",
"outputId": "4e61458c-4496-4c6a-ab4d-2be21840480f",
"tags": []
},
"outputs": [],
"source": [
"# !pip install tensorflow==2.14.1 lit-nlp keras_nlp"
"!cd ../../../.. && make lit_kernel"
]
},
{
"cell_type": "markdown",
"id": "2b9935bc-5274-46cd-baaa-aec3a2d88be5",
"metadata": {},
"source": [
"When it's completed, select the **`LIT Kernel`** on the top right before going forward in the notebook.<br>\n",
"It may take ~1 minutes until the kernel is shown.\n",
"\n",
"<img width=\"700\" alt=\"image\" src=\"https://github.com/user-attachments/assets/1d8dd451-3d97-4c42-89f7-b8b7a93428f7\">\n"
]
},
{
"cell_type": "markdown",
"id": "ed3de7e4-55a0-4eed-a922-4be6a82253f4",
"metadata": {},
"source": [
"### Import libraries\n"
]
},
{
Expand Down

0 comments on commit 8bd7a91

Please sign in to comment.