{"id":20786076,"url":"https://github.com/thomassuedbroecker/watson-nlp-example-local-docker","last_synced_at":"2026-04-11T09:01:42.243Z","repository":{"id":127030669,"uuid":"578692476","full_name":"thomassuedbroecker/watson-nlp-example-local-docker","owner":"thomassuedbroecker","description":"This is example how to use Watson NLP based on the official example documentation.","archived":false,"fork":false,"pushed_at":"2023-02-09T15:58:55.000Z","size":110,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-18T09:52:54.070Z","etag":null,"topics":["bash-script","curl","watson-embed","watson-nlp-embed"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thomassuedbroecker.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-15T16:51:45.000Z","updated_at":"2023-01-18T08:23:48.000Z","dependencies_parsed_at":null,"dependency_job_id":"2785a823-ef96-4d81-8232-f78a9bef0b8c","html_url":"https://github.com/thomassuedbroecker/watson-nlp-example-local-docker","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomassuedbroecker%2Fwatson-nlp-example-local-docker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomassuedbroecker%2Fwatson-nlp-example-local-docker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomassuedbroecker%2Fwatson-nlp-example-local-docker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomassuedbroecker%2Fwatson-nlp-example-local-docker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thomassuedbroecker","download_url":"https://codeload.github.com/thomassuedbroecker/watson-nlp-example-local-docker/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243129842,"owners_count":20241074,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bash-script","curl","watson-embed","watson-nlp-embed"],"created_at":"2024-11-17T14:50:37.288Z","updated_at":"2025-12-16T08:35:34.919Z","avatar_url":"https://github.com/thomassuedbroecker.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Run Watson NLP for Embed on your local computer with Docker\n\nThis is an example about, how to use Watson NLP based on the official example documentation:[IBM Watson Libraries for Embed](https://www.ibm.com/docs/en/watson-libraries?topic=watson-natural-language-processing-library-embed-home).\n\n\u003e Visit the related blog post [`Run Watson NLP for Embed on your local computer with Docker`](https://suedbroecker.net/2022/12/15/run-watson-nlp-for-embed-on-your-local-computer-with-docker/).\n\n\n## Pretrained models\n\n* Step 1: Clone the example project to your local computer\n* Step 2: Set your IBM_ENTITLEMENT_KEY in the `.env` file\n* Step 3: Execute the `run-watson-nlp-with-docker.sh` bash script\n* Step 4: Verify running Watson NLP container\n\n### Step 1: Clone the example project to your local computer\n\n```sh\ngit clone https://github.com/thomassuedbroecker/watson-nlp-example-local-docker\ncd watson-nlp-example-local-docker/code\n```\n\n### Step 2:  Set your IBM_ENTITLEMENT_KEY in the `.env` file\n\n```sh\ncat .env_template \u003e .env\n```\n\nEdit the `.env` file.\n\n```sh\n# used as 'environment' variables\nIBMCLOUD_ENTITLEMENT_KEY=\"YOUR_KEY\"\n```\n\n### Step 3: Execute the `run-watson-nlp-with-docker.sh` bash script\n\n```sh\nsh run-watson-nlp-with-docker.sh\n```\n\n* Example output:\n\n```sh\n# ******\n# List model array content\n# ******\n\nModel 0 : watson-nlp_syntax_izumo_lang_en_stock:1.0.7\nModel 1 : watson-nlp_syntax_izumo_lang_fr_stock:1.0.7\n\n# ******\n# If TLS credentials are set up, run with TLS\n# ******\n\nTLS is not configured\n\n# ******\n# Connect to IBM Cloud Container Image Registry: cp.icr.io/cp/ai\n# ******\n\nIBM_ENTITLEMENT_KEY: XXXX\n\nflag needs an argument: --password\n\n# ******\n# Create volume for models\n# ******\n\n# 1. Clear out existing volume\nmodel_data\n# 2. Create a shared volume and initialize with open permissions\n0741b26b357dc5a5fc0c002a6ed9da0cf2373c13e5a4f644b850cdc47bd9b3bc\n# 3. Run a container in an interactive mode to set the permissions\n# 4. Put models into the shared volume\nArchive:  /app/model.zip\n  inflating: config.yml              \nLoad model model: watson-nlp_syntax_izumo_lang_en_stock:1.0.7 0\nArchive:  /app/model.zip\n  inflating: config.yml              \nLoad model model: watson-nlp_syntax_izumo_lang_fr_stock:1.0.7 1\n\n# ******\n# Run NLP\n# ******\n\n# Run the runtime with the models mounted\n\n[STARTING RUNTIME]\n\n....\n\n10001001I\u003e\", \"message\": \"Common Service is running on port: 8085 with thread pool size: 5\", \"num_indent\": 0, \"thread_id\": 140231246393600, \"timestamp\": \"2022-12-15T17:18:13.453967\"}\n[STARTING GATEWAY]\n2022/12/15 17:18:14 Running with INSECURE credentials\n2022/12/15 17:18:14 Serving proxy calls INSECURE\n```\n\n### Step 4: Verify running Watson NLP container\n\nVerify the running Watson NLP container by open a new terminal session and execute an API call.\n\n* Models \n    * **syntax_izumo_lang_en_stock**\n    * **syntax_izumo_lang_fr_stock**\n\n* Text\n    * _This is a test sentence_\n    * _Ceci est une phrase test_\n\n```sh\n curl -s \\\n   \"http://localhost:8080/v1/watson.runtime.nlp.v1/NlpService/SyntaxPredict\" \\\n   -H \"accept: application/json\" \\\n   -H \"content-type: application/json\" \\\n   -H \"grpc-metadata-mm-model-id: syntax_izumo_lang_fr_stock\" \\\n   -d '{ \"raw_document\": { \"text\": \"Ceci est une phrase test\" }, \"parsers\": [\"token\"] }'\n```\n\n* Example output:\n\n```json\n{\"text\":\"This is a test sentence\", \"producerId\":{\"name\":\"Izumo Text Processing\", \"version\":\"0.0.1\"}, \"tokens\":[{\"span\":{\"begin\":0, \"end\":4, \"text\":\"This\"}, \"lemma\":\"\", \"partOfSpeech\":\"POS_UNSET\", \"dependency\":null, \"features\":[]}, {\"span\":{\"begin\":5, \"end\":7, \"text\":\"is\"}, \"lemma\":\"\", \"partOfSpeech\":\"POS_UNSET\", \"dependency\":null, \"features\":[]}, {\"span\":{\"begin\":8, \"end\":9, \"text\":\"a\"}, \"lemma\":\"\", \"partOfSpeech\":\"POS_UNSET\", \"dependency\":null, \"features\":[]}, {\"span\":{\"begin\":10, \"end\":14, \"text\":\"test\"}, \"lemma\":\"\", \"partOfSpeech\":\"POS_UNSET\", \"dependency\":null, \"features\":[]}, {\"span\":{\"begin\":15, \"end\":23, \"text\":\"sentence\"}, \"lemma\":\"\", \"partOfSpeech\":\"POS_UNSET\", \"dependency\":null, \"features\":[]}], \"sentences\":[{\"span\":{\"begin\":0, \"end\":23, \"text\":\"This is a test sentence\"}}], \"paragraphs\":[{\"span\":{\"begin\":0, \"end\":23, \"text\":\"This is a test sentence\"}}]}\n```\n\nWe executed the syntac predict [v1/watson.runtime.nlp.v1/NlpService/SyntaxPredict](https://developer.ibm.com/apis/catalog/embeddableai--watson-natural-language-processing-apis/api/API--embeddableai--watson-natural-language-processing-apis#SyntaxPredict) REST API methode and the `syntax_izumo_lang_en_stock` model.\n\n## Custom model and pretrained models\n\n* Step 1: Step 1: Follow the steps to create a custom classification model\n* Step 2: Clone the example project to your local computer\n* Step 3: Set your IBM_ENTITLEMENT_KEY in the `.env` file\n* Step 4: Copy the created model\n* Step 5: Execute the `run-watson-nlp-with-dockerfile.sh` bash script\n* Step 6: Open a new terminal and insert following `curl` command\n\n### Step 1: Follow the steps to create a custom classification model\n\n\u003e Visit the [Customize a classification model for Watson NLP for Embed](https://github.com/thomassuedbroecker/watson-nlp-custom-model#customize-a-classification-model-for-watson-nlp-for-embed)\n\n### Step 2: Clone the example project to your local computer\n\n```sh\ngit clone https://github.com/thomassuedbroecker/watson-nlp-example-local-docker\ncd watson-nlp-example-local-docker/code\n```\n\n### Step 3: Set your IBM_ENTITLEMENT_KEY in the `.env` file\n\n```sh\ncat .env_template \u003e .env\n```\n\nEdit the `.env` file.\n\n```sh\n# used as 'environment' variables\nIBMCLOUD_ENTITLEMENT_KEY=\"YOUR_KEY\"\n```\n\n### Step 4: Copy the created model\n\nEnsure you copied the your custom model to this folder.\n\n```sh\ncode/app/custom_models\n```\n\n### Step 5: Execute the `run-watson-nlp-with-dockerfile.sh` bash script\n\n```sh\nsh run-watson-nlp-with-dockerfile.sh\n```\n\n* Example output:\n\n```sh\n# ******\n# Connect to IBM Cloud Container Image Registry: cp.icr.io/cp/ai\n# ******\n\nIBM_ENTITLEMENT_KEY: \nXXXX\n\n# ******\n# List pretrained model array content\n# ******\n\n1. Load pretrained model array array\n2. List pretrained models\nModel 0 : watson-nlp_syntax_izumo_lang_en_stock:1.0.7\nModel 1 : watson-nlp_syntax_izumo_lang_fr_stock:1.0.7\n\n# ******\n# Download the pretrained models\n# ******\n\nmkdir: /Users/thomassuedbroecker/Downloads/dev/watson-nlp-example-local-docker/code/models: File exists\n# 1. Run a container in an interactive mode to set the permissions\n# 2. Put models into the file share\nArchive:  /app/model.zip\n...\n\n# ******\n# Create container image\n# Runtime container image: cp.icr.io/cp/ai/watson-nlp-runtime:1.0.20\n# ******\n\nImage name: watson-nlp-runtime-with-custom-models\n[+] Building 19.3s (8/8) FINISHED                                                         \n =\u003e [internal] load build definition from Dockerfile                                 0.0s\n =\u003e =\u003e transferring dockerfile: 203B                                                 0.0s\n =\u003e [internal] load .dockerignore                                                    0.0s\n =\u003e =\u003e transferring context: 2B                                                      0.0s\n =\u003e [internal] load metadata for cp.icr.io/cp/ai/watson-nlp-runtime:1.0.20           0.0s\n =\u003e [1/3] FROM cp.icr.io/cp/ai/watson-nlp-runtime:1.0.20                             0.0s\n =\u003e [internal] load build context                                                   12.4s\n =\u003e =\u003e transferring context: 1.27GB                                                 12.0s\n =\u003e CACHED [2/3] COPY ./app/models /app/models                                       0.0s\n =\u003e [3/3] COPY ./app/custom_models /app/models                                       2.0s\n =\u003e exporting to image                                                               4.8s\n =\u003e =\u003e exporting layers                                                              4.8s\n =\u003e =\u003e writing image sha256:4bb2f8d4cc35bff3f6e38c645d47ae30d53fc024ccb56274b439318  0.0s\n =\u003e =\u003e naming to docker.io/library/watson-nlp-runtime-with-custom-models:1.0.0       0.0s\n\n...\n\n# ******\n# Run NLP with custom model\n# ******\n\n# Run the custom runtime with the custom models mounted\n# Image: cp.icr.io/cp/ai/watson-nlp-runtime\n\n[STARTING RUNTIME]\nWARNING:root:Limited tf.compat.v2.summary API due to missing TensorBoard installation.\n...\n{\"channel\": \"COMMON-SERVR\", \"exception\": null, \"level\": \"info\", \"log_code\": \"\u003cCOM10001001I\u003e\", \"message\": \"Common Service is running on port: 8085 with thread pool size: 5\", \"num_indent\": 0, \"thread_id\": 140369309888768, \"timestamp\": \"2023-01-31T09:22:04.343563\"}\n[STARTING GATEWAY]\n2023/01/31 09:22:05 Running with INSECURE credentials\n2023/01/31 09:22:05 Serving proxy calls INSECURE\n```\n\n### Step 6: Open a new terminal and insert following `curl` command\n\n```sh\ncurl -s -X POST \"http://localhost:8080/v1/watson.runtime.nlp.v1/NlpService/ClassificationPredict\" \\\n  -H \"accept: application/json\" \\\n  -H \"grpc-metadata-mm-model-id: ensemble_model\" \\\n  -H \"content-type: application/json\" \\\n  -d \"{ \\\"rawDocument\\\": \\\n    { \\\"text\\\": \\\"The credit card doesn't work, and I look at the savings, but I need more money to spend.\\\" }}\" | jq\n```\n\n* Example output:\n\n```sh\n{\n  \"classes\": [\n    {\n      \"className\": \"Credit reporting, credit repair services, or other personal consumer reports\",\n      \"confidence\": 0.35304376\n    },\n    {\n      \"className\": \"Credit card or prepaid card\",\n      \"confidence\": 0.273138\n    },\n    {\n      \"className\": \"Debt collection\",\n      \"confidence\": 0.114369996\n    },\n    {\n      \"className\": \"Checking or savings account\",\n      \"confidence\": 0.07278225\n    },\n    {\n      \"className\": \"Mortgage\",\n      \"confidence\": 0.050865967\n    }\n  ],\n  \"producerId\": {\n    \"name\": \"Voting based Ensemble\",\n    \"version\": \"0.0.1\"\n  }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomassuedbroecker%2Fwatson-nlp-example-local-docker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthomassuedbroecker%2Fwatson-nlp-example-local-docker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomassuedbroecker%2Fwatson-nlp-example-local-docker/lists"}