kiwi.runner
Predictions
Runner
kiwi.runner.
logger
sentences_hter
target_tags_BAD_probabilities
target_tags_labels
source_tags_BAD_probabilities
source_tags_labels
gap_tags_BAD_probabilities
gap_tags_labels
configure_outputs
wrap_predictions
predict
Create predictions for a list of examples.
source – a list of sentences on a source language.
target – a list of (translated) sentences on a target language.
alignments – optional list of source-target alignments required only by the NuQE model.
batch_size – how large to build a batch (default: 1).
num_data_workers – how many subprocesses to use for data loading.
A Predictions object with predicted outputs for each example in the inputs. If input source and target are all empty, returned object has all attributes as None. If there are aligned empty sentences at both source and target, the corresponding returned prediction will contain empty/zero values (empty list for word level outputs, 0.0 for sentence level outputs).
source
target
None
Exception –
If an example has an empty string as source xor target
field (not both at the same time).
Notes
source and target lenghts must match.
Example
>>> from kiwi.lib import predict >>> runner = predict.load_system('../tests/toy-data/models/nuqe.ckpt') >>> source = ['a b c', 'd e f g'] >>> target = ['q w e r', 't y'] >>> alignments = ['0-0 1-1 1-2', '1-1 3-0'] >>> predictions = runner.predict(source, target, alignments) >>> predictions.target_tags_BAD_probabilities [[0.49699464440345764, 0.49956727027893066, ...], [..., 0.5013138651847839]]
sentences_hter=[0.2668147683143616, 0.26675286889076233], target_tags_BAD_probabilities=[
[0.49699464440345764, 0.49956727027893066, 0.5025501847267151, 0.5057167410850525, ], [0.4967852830886841, 0.5013138651847839],
0.49699464440345764, 0.49956727027893066, 0.5025501847267151, 0.5057167410850525,
], [0.4967852830886841, 0.5013138651847839],
], target_tags_labels=[[‘OK’, ‘OK’, ‘BAD’, ‘BAD’], [‘OK’, ‘BAD’]], source_tags_BAD_probabilities=None, source_tags_labels=None, gap_tags_BAD_probabilities=[
[0.42644527554512024, 0.42096763849258423, 0.41709718108177185, 0.4157106280326843, 0.41496342420578003, ], [0.42876192927360535, 0.4251120686531067, 0.4210476577281952],
0.42644527554512024, 0.42096763849258423, 0.41709718108177185, 0.4157106280326843, 0.41496342420578003,
], [0.42876192927360535, 0.4251120686531067, 0.4210476577281952],
], gap_tags_labels=[[‘OK’, ‘OK’, ‘OK’, ‘OK’, ‘OK’], [‘OK’, ‘OK’, ‘OK’]],
)
run
remove_empty_sentences
insert_dummy_outputs_for_empty_sentences
kiwi.loggers