Skip to content

Commit c778fe1

Browse files
committed
Resolving review comments
1 parent 110c999 commit c778fe1

File tree

6 files changed

+13
-26
lines changed

6 files changed

+13
-26
lines changed

lit_nlp/examples/gcp/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ docker build -f ./lit_nlp/examples/gcp/Dockerfile -t lit-app:gcp-dev .
2727
### Run GPT-2 in a Docker container
2828

2929
```shell
30-
# Runs GPT-2 in Keras on Tensorflow
30+
# Runs GPT-2 in Keras on PyTorch
3131
docker run --rm -p 5432:5432 -e MODEL_CONFIG=gpt2:gpt2_base_en lit-app:gcp-dev
3232
```

lit_nlp/examples/gcp/model.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# limitations under the License.
1414
# ==============================================================================
1515

16-
"""Wrapper for connetecting to LLMs on GCP via the model_server HTTP API."""
16+
"""Wrapper for connecting to LLMs on GCP via the model_server HTTP API."""
1717

1818
from lit_nlp import app as lit_app
1919
from lit_nlp.api import model as lit_model
@@ -24,11 +24,6 @@
2424
from lit_nlp.lib import serialize
2525
import requests
2626

27-
"""
28-
Plan for this module:
29-
30-
"""
31-
3227
_LlmHTTPEndpoints = lit_gcp_constants.LlmHTTPEndpoints
3328

3429
LLM_ON_GCP_INIT_SPEC: lit_types.Spec = {

lit_nlp/examples/gcp/model_server.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,14 @@
1818
from collections.abc import Sequence
1919
import functools
2020
import os
21-
from typing import Optional
2221

2322
from absl import app
24-
from lit_nlp import dev_server
2523
from lit_nlp.examples.gcp import constants as lit_gcp_constants
2624
from lit_nlp.examples.prompt_debugging import models as pd_models
2725
from lit_nlp.examples.prompt_debugging import utils as pd_utils
2826
from lit_nlp.lib import serialize
2927
from lit_nlp.lib import wsgi_app
3028

31-
DEFAULT_DL_FRAMEWORK = 'kerasnlp'
32-
DEFAULT_DL_RUNTIME = 'tensorflow'
33-
DEFAULT_PRECISION = 'bfloat16'
34-
DEFAULT_SEQUENCE_LENGTH = 512
35-
DEFAULT_BATCH_SIZE = 1
3629
DEFAULT_MODELS = 'gemma_1.1_2b_IT:gemma_1.1_instruct_2b_en'
3730

3831
_LlmHTTPEndpoints = lit_gcp_constants.LlmHTTPEndpoints
@@ -59,11 +52,13 @@ def _handler(app: wsgi_app.App, request, unused_environ):
5952
f'Only 1 model configuration can be provided, got {num_configs}'
6053
)
6154

62-
dl_framework = os.getenv('DL_FRAMEWORK', DEFAULT_DL_FRAMEWORK)
63-
dl_runtime = os.getenv('DL_RUNTIME', DEFAULT_DL_RUNTIME)
64-
precision = os.getenv('PRECISION', DEFAULT_PRECISION)
65-
batch_size = int(os.getenv('BATCH_SIZE', DEFAULT_BATCH_SIZE))
66-
sequence_length = int(os.getenv('SEQUENCE_LENGTH', DEFAULT_SEQUENCE_LENGTH))
55+
dl_framework = os.getenv('DL_FRAMEWORK', pd_models.DEFAULT_DL_FRAMEWORK)
56+
dl_runtime = os.getenv('DL_RUNTIME', pd_models.DEFAULT_DL_RUNTIME)
57+
precision = os.getenv('PRECISION', pd_models.DEFAULT_PRECISION)
58+
batch_size = int(os.getenv('BATCH_SIZE', pd_models.DEFAULT_BATCH_SIZE))
59+
sequence_length = int(
60+
os.getenv('SEQUENCE_LENGTH', pd_models.DEFAULT_SEQUENCE_LENGTH)
61+
)
6762

6863
models = pd_models.get_models(
6964
models_config=model_config,
@@ -92,7 +87,8 @@ def _handler(app: wsgi_app.App, request, unused_environ):
9287
wrapped_handlers, project_root='gcp', index_file='index.html'
9388
)
9489

95-
def main(argv: Sequence[str]) -> Optional[dev_server.LitServerType]:
90+
91+
def main(argv: Sequence[str]) -> wsgi_app.App:
9692
if len(argv) > 1:
9793
raise app.UsageError('Too many command-line arguments.')
9894

lit_nlp/examples/gcp/model_server_gunicorn_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@
2222
timeout = 3600
2323
threads = 8
2424
worker_class = 'gthread'
25-
wsgi_app = f'lit_nlp.examples.gcp.model_server:get_wsgi_app()'
25+
wsgi_app = 'lit_nlp.examples.gcp.model_server:get_wsgi_app()'

lit_nlp/examples/gcp/server_gunicorn_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@
2222
timeout = 3600
2323
threads = 8
2424
worker_class = 'gthread'
25-
wsgi_app = f'lit_nlp.examples.gcp.server:get_wsgi_app()'
25+
wsgi_app = 'lit_nlp.examples.gcp.server:get_wsgi_app()'

lit_nlp/examples/gcp/vertexai_models.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,11 @@
2525
from lit_nlp.api import types as lit_types
2626

2727
_MAX_NUM_RETRIES = 5
28-
2928
_DEFAULT_CANDIDATE_COUNT = 1
30-
3129
_DEFAULT_MAX_OUTPUT_TOKENS = 256
32-
3330
_DEFAULT_TEMPERATURE = 0.7
3431

3532

36-
# TODO(fanyecourage): Rename this class.
3733
class GeminiFoundationalModel(lit_model.BatchedRemoteModel):
3834
"""GeminiFoundationalModel is a wrapper for foundatoinal Gemini models in Vertex AI Model Garden model.
3935

0 commit comments

Comments
 (0)