Merge pull request #2358 from mozilla/rename-probability-confidence
Rename metadata probability field to confidence
This commit is contained in:
commit
7995e4230b
|
@ -350,7 +350,7 @@ JSONOutput(Metadata* metadata)
|
|||
std::vector<meta_word> words = WordsFromMetadata(metadata);
|
||||
|
||||
std::ostringstream out_string;
|
||||
out_string << R"({"metadata":{"confidence":)" << metadata->probability << R"(},"words":[)";
|
||||
out_string << R"({"metadata":{"confidence":)" << metadata->confidence << R"(},"words":[)";
|
||||
|
||||
for (int i = 0; i < words.size(); i++) {
|
||||
meta_word w = words[i];
|
||||
|
|
|
@ -51,14 +51,14 @@ def ctc_beam_search_decoder(probs_seq,
|
|||
:param scorer: External scorer for partially decoded sentence, e.g. word
|
||||
count or language model.
|
||||
:type scorer: Scorer
|
||||
:return: List of tuples of log probability and sentence as decoding
|
||||
results, in descending order of the probability.
|
||||
:return: List of tuples of confidence and sentence as decoding
|
||||
results, in descending order of the confidence.
|
||||
:rtype: list
|
||||
"""
|
||||
beam_results = swigwrapper.ctc_beam_search_decoder(
|
||||
probs_seq, alphabet.config_file(), beam_size, cutoff_prob, cutoff_top_n,
|
||||
scorer)
|
||||
beam_results = [(res.probability, alphabet.decode(res.tokens)) for res in beam_results]
|
||||
beam_results = [(res.confidence, alphabet.decode(res.tokens)) for res in beam_results]
|
||||
return beam_results
|
||||
|
||||
|
||||
|
@ -93,15 +93,15 @@ def ctc_beam_search_decoder_batch(probs_seq,
|
|||
:param scorer: External scorer for partially decoded sentence, e.g. word
|
||||
count or language model.
|
||||
:type scorer: Scorer
|
||||
:return: List of tuples of log probability and sentence as decoding
|
||||
results, in descending order of the probability.
|
||||
:return: List of tuples of confidence and sentence as decoding
|
||||
results, in descending order of the confidence.
|
||||
:rtype: list
|
||||
"""
|
||||
batch_beam_results = swigwrapper.ctc_beam_search_decoder_batch(
|
||||
probs_seq, seq_lengths, alphabet.config_file(), beam_size, num_processes,
|
||||
cutoff_prob, cutoff_top_n, scorer)
|
||||
batch_beam_results = [
|
||||
[(res.probability, alphabet.decode(res.tokens)) for res in beam_results]
|
||||
[(res.confidence, alphabet.decode(res.tokens)) for res in beam_results]
|
||||
for beam_results in batch_beam_results
|
||||
]
|
||||
return batch_beam_results
|
||||
|
|
|
@ -46,7 +46,7 @@ std::vector<Output> get_beam_search_result(
|
|||
for (size_t i = 0; i < top_paths && i < prefixes.size(); ++i) {
|
||||
Output output;
|
||||
prefixes[i]->get_path_vec(output.tokens, output.timesteps);
|
||||
output.probability = -prefixes[i]->approx_ctc;
|
||||
output.confidence = -prefixes[i]->approx_ctc;
|
||||
output_vecs.push_back(output);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* for each token in the beam search output
|
||||
*/
|
||||
struct Output {
|
||||
double probability;
|
||||
double confidence;
|
||||
std::vector<int> tokens;
|
||||
std::vector<int> timesteps;
|
||||
};
|
||||
|
|
|
@ -30,8 +30,10 @@ typedef struct MetadataItem {
|
|||
typedef struct Metadata {
|
||||
MetadataItem* items;
|
||||
int num_items;
|
||||
// Approximated probability (confidence value) for this transcription.
|
||||
double probability;
|
||||
// Approximated confidence value for this transcription. This is roughly the
|
||||
// sum of the acoustic model logit values for each timestep/character that
|
||||
// contributed to the creation of this transcription.
|
||||
double confidence;
|
||||
} Metadata;
|
||||
|
||||
enum DeepSpeech_Error_Codes
|
||||
|
|
|
@ -36,7 +36,7 @@ namespace DeepSpeechClient.Extensions
|
|||
var metaData = (Metadata)Marshal.PtrToStructure(intPtr, typeof(Metadata));
|
||||
|
||||
managedMetaObject.Items = new Models.MetadataItem[metaData.num_items];
|
||||
managedMetaObject.Probability = metaData.probability;
|
||||
managedMetaObject.Confidence = metaData.confidence;
|
||||
|
||||
|
||||
//we need to manually read each item from the native ptr using its size
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
public class Metadata
|
||||
{
|
||||
/// <summary>
|
||||
/// Approximated probability (confidence value) for this transcription.
|
||||
/// Approximated confidence value for this transcription.
|
||||
/// </summary>
|
||||
public double Probability { get; set; }
|
||||
public double Confidence { get; set; }
|
||||
/// <summary>
|
||||
/// List of metada items containing char, timespet, and time offset.
|
||||
/// </summary>
|
||||
|
|
|
@ -15,8 +15,8 @@ namespace DeepSpeechClient.Structs
|
|||
/// </summary>
|
||||
internal unsafe int num_items;
|
||||
/// <summary>
|
||||
/// Approximated probability (confidence value) for this transcription.
|
||||
/// Approximated confidence value for this transcription.
|
||||
/// </summary>
|
||||
internal unsafe double probability;
|
||||
internal unsafe double confidence;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace CSharpExamples
|
|||
var nl = Environment.NewLine;
|
||||
string retval =
|
||||
Environment.NewLine + $"Recognized text: {string.Join("", meta?.Items?.Select(x => x.Character))} {nl}"
|
||||
+ $"Prob: {meta?.Probability} {nl}"
|
||||
+ $"Confidence: {meta?.Confidence} {nl}"
|
||||
+ $"Item count: {meta?.Items?.Length} {nl}"
|
||||
+ string.Join(nl, meta?.Items?.Select(x => $"Timestep : {x.Timestep} TimeOffset: {x.StartTime} Char: {x.Character}"));
|
||||
return retval;
|
||||
|
|
|
@ -49,7 +49,7 @@ ModelState::decode_metadata(const DecoderState& state)
|
|||
|
||||
std::unique_ptr<Metadata> metadata(new Metadata());
|
||||
metadata->num_items = out[0].tokens.size();
|
||||
metadata->probability = out[0].probability;
|
||||
metadata->confidence = out[0].confidence;
|
||||
|
||||
std::unique_ptr<MetadataItem[]> items(new MetadataItem[metadata->num_items]());
|
||||
|
||||
|
|
Loading…
Reference in New Issue