Skip to main content
Version: 10.3.1

Test model execution locally

To check the model quality, you can prepare a test set of documents and run execution locally. ModelEvaluationRunner.java contains logic similar to that of the training runner.

Once the test execution is finished, the model results are available in the output directory. Statistics are located in /outputDir/statistics.csv and contain information about what actually was extracted by the model against what was expected. Using the statistics, you can analyze the model quality and decide whether you need to improve it.

Run extraction locally

To run the extraction locally, use the Archetype-generated ModelExecutionRunner class as shown in the sample code below. Only make sure to provide the following paths:

  • trainedModelPath to the trained model folder
  • inputFolderPath to the dataset folder
  • outputFolderPath to the output folder
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map;

import com.workfusion.vds.sdk.run.ModelRunner;
import com.workfusion.vds.sdk.run.config.LocalExecutionConfiguration;

public class ModelExecutionRunner {

public static void main(String[] args) throws Exception {

Path trainedModelPath = Paths.get("/home/post-processing/trained-model/");
Path inputFolderPath = Paths.get("/home/post-processing/input/");
Path outputFolderPath = Paths.get("/home/post-processing/output/");

Map<String, Object> parameters = new HashMap<>();

LocalExecutionConfiguration configuration = LocalExecutionConfiguration.builder()
.inputDir(inputFolderPath)
.outputDir(outputFolderPath)
.trainedModelDir(trainedModelPath)
.parameters(parameters)
.build();

ModelRunner.run(ExampleIeModel.class, configuration);
}

}
warning

If you use Windows on your machine, mind the following prerequisites:

  • Install your Java, IDE, and a working folder on the same logical drive.
  • Do not add the drive name to the path. Use /home/data-set/ instead of C:/home/data-set/.

After execution, you get an output folder with the following structure:

  • model-result contains JSON files with model extraction results.
  • processing-result contains a JSON file where post-processing results are stored.
  • statistics.csv is a file with statistics.

Inside the ModelRunner class, you can find an instance of ProcessingRunner. This is the main class that executes extraction and post-processing logic on your local machine.

The dataset folder contains a set of separate files (documents). However, if you have a CSV file only, for example, a snapshot from a Manual Task, instead of the run method, call runFromCsv, providing a path to the CSV file and the name of the column comprising the document content, for example, HTML, XML, or TXT. You can also use the TrainingSetUtils utility class that provides useful methods to convert a dataset from or to CSV and TXT files.

Analyze statistics

Let's look closer at the statistics.csv file. Using the file, you can analyze the model extraction results and post-processing output.

For each file in a dataset, there is a separate line. For each field in a dataset document, there are seven columns, where <%field\_name%> is the corresponding field name, for example, invoice_amount.

Column nameDescription
<%field_name%>_goldValue from the dataset file.
<%field_name%>_extractedValue extracted by the trained model.
<%field_name%>_post_processedValue after post-processing.
<%field_name%>_model_scoreScore provided by the model during extraction.
<%field_name%>_final_scoreScore changed by post-processing, the same as the model score if not changed.
<%field_name%>_error_typeError type. Possible values: TP, TN, FP, FN.
<%field_name%>_reasonReason why an error occurred, if any. Possible values: EXTRACT_MODEL, EXTRACT_RULES, FAIL_MODEL, FAIL_RULES.

Once you update the model (Annotators, Feature Extractors, or Post-Processing), train the model again, run execution, and analyze the updated statistics.

Customize logging levels for local run

For debug purposes, during local execution or training, you can change the logging level for any logger. You can use the SpringBoot-like approach: apply JVM parameters with the logging.level prefix. See the example below:

-Dlogging.level.root=DEBUG
-Dlogging.level.com.workfusion=WARN
-Dlogging.level.my.custom.packages=TRACE
TROUBLESHOOTING

In case you have issues with model quality, read the following support guide.