Skip to content

Latest commit

 

History

History
223 lines (177 loc) · 7.35 KB

Workshop-2-Tuesday.md

File metadata and controls

223 lines (177 loc) · 7.35 KB

NLP Hands-on Workshop Series - Session 2

Creating a custom language model to optimize NLP results

Tuesday, November 5 | 10:45 - 12:15 | Holly & Butternut

 

Section A

[Do this section in IBM Watson Knowledge Studio]

Open the Knowledge Studio web GUI, then create an entities and relations workspace:

  1. Click create an entities and relations workspace
  2. Assign the workspace a name and finish

→ A.1 Define entities

Define the types of word we care about (entities) and supply some examples of those words (dictionaries).

  1. On the Entity Types page, add the following entity types:

    • action
    • docs
    • obj
    • persona
    • tech

    Do not edit the Roles or Subtypes.

  2. On the Dictionaries page:

    1. Download each of these dictionaries to your local computer, then upload them to Watson Knowledge Studio:
    2. For each dictionary, select the dictionary and associate the dictionary with the entity type of the same name

    Note: You have to upload the dictionaries one at a time by selecting Upload Dictionary from the menu.

→ A.2 Provide sample customer messages

On the Documents page:

  1. Download this document set to your local computer: customer-messages-documents.zip

    Note: Uncompress the .zip file into individual .txt files on your local computer

  2. In Watson Knowledge Studio, click Import Document Set and then upload the 18 .txt files you downloaded in the prerequisites
  3. Rename the document set "Document set 1"

Note: Do not upload the .zip file itself. Upload the 18 .txt files in one upload action as a set.

→ A.3 Process files & train model

  1. On the Pre-annotation page (under the Machine Learning Model menu item):

    1. Click Apply This Pre-annotator
    2. When prompted, select "Document set 1" and then click Run
  2. On the Performance page:

    1. Select all documents, and then click Train and evaluate

→ A.4 Deploy model

On the Versions page:

  1. Click Create version
  2. Deploy the snapshot version you just created to your IBM Watson Natural Language Understanding service instance

    Note: If you cannot find your NLU service instance in Spaces try looking in Resource groups.

Creating a custom model

 

Section B

[Do this section in IBM Watson Studio]

Create a project in Watson Studio from the sample project.

  1. Download this sample project to your local computer:
    CASCON-2019-NLP-Workshop-2-Tuesday.zip

  2. In Watson Studio, create a new project "from a sample or file":

    1. Upload the sample project .zip file
    2. Give the project a name
    3. If you don't already have Cloud Object Storage set up, follow the prompts to create an instance of Cloud Object Storage for the project
    4. Click Create

Creating a project from a file

Demo video
Create project from sample

 

Section C

Analyze customer questions and comments a notebook.

  1. On the Assets page of your project, open the notebook named "3-Custom-language-model" in edit mode by clicking the pencil ( ) beside the notebook

  2. Add the NLU service apikey:

    1. From the Services menu in Watson Studio, right-click "Watson Services" and then open the link in a new browser tab
    2. In the new Watson services tab, from the Action menu beside the Natural Language Understanding instance, select "Manage in IBM Cloud"
    3. In the service details page that opens, click Service credentials, then expand credentials to view them, and then copy the apikey
  3. Specify the custom model ID:

    1. On the Versions page in your Knowledge Studio workspace, expand the Deployed Models list
    2. Copy the Model ID
  4. Run the code cells in the notebook in order, starting at the top.

    1. Import sample customer messages
    2. Analyze sample customer messages: default model & custom model

Notebook

 

Section D

Normalize results.

  1. On the Assets page of your project, open the notebook named "4-Normalize-custom-model-results" in edit mode by clicking the pencil ( ) beside the notebook

  2. Run the code cells in the notebook in order, starting at the top.

Normalizing results

 

Section E

Visualize normalized results.

  1. On the Assets page of your project, open the notebook named "5-Visualize-custom-model-results" in edit mode by clicking the pencil ( ) beside the notebook

  2. Run the code cells in the notebook in order, starting at the top.

Visualize normalized results

 

Bonus: Section F [Optional]

Cluster messages using extracted entities.

  1. On the Assets page of your project, open the notebook named "5-Visualize-custom-model-results" in edit mode by clicking the pencil ( ) beside the notebook

  2. Run the code cells in the notebook in order, starting at the top.

Visualize normalized results