Images for the WSD module of Universal Semantic Annotator (USeA).
188
Universal Semantic Annotator (USeA) is the first unified API for three primary tasks in Natural Language Understanding (NLU):
The main motivations behind USeA are manifold: i) the creation of an easy-to-use tool and service for the automatic annotation of explicit semantic knowledge in 100 languages, ii) enabling the use of explicit semantics in multilingual and cross-lingual real-world applications, iii) the democratization of state-of-the-art systems that would otherwise require expert knowledge of the field for their development and implementation, and last but not least iv) fostering further research in NLU and other fields on the interplay between semantics and other modalities, e.g., computer vision, speech recognition, video understanding.
This repo is for the Docker image of the USeA WSD module. This image takes care of:
usea-wsd containerMake sure you have installed docker before proceeding, then run the following command:
docker run --name sapienzanlp/usea-wsd:1.0.0 -p 22002:80 usea-wsd
If you want to run the container in the background, simply use the flag -d as follows:
docker run -d --name sapienzanlp/usea-wsd:1.0.0 -p 22002:80 usea-wsd
If everything went well, the service will become available at localhost:22002/api/wsd.
If you want to use a GPU to speed-up usea-wsd, you can use the CUDA-compatible image:
docker run -d --name sapienzanlp/usea-wsd:1.0.0-cuda -p 22002:80 usea-wsd
For more info about how to enable GPU support in Docker you can refer to the official documentation.
This service exposes an end-point named /api/wsd. The endpoint accepts POST requests with a JSON body,
containing a list of tokens. For each token, some parameters must be specified:
text: the text of the tokenindex: the index of the tokenpos: the pos tag of the tokenlemma: the lemma of the tokendep: the dependency label of the tokenEach request returns a JSON response containing a list of objects, one for each input document. Each object
in the response provides the tokenization, lemmatization, PoS-tagging and sense information of the
corresponding input document.
Let's try with a simple example. We want to disambiguate the words in the following sentence "The quick brown fox jumps over the lazy dog.":
curl -X 'POST' \
'http://127.0.0.1/api/wsd' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"sentence":{
"tokens":[
{
"text":"The",
"index":0,
"pos":"DET",
"lemma":"the",
"dep":"det"
},
{
"text":"quick",
"index":1,
"pos":"ADJ",
"lemma":"quick",
"dep":"amod"
},
{
"text":"brown",
"index":2,
"pos":"ADJ",
"lemma":"brown",
"dep":"amod"
},
{
"text":"fox",
"index":3,
"pos":"NOUN",
"lemma":"fox",
"dep":"nsubj"
},
{
"text":"jumps",
"index":4,
"pos":"VERB",
"lemma":"jump",
"dep":"root"
},
{
"text":"over",
"index":5,
"pos":"ADP",
"lemma":"over",
"dep":"case"
},
{
"text":"the",
"index":6,
"pos":"DET",
"lemma":"the",
"dep":"det"
},
{
"text":"lazy",
"index":7,
"pos":"ADJ",
"lemma":"lazy",
"dep":"amod"
},
{
"text":"dog",
"index":8,
"pos":"NOUN",
"lemma":"dog",
"dep":"obl"
},
{
"text":".",
"index":9,
"pos":"PUNCT",
"lemma":".",
"dep":"punct"
}
],
"language":"en"
}
}'
If everything went right, the output should be similar to:
{
"tokens": [
{
"index": 0,
"text": "The",
"pos": "DET",
"lemma": "the",
"bnSynsetId": "O",
"wnSynsetOffset": "O",
"nltkSynset": "O"
},
{
"index": 1,
"text": "quick",
"pos": "ADJ",
"lemma": "quick",
"bnSynsetId": "bn:00096664a",
"wnSynsetOffset": "32733a",
"nltkSynset": "agile.s.01"
},
{
"index": 2,
"text": "brown",
"pos": "ADJ",
"lemma": "brown",
"bnSynsetId": "bn:00098942a",
"wnSynsetOffset": "372111a",
"nltkSynset": "brown.s.01"
},
{
"index": 3,
"text": "fox",
"pos": "NOUN",
"lemma": "fox",
"bnSynsetId": "bn:00036129n",
"wnSynsetOffset": "2118333n",
"nltkSynset": "fox.n.01"
},
{
"index": 4,
"text": "jumps",
"pos": "VERB",
"lemma": "jump",
"bnSynsetId": "bn:00083833v",
"wnSynsetOffset": "1963942v",
"nltkSynset": "jump.v.01"
},
{
"index": 5,
"text": "over",
"pos": "ADP",
"lemma": "over",
"bnSynsetId": "O",
"wnSynsetOffset": "O",
"nltkSynset": "O"
},
{
"index": 6,
"text": "the",
"pos": "DET",
"lemma": "the",
"bnSynsetId": "O",
"wnSynsetOffset": "O",
"nltkSynset": "O"
},
{
"index": 7,
"text": "lazy",
"pos": "ADJ",
"lemma": "lazy",
"bnSynsetId": "bn:00105799a",
"wnSynsetOffset": "981304a",
"nltkSynset": "lazy.s.01"
},
{
"index": 8,
"text": "dog",
"pos": "NOUN",
"lemma": "dog",
"bnSynsetId": "bn:00015267n",
"wnSynsetOffset": "2084071n",
"nltkSynset": "dog.n.01"
},
{
"index": 9,
"text": ".",
"pos": "PUNCT",
"lemma": ".",
"bnSynsetId": "O",
"wnSynsetOffset": "O",
"nltkSynset": "O"
}
],
"language": "en"
}
There are a few environment variables that can be passed to the docker container to customize the behavior of your instance:
TIMEOUTIf your container crashes at loading time, try to increase this value.
Default value: TIMEOUT="500"
Example: Setting the TIMEOUT value to 1200.
docker run --name sapienzanlp/usea-wsd:1.0.0 -p 22002:80 -e TIMEOUT="1200" usea-wsd
MAX_WORKERSCan be used to limit the number of simultaneously running processes.
Default value: MAX_WORKERS=1
Example: Setting the number of AMuSE-WSD instances to 4.
docker run --name sapienzanlp/usea-wsd:1.0.0 -p 22002:80 -e MAX_WORKERS="4" usea-wsd
WORKERS_PER_COREChecks how many CPU cores are available in the current server running your container.
It will set the number of workers to the number of CPU cores multiplied by this value.
Default value: WORKERS_PER_CORE=1
Example:
docker run --name sapienzanlp/usea-wsd:1.0.0 -p 22002:80 -e WORKERS_PER_CORE="3" usea-wsd
If you set the value to 3 in a server with 2 CPU cores, it will run 6 worker processes.
docker run --name sapienzanlp/usea-wsd:1.0.0 -p 22002:80 -e WORKERS_PER_CORE="0.5" usea-wsd
LOG_LEVELThe log level for Gunicorn.
One of:
debuginfowarningerrorcriticalDefault value: LOG_LEVEL=”info”
Example:
docker run --name sapienzanlp/usea-wsd:1.0.0 -p 22002:80 -e LOG_LEVEL="info" usea-wsd
Auto-generated interactive documentation for the API (thanks to FastAPI).
http://127.0.0.1:PORT/docs
where PORT is the port number you specify when starting up the service.
Content type
Image
Digest
Size
3 GB
Last updated
over 4 years ago
docker pull sapienzanlp/usea-wsd:1.0.0-cuda