Concepts

At a glance

The Concepts task extracts general DBPedia concepts that are directly referenced or alluded to (but not directly referenced) in the input text. For example, in the text IBM announces new advances in quantum computing., a concept extracted may be http://dbpedia.org/resource/IBM, http://dbpedia.org/resource/Quantum_computing and http://dbpedia.org/resource/Qubit.

Class definition
watson_nlp.workflows.concepts.concepts_workflow.ConceptsWorkflow

The Concepts model was trained to assign concepts from DBPedia (2016 version)

Pretrained models

Model names are listed below. For language support, see Supported languages.

Model ID Container Image
concepts_alchemy-workflow_lang_de_stock cp.icr.io/cp/ai/watson-nlp_concepts_alchemy-workflow_lang_de_stock:1.4.1
concepts_alchemy-workflow_lang_en_stock cp.icr.io/cp/ai/watson-nlp_concepts_alchemy-workflow_lang_en_stock:1.4.1
concepts_alchemy-workflow_lang_es_stock cp.icr.io/cp/ai/watson-nlp_concepts_alchemy-workflow_lang_es_stock:1.4.1
concepts_alchemy-workflow_lang_fr_stock cp.icr.io/cp/ai/watson-nlp_concepts_alchemy-workflow_lang_fr_stock:1.4.1
concepts_alchemy-workflow_lang_it_stock cp.icr.io/cp/ai/watson-nlp_concepts_alchemy-workflow_lang_it_stock:1.4.1
concepts_alchemy-workflow_lang_ja_stock cp.icr.io/cp/ai/watson-nlp_concepts_alchemy-workflow_lang_ja_stock:1.4.1
concepts_alchemy-workflow_lang_ko_stock cp.icr.io/cp/ai/watson-nlp_concepts_alchemy-workflow_lang_ko_stock:1.4.1
concepts_alchemy-workflow_lang_pt_stock cp.icr.io/cp/ai/watson-nlp_concepts_alchemy-workflow_lang_pt_stock:1.4.1

For details of the Concepts type system, see Understanding model type systems.

Running models

The Concepts model request accepts the following fields:

Field Type Required
Optional
Repeated
Description
raw_document watson_core_data_model.nlp.RawDocument required The input document on which to perform Concepts predictions
limit int32 optional The maximum number of concepts to return. Default is 50

Example requests

REST API

curl -s \
  "http://localhost:8080/v1/watson.runtime.nlp.v1/NlpService/ConceptsPredict" \
  -H "accept: application/json" \
  -H "content-type: application/json" \
  -H "Grpc-Metadata-mm-model-id: concepts_alchemy-workflow_lang_en_stock" \
  -d '{ "raw_document": { "text": "Einstein postulated that light propagates through empty space with a definite speed 'c' independent of the speed of the observer (or source)." }, "limit": 2 }'

Response

{"concepts":[
  {"text":"Special_relativity", "relevance":0.7799297, "dbpediaResource":"http://dbpedia.org/resource/Special_relativity"},
  {"text":"Vacuum", "relevance":0.6394, "dbpediaResource":"http://dbpedia.org/resource/Vacuum"}
  ],
 "producerId":{
  "name":"Concepts Workflow",
  "version":"0.0.1"
  }
}

Python

import grpc

from watson_nlp_runtime_client import (
    common_service_pb2,
    common_service_pb2_grpc,
    syntax_types_pb2,
)

channel = grpc.insecure_channel("localhost:8085")

stub = common_service_pb2_grpc.NlpServiceStub(channel)

request = common_service_pb2.ConceptsRequest(
    raw_document=syntax_types_pb2.RawDocument(text="Einstein postulated that light propagates through empty space with a definite speed 'c' independent of the speed of the observer (or source)."),
    limit=2
)

  response = stub.ConceptsPredict(
    request, metadata=[("mm-model-id", "concepts_alchemy-workflow_lang_en_stock")]
)

print(response)

Response

concepts {
  text: "Special_relativity"
  relevance: 0.78003943
  dbpedia_resource: "http://dbpedia.org/resource/Special_relativity"
}
concepts {
  text: "Vacuum"
  relevance: 0.639851689
  dbpedia_resource: "http://dbpedia.org/resource/Vacuum"
}
producer_id {
  name: "Concepts Workflow"
  version: "0.0.1"
}