Integrating with IBM Watson™ Knowledge Studio

You can integrate a custom model from IBM Watson™ Knowledge Studio with the Discovery service to provide custom enrichments.

Before you begin

Before you can integrate a custom model from Knowledge Studio with the Discovery service, you must create and deploy the model by using Knowledge Studio. See the Knowledge Studio documentation for information on creating and deploying models. You need the unique ID of the deployed model to integrate it with the Discovery service.

About this task

You can use a custom model developed in Knowledge Studio to enrich documents in the Discovery service. This gives you the flexibility to apply the Discovery service's document-enhancing capabilities with information specific to areas of particular focus, such as industry or scientific discipline. You can use both public data and your own proprietary data in your enrichment model.

You must use the service API to integrate a Knowledge Studio model with the Discovery service. You cannot use the Discovery tooling to integrate a custom model.

Procedure

  1. Get the ID of your Discovery environment as described at "List environments". Note the environment ID.

  2. List the IDs of your current Discovery configuration or configurations as described at "List configurations" Note the ID of the configuration that you want to integrate with your IBM Watson™ Knowledge Studio custom model.

  3. Download a copy of your current Discovery configuration by running the following commands in a bash shell or equivalent, such as Cygwin for Windows. Substitute {environment_id} and {configuration_id} with the IDs you noted down in the previous two steps.

    curl -u "{username}":"{password}" "https://gateway.watsonplatform.net/discovery/api/v1/environments/{environment_id}/configurations/{configuration_id}?version=2017-06-25" > my_config.json
    

    This command lists the contents of your collection file and puts them in a JSON file named my_config.json.

  4. Open the my_config.json file in a text editor and make the following changes:

    1. Change the value of the "name" field to something that indicates the purpose of the new configuration. You can optionally change the value of the "description" field as well.

      ...
      "name": "wks-config",
      "description": "This is a configuration to use with a WKS model",
      ...
      
    2. Update the enrichment fields with information for the Knowledge Studio model. Assuming that the enrichment fields originally read:

      "enrichments": [
        {
          "destination_field": "enriched_text",
          "source_field": "text",
          "enrichment": "alchemy_language",
          "options": {
            "extract": "keyword, entity, doc-sentiment, taxonomy, concept, relation",
            "sentiment": true,
            "quotations": true
          }
        }
      ]
      
    3. Update the file as follows, substituting the unique ID of the Knowledge Studio model described in "Before you begin" for {watson_knowledge_studio_model_ID}.

      "enrichments": [
        {
          "destination_field": "enriched_text",
          "source_field": "text",
          "enrichment": "alchemy_language",
          "options": {
            "extract": "keyword, entity, doc-sentiment, taxonomy, concept, relation, typed-rels",
            "sentiment": true,
            "quotations": true,
            "model": "{watson_knowledge_studio_model_ID}"
          }
        }
      ]
      
  5. Optionally enable entity normalization as described in Creating a custom configuration to normalize entities.

  6. Save the my_config.json file.

  7. We strongly recommend that you use a JSON validator such as JSLint to validate and, if necessary, correct your edited JSON before you perform the next steps.

  8. Update the configuration as follows. You again need the {environment_id} and {configuration_id} IDs you collected at the start of this procedure.

    curl -X PUT -u "{username}":"{password}" -H "Content-Type: application/json" -d @my_config.json "https://gateway.watsonplatform.net/discovery/api/v1/environments/{environment_id}/configurations/{configuration_id}?version=2017-06-25"
    

    The command returns the contents of the updated configuration file.

  9. Use the Discovery service normally. Documents you ingest with the updated configuration are automatically enriched with the data from your custom model.