Skip to content

Commit 724bdee

Browse files
RyanMullinsLIT team
authored andcommitted
Move TyDi QA demo to its own directory.
PiperOrigin-RevId: 588490476
1 parent ac8ed59 commit 724bdee

File tree

9 files changed

+53
-41
lines changed

9 files changed

+53
-41
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@ docs/documentation/.doctrees/**
1515

1616
**/.DS_Store
1717
.dalle-venv/
18+
.tydi-venv/
1819
.venv/
1920
.vscode/

lit_nlp/examples/dalle/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ LIT repo.
2121
python -m venv .dalle-venv
2222
source .dalle-venv/bin/activate
2323
# This requirements.txt file will also install the core LIT library deps.
24-
pip install -r ./lit_nlp/examples/dalle-mini/requirements.txt
25-
# The LIT web app can still needs be built in the usual way.
24+
pip install -r ./lit_nlp/examples/dalle/requirements.txt
25+
# The LIT web app still needs to be built in the usual way.
2626
(cd ./lit_nlp && yarn && yarn build)
2727
```
2828

lit_nlp/examples/dalle/demo.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
r"""Example for dalle demo model.
22
33
To run locally with a small number of examples:
4-
python -m lit_nlp.examples.dalle_demo \
5-
--alsologtostderr --port=5432
4+
python -m lit_nlp.examples.dalle.demo
65
76
Then navigate to localhost:5432 to access the demo UI.
87
"""

lit_nlp/examples/models/tydi_test.py

Lines changed: 0 additions & 30 deletions
This file was deleted.

lit_nlp/examples/tydi/README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
TyDi QA Demo for the Learning Interpretability Tool
2+
=======================================================
3+
4+
This demo showcases how LIT can be used to a multilingual question-answering
5+
model trained on the [TyDi QA dataset](https://doi.org/10.1162/tacl_a_00317)
6+
using FLAX.
7+
8+
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.
9+
10+
```sh
11+
# Create the virtual environment. You may want to use python3 or python3.10
12+
# depends on how many Python versions you have installed and their aliases.
13+
python -m venv .tydi-venv
14+
source .tydi-venv/bin/activate
15+
# This requirements.txt file will also install the core LIT library deps.
16+
pip install -r ./lit_nlp/examples/tydi/requirements.txt
17+
# The LIT web app still needs to be built in the usual way.
18+
(cd ./lit_nlp && yarn && yarn build)
19+
```
20+
21+
Once your virtual environment is setup, you can launch the demo with the
22+
following command.
23+
24+
```sh
25+
python -m lit_nlp.examples.tydi.demo
26+
```
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
r"""Example demo loading a TyDiModel.
22
33
To run locally with a small number of examples:
4-
python -m lit_nlp.examples.tydi_demo \
5-
--alsologtostderr --port=5432 --max_examples=10
4+
python -m lit_nlp.examples.tydi.demo
65
76
Then navigate to localhost:5432 to access the demo UI.
87
"""
@@ -18,7 +17,7 @@
1817
from lit_nlp import server_flags
1918
from lit_nlp.components import word_replacer
2019
from lit_nlp.examples.datasets import question_answering
21-
from lit_nlp.examples.models import tydi
20+
from lit_nlp.examples.tydi import model
2221

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

6160
max_examples: int = _MAX_EXAMPLES.value
6261
dataset_defs: tuple[tuple[str, str]] = (
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Copyright 2023 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
# ==============================================================================
15+
16+
-r ../../../requirements_core.txt
17+
18+
jax==0.3.16
19+
jaxlib==0.3.15
20+
flax==0.5.3

requirements_examples.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,4 @@ sentencepiece==0.1.99
1818
tensorflow-datasets==4.8.0
1919
torch==2.0.1
2020
transformers==4.27.1
21-
jax==0.4.13
22-
jaxlib==0.4.13
23-
flax==0.6.11
2421
# LINT.ThenChange(./pyproject.toml)

0 commit comments

Comments
 (0)