Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ The easiest way to deploy and run the service is to use the Docker image.
It's possible to use a Docker image via [docker HUB](https://hub.docker.com/r/grobid/datastet), pull the image (5.25GB) as follows:

```bash
docker pull grobid/datastet:0.8.0
docker pull grobid/datastet:0.9.0
```

(check the latest version on project's [docker HUB](https://hub.docker.com/r/grobid/datastet)!)

After pulling or building the Docker image, you can now run the `datastet` service as a container:

```bash
> docker run --rm --gpus all -it --init --ulimit core=0 -p 8060:8060 grobid/datastet:0.8.0
> docker run --rm --gpus all -it --init --ulimit core=0 -p 8060:8060 grobid/datastet:0.9.0
```

The build image includes the automatic support of GPU when available on the host machine via the parameter `--gpus all` (with automatic recognition of the CUDA version), with fall back to CPU if GPU are not available.
Expand All @@ -51,15 +51,15 @@ The `datastet` service is available at the default host/port `localhost:8060`, b
launch time of the container as follow:

```bash
> docker run --rm --gpus all -it --init --ulimit core=0 -p 8080:8060 grobid/datastet:0.8.0
> docker run --rm --gpus all -it --init --ulimit core=0 -p 8080:8060 grobid/datastet:0.9.0
```

By default, BidLSTM-CFR with ELMo model if used for the dataset mention recognition (it performs better than SciBERT with 3 points F1-score).
Every classification models are fine-tuned SciBERT models.
To modify the configuration without rebuilding the image - for instance rather use the SciBERT model, it is possible to mount a modified config file at launch as follows:

```bash
> docker run --rm --gpus all -it --init --ulimit core=0 -p 8060:8060 -v /home/lopez/grobid/datastet/resources/config/config.yml:/opt/grobid/datastet/resources/config/config.yml:ro grobid/datastet:0.8.0
> docker run --rm --gpus all -it --init --ulimit core=0 -p 8060:8060 -v /home/lopez/grobid/datastet/resources/config/config.yml:/opt/grobid/datastet/resources/config/config.yml:ro grobid/datastet:0.9.0
```

As an alterntive, a docker image for the `datastet` service can be built with the project Dockerfile to match the
Expand All @@ -74,15 +74,15 @@ current master version. The complete process is as follows:
- from the GROBID root installation (`grobid/`), launch the docker build:

```bash
> docker build -t grobid/datastet:0.8.0 --build-arg GROBID_VERSION=0.8.0 --file Dockerfile.datastet .
> docker build -t grobid/datastet:0.9.0 --build-arg GROBID_VERSION=0.9.0 --file Dockerfile.datastet .
```

The Docker image build take several minutes, installing GROBID, datastet, a complete Python Deep Learning environment based on [DeLFT](https://github.com/kermitt2/delft) and deep learning models downloaded from the internet (one fine-tuned model with a BERT layer has a size of around 400 MB).
The resulting image is thus very large, more than 10GB, due to the deep learning resources and models.

## Build & Run

Building the module requires JDK 1.8 or higher. First install and build the latest development version of GROBID (currently `0.8.2-SNAPSHOT`) as explained by the [documentation](http://grobid.readthedocs.org), together with [DeLFT](https://github.com/kermitt2/delft) (currently version `0.3.2`) for Deep Learning model support.
Building the module requires JDK 1.8 or higher. First install and build the latest development version of GROBID (currently `0.9.0`) as explained by the [documentation](http://grobid.readthedocs.org), together with [DeLFT](https://github.com/kermitt2/delft) (currently version `0.3.2`) for Deep Learning model support.

Under the installed and built `grobid/` directory, clone the present module `datastet` (it will appear as sibling sub-project to grobid-core, grobid-trainer, etc.):

Expand Down Expand Up @@ -201,7 +201,7 @@ The output data format is JSON format as follows:
```json
{
"application" : "datastet",
"version" : "0.8.0",
"version" : "0.9.0",
"date" : "2024-10-04T07:31+0000",
"md5" : "F1F1BC4C79AC8A8E85D1EAF4265B97FB",
"mentions" : [ {
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ apply plugin: 'base'
apply plugin: 'com.github.kt3k.coveralls'

group = "org.grobid.datastet"
version = '0.8.2-SNAPSHOT'
version = '0.9.0'

description = """datastet"""

Expand Down
2 changes: 1 addition & 1 deletion resources/config/config-docker.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: "0.8.2"
version: "0.9.0"

corpusPath: "./resources/dataset/dataseer/corpus"
templatePath: "./resources/dataset/dataseer/crfpp-templates/dataseer.template"
Expand Down
2 changes: 1 addition & 1 deletion resources/config/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: "0.8.2"
version: "0.9.0"

corpusPath: "./resources/dataset/dataseer/corpus"
templatePath: "./resources/dataset/dataseer/crfpp-templates/dataseer.template"
Expand Down
24 changes: 21 additions & 3 deletions src/main/java/org/grobid/core/engines/DatasetParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ public class DatasetParser extends AbstractParser {
private static final java.util.concurrent.atomic.AtomicBoolean disambiguatorWarningLogged =
new java.util.concurrent.atomic.AtomicBoolean(false);

// guard to warn only once about the context classifier not being available
private static final java.util.concurrent.atomic.AtomicBoolean contextClassifierWarningLogged =
new java.util.concurrent.atomic.AtomicBoolean(false);

private EngineParsers parsers;
private DatastetServiceConfiguration datastetConfiguration;
private DataTypeClassifier dataTypeClassifier;
Expand All @@ -101,6 +105,12 @@ private static void warnDisambiguatorNotAvailableOnce() {
}
}

private static void warnContextClassifierNotAvailableOnce() {
if (contextClassifierWarningLogged.compareAndSet(false, true)) {
LOGGER.warn("Dataset context classifier is not available, context classification will be skipped");
}
}

public static DatasetParser getInstance(
DatastetServiceConfiguration configuration,
DataTypeClassifier dataTypeClassifier,
Expand Down Expand Up @@ -128,12 +138,16 @@ private DatasetParser(DatastetServiceConfiguration configuration) {
GrobidCRFEngine.valueOf(configuration.getDatastetConfiguration().getModel("datasets").engine.toUpperCase()),
configuration.getDatastetConfiguration().getModel("datasets").delft.architecture);

this.dataTypeClassifier = dataTypeClassifier;
DatastetLexicon.getInstance();
this.parsers = new EngineParsers();
this.datastetConfiguration = configuration;
this.disambiguator = DatasetDisambiguator.getInstance(configuration.getDatastetConfiguration());
this.datasetContextClassifier = datasetContextClassifier;
try {
this.datasetContextClassifier = DatasetContextClassifier.getInstance(configuration);
} catch (Exception e) {
LOGGER.warn("Dataset context classifier is not available, context classification will be skipped", e);
this.datasetContextClassifier = null;
}
}

public List<List<Dataset>> processing(List<DatasetDocumentSequence> tokensList) {
Expand Down Expand Up @@ -1482,7 +1496,11 @@ public Pair<List<List<Dataset>>, Document> processPDF(File file,
entities = markDAS(entities, availabilityTokens);

// finally classify the context for predicting the role of the dataset mention
entities = this.datasetContextClassifier.classifyDocumentContexts(entities);
if (this.datasetContextClassifier != null) {
entities = this.datasetContextClassifier.classifyDocumentContexts(entities);
} else {
warnContextClassifierNotAvailableOnce();
}

} catch (Exception e) {
//e.printStackTrace();
Expand Down
Loading