Skip to content

Commit

Permalink
Move TyDi QA demo to its own directory.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 588490476
  • Loading branch information
RyanMullins authored and LIT team committed Dec 6, 2023
1 parent ac8ed59 commit 724bdee
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 41 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ docs/documentation/.doctrees/**

**/.DS_Store
.dalle-venv/
.tydi-venv/
.venv/
.vscode/
4 changes: 2 additions & 2 deletions lit_nlp/examples/dalle/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ LIT repo.
python -m venv .dalle-venv
source .dalle-venv/bin/activate
# This requirements.txt file will also install the core LIT library deps.
pip install -r ./lit_nlp/examples/dalle-mini/requirements.txt
# The LIT web app can still needs be built in the usual way.
pip install -r ./lit_nlp/examples/dalle/requirements.txt
# The LIT web app still needs to be built in the usual way.
(cd ./lit_nlp && yarn && yarn build)
```

Expand Down
3 changes: 1 addition & 2 deletions lit_nlp/examples/dalle/demo.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
r"""Example for dalle demo model.
To run locally with a small number of examples:
python -m lit_nlp.examples.dalle_demo \
--alsologtostderr --port=5432
python -m lit_nlp.examples.dalle.demo
Then navigate to localhost:5432 to access the demo UI.
"""
Expand Down
30 changes: 0 additions & 30 deletions lit_nlp/examples/models/tydi_test.py

This file was deleted.

26 changes: 26 additions & 0 deletions lit_nlp/examples/tydi/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
TyDi QA Demo for the Learning Interpretability Tool
=======================================================

This demo showcases how LIT can be used to a multilingual question-answering
model trained on the [TyDi QA dataset](https://doi.org/10.1162/tacl_a_00317)
using FLAX.

You will need a stand-alone virtual environment for the Python libraries, which you can set up using the following commands from the root of the LIT repo.

```sh
# Create the virtual environment. You may want to use python3 or python3.10
# depends on how many Python versions you have installed and their aliases.
python -m venv .tydi-venv
source .tydi-venv/bin/activate
# This requirements.txt file will also install the core LIT library deps.
pip install -r ./lit_nlp/examples/tydi/requirements.txt
# The LIT web app still needs to be built in the usual way.
(cd ./lit_nlp && yarn && yarn build)
```

Once your virtual environment is setup, you can launch the demo with the
following command.

```sh
python -m lit_nlp.examples.tydi.demo
```
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
r"""Example demo loading a TyDiModel.
To run locally with a small number of examples:
python -m lit_nlp.examples.tydi_demo \
--alsologtostderr --port=5432 --max_examples=10
python -m lit_nlp.examples.tydi.demo
Then navigate to localhost:5432 to access the demo UI.
"""
Expand All @@ -18,7 +17,7 @@
from lit_nlp import server_flags
from lit_nlp.components import word_replacer
from lit_nlp.examples.datasets import question_answering
from lit_nlp.examples.models import tydi
from lit_nlp.examples.tydi import model

# NOTE: additional flags defined in server_flags.py
_FLAGS = flags.FLAGS
Expand Down Expand Up @@ -56,7 +55,7 @@ def main(argv: Sequence[str]) -> Optional[dev_server.LitServerType]:
# Ignore path prefix, if using /path/to/<model_name> to load from a
# specific directory rather than the default shortcut.
model_name = os.path.basename(model_name_or_path)
models[model_name] = tydi.TyDiModel(model_name=model_name_or_path)
models[model_name] = model.TyDiModel(model_name=model_name_or_path)

max_examples: int = _MAX_EXAMPLES.value
dataset_defs: tuple[tuple[str, str]] = (
Expand Down
File renamed without changes.
20 changes: 20 additions & 0 deletions lit_nlp/examples/tydi/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================

-r ../../../requirements_core.txt

jax==0.3.16
jaxlib==0.3.15
flax==0.5.3
3 changes: 0 additions & 3 deletions requirements_examples.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,4 @@ sentencepiece==0.1.99
tensorflow-datasets==4.8.0
torch==2.0.1
transformers==4.27.1
jax==0.4.13
jaxlib==0.4.13
flax==0.6.11
# LINT.ThenChange(./pyproject.toml)

0 comments on commit 724bdee

Please sign in to comment.