- require 'zipf'
!!!
%html
%head
%title Debug view (Session #{session_key})
%link(rel="stylesheet" type="text/css" href="debug.css")
%script{:src => "http://postedit.cl.uni-heidelberg.de/js/jquery.min.js"}
%script{:src => "http://postedit.cl.uni-heidelberg.de/js/jquery.tablesorter.min.js"}
%script{:src => "http://postedit.cl.uni-heidelberg.de/js/debug.js"}
%body
%h1 Debug view
%div#floater
- if pairwise_ranking_data["kbest"].empty?
%p.red
%strong No data to show!
%ul
-if admin
%li
%a{ :href => "#controls" } Controls
%li
%a{ :href => "#post_edit" } Post-edit
%li
%a{ :href => "#grammar" } Grammar
%li
%a{ :href => "#weights" } Weights
%li
%a{ :href => "#kbest" } K-best
%p
Status:
%span#status ...
%p.tiny Session: #{session_key}
/=#########################################################################
-if admin
%h2#controls Controls
%h3 Reset
%p
%strong [Server reply]
%span#control_reply
%ul
%li
%a.ajax{:tgt => "/reset_progress", :href => "#controls"} Reset progress
%li
%a.ajax{:tgt => "/reset_weights", :href => "#controls"} Reset weights
%li
%a.ajax{:tgt => "/reset_learning_rates", :href => "#controls"} Reset learning rates
/
%li
%a.ajax{:tgt => "/reset_extractor", :href => "#controls"} Reset extractor
%li
%a.ajax{:tgt => "/reset_grammars", :href => "#controls"} Reset grammars
%li
%a.ajax{:tgt => "/reset_new_rules", :href => "#controls"} Reset new rules
/
%li
%a.ajax{:tgt => "/shutdown", :href => "#controls"} Initiate shutdown
%h3 Learning rates & weights
%p Get current weight/rate for specific features:
%input#features_get{ :value => "Feature", :style => "text-align:center; width:20em" }
%select#features_type_get
%option{ :value => "/get_weight" } Weight
%option{ :value => "/get_rate" } Rate
%input#features_value_get{ :value => " ", :style => "text-align:right; width:10em" }
%button#get_features
Get
%p Set weight/rate for specific features:
%input#features{ :value => "Feature", :style => "text-align:center; width:20em" }
%select#features_type
%option{ :value => "/set_weights" } Weight
%option{ :value => "/set_learning_rates" } Rate
%input#features_value{ :value => "1e-05", :style => "text-align:right; width:10em" }
%button#set_features
Set
%p
Set rate for feature groups:
%span.tiny (Features unseen in training/tuning have a common default rate.)
%select#feature_groups_get
%option{ :value => "R" } rule ids
%option{ :value => "RB" } rule bigrams
%option{ :value => "Shape" } rule shapes
%input#feature_groups_value_get{ :value => "1e-05", :style => "text-align:right; width:10em" }
%button#get_feature_groups
Get rate
%br
%select#feature_groups
%option{ :value => "R" } rule ids
%option{ :value => "RB" } rule bigrams
%option{ :value => "Shape" } rule shapes
%input#feature_groups_value{ :value => "1e-05", :style => "text-align:right; width:10em" }
%button#set_feature_groups
Set rate
/=#########################################################################
%h2#post_edit Post-edit
%p#original_svg_b64 #{data["original_svg"][progress]}
%p Before:
%div#original_svg
%p#svg_b64 #{data["svg"][progress]}
%p After:
%div#svg
%table
%tr
%td.noborder
%strong Progress:
%td.left.noborder ##{[0,progress].max}
%tr
%td.noborder
%strong Raw source:
%td.left.noborder #{data["raw_source_segments"][[0,progress].max]}
%tr
%td.noborder
%strong MT Input:
%td.left.noborder #{data["source_segments"][[0,progress].max]}
%tr
%td.noborder
%strong Post-edit:
%td.left.noborder #{data["post_edits_raw"][progress]}
%tr
%td.noborder
%strong Post-edit (processed):
%td.left.noborder #{data["post_edits"][progress]}
%tr
%td.noborder
%strong Original MT:
%td.left.noborder #{data["mt_raw"][progress]}
%tr
%td.noborder
%strong Displayed MT:
%td.left.noborder #{data["mt"][progress]}
%tr
%td.noborder
%strong Best match (BLEU=#{(pairwise_ranking_data["best_match_score"]*100).round(2)}%):
%td.left.noborder.updated #{pairwise_ranking_data["best_match"]}
%h3 Metadata
%p
Updated:
%span#up_val #{data["updated"][progress]}
%p.updated K: #{pairwise_ranking_data["samples_size"]}
%p.updated Number of updates: #{pairwise_ranking_data["num_up"]}
%p.updated Updated features: #{pairwise_ranking_data["updated_features"]}
%p Duration: #{data["durations"][progress]}ms
%p Keypresses: #{data["count_kbd"][progress]}
%p Clicks: #{data["count_click"][progress]}
%h3 Derivation
%p
%a{:onclick => "$('#derivation').toggle()"} Show/hide original raw derivation.
%pre#derivation{:style => "display:none"} #{data["derivations"][progress]}
%h3 Client reply
%p
%a{:onclick => "$('#client_reply').toggle()"} Show/hide raw JSON client reply.
- if data["feedback"][progress]
- client_reply = JSON.parse(data["feedback"][progress])
- client_reply["svg"] = "omitted"
- client_reply["original_svg"] = "omitted"
%pre#client_reply{ :style => "display:none" } #{JSON.pretty_generate(client_reply)}
%p.up
%a{ :href => "#" } ^ up
/=#########################################################################
%h2#grammar Grammar
%p Notes: In addition to dynamically adding each source/post-edit instance to the suffix array extractor, the system additionally uses the provided phrase alignments to extract new rules. The extraction follows the original Hiero grammar extraction, but using phrases instead of words and using only a single binary feature: 'NewRule=1'. Extracted rules that already exist in a grammar are annotated with an additional feature: 'KnownRules=1'. OOVs are avoided by asking the user for translations of unknown words prior to translation. These are added to the grammars as new rules ('OOVFix=1').
%h3
New Rules
%p Including OOV fixes.
%table.sortable
%thead
%th Source
%th
%th Target
%tbody
- new_rules.each do |rule_string|
- nt, src, tgt, f, a = splitpipe(rule_string)
%tr
%td #{src}
%td.big ↣
%td #{tgt}
%h3
Known rules
%table.sortable
%thead
%th Source
%th
%th Target
%tbody
- known_rules.each do |rule_string|
- nt, src, tgt, f, a = splitpipe(rule_string)
%tr
%td #{src}
%td.big ↣
%td #{tgt}
%p.up
%a{ :href => "#" } ^ up
/=#########################################################################
%h2#weights Weights
%p Notes: If the user modifies the string of the original one-best output, a standard pairwise ranking update is made, using the post-edit as reference translation. No update is performed if the string is not modified. The k-best list is not modified, as the original grammar is used (leave-one-out).
/
%p N.B. that updates are only done if the post-edit is different from the original 1-best output of the decoder.
%p Update of a single row is: After = Before - (Rate * -Raw Diff.) = Before + (Rate * Raw. Diff.). The 'Raw Diff.' column is the sum of the difference vectors of the misranked pairs.
%h3 Weight updates
%table.sortable.updated
%thead
%tr
%th Feature
%th Before
%th After
%th Diff.
%th Raw diff.
%th Rate
%tbody
- if pairwise_ranking_data["update_raw"]
- raw_update = SparseVector.from_kv(pairwise_ranking_data["update_raw"])
- pairwise_ranking_data["weights_before"].default = 0
- pairwise_ranking_data["weights_after"].keys.each.sort { |a,b| a <=> b }.each do |k|
- diff = pairwise_ranking_data["weights_after"][k] - pairwise_ranking_data["weights_before"][k]
- if diff != 0.0
%tr
%td.left #{k}
%td.right #{"%+.3f" % pairwise_ranking_data["weights_before"][k]}
%td.right #{"%+.3f" % pairwise_ranking_data["weights_after"][k]}
- rdiff = diff.round 3
- if diff < 0
%td.right.red #{rdiff}
- elsif diff > 0
%td.right.green #{rdiff}
%td.right #{"%+.1f"%(raw_update[k])}
%td.right
- if pairwise_ranking_data["learning_rates"].has_key? k
#{pairwise_ranking_data["learning_rates"][k].round 10}
- elsif k.start_with? "R:"
#{pairwise_ranking_data["learning_rate_R"].round 10}
- elsif k.start_with? "RBS:" or k.start_with? "RBT:"
#{pairwise_ranking_data["learning_rate_RB"].round 10}
- elsif k.start_with? "Shape_"
#{pairwise_ranking_data["learning_rate_Shape"].round 10}
- else
ERROR: unknown key #{k}
%p
%a{ :onclick => "$('#features_expl').toggle()" } Explanations
%table#features_expl{ :style => "display:none" }
%tr
%td EgivenFCoherent
%td.left -log10[ c(e, f) / sample c(f) ]
%tr
%td NewRule
%td.left New rules extracted from post-edits (this is the only feature of those rules)
%tr
%td KnownRule
%td.left Added to already existing rules if they could be also be extracted from post-edits
%tr
%td OOVFix
%td.left Manually added rules for OOV items
%tr
%td Glue
%td.left Absolute number of rules used from glue grammar
%tr
%td IsSingletonF/E
%td.left true|false (1|0) (sum)
%tr
%td IsSingletonFE
%td.left true|false (1|0) (sum)
%tr
%td LanguageModel
%td.left -log10[ score ]
%tr
%td LanguageModel_OOV
%td.left Absolute count of OOV unigrams
%tr
%td MaxLexFgivenE
%td.left Sum_f -log10(maxScore) (maxScore = max_e(ttable(f))
%tr
%td MaxLexEgivenF
%td.left Sum_e -log10(maxScore) (maxScore = max_f(ttable(e))
%tr
%td PassThrough
%td.left Absolute count of applied PassThrough rules
%tr
%td SampleCountF
%td.left log10 [ sample c(f) ]
%tr
%td WordPenalty
%td.left log_10(e)*|e| = 1/log(10) * |e| (*-1) = -0.43429448190325176*|e|
%tr
%td SourceWordPenalty
%td.left As WordPenalty (|e| <=> |f|)
%tr
%td R:*
%td.left Rule indicator features (sum of rule applications)
%tr
%td Shape_*
%td.left Indicator features for rule shapes (39 in total)
/=%tr
/= %td IsSupportedOnline
/= %td.left Rules with support from local context (added by Denkowski's online suffix array extractor)
%p.up
%a{ :href => "#" } ^ up
/=#########################################################################
%h2#kbest K-best list
%p
Notes:
%span.red In red:
%span Update needed, i.e. "any of the above hypotheses has a lower model score" (if the list is ordered by BLEU score in descending order).
%table.sortable.updated
%thead
%tr
%th.center{:style => "width:5%"} Rank
%th.center{:style => "width:5%"} BLEU score
%th.center{:style => "width:5%"} Model score
%th.center{:style => "width:5%"} Original rank
%th.center{:style => "width:5%"} Token count
%th.center{:style => "width:75%"} Translation
%tbody
- kbest = []
- pairwise_ranking_data["kbest"].each { |i| x=splitpipe(i); kbest << [ x[0].to_f, x[1].to_f, x[2].to_i, x[3], x[4] ] }
- kbest.sort! { |i,j| j[0] <=> i[0] }
- kbest.each_with_index do |k,j|
- add_class = ""
- if kbest[0,j].map { |l| l[0]>k[0] && l[1] "#{add_class}"}
%td.center #{j+1}
%td.center #{"%.2f"%(k[0].to_f*100)}
%td.center #{k[1]}
%td.center #{k[2]+1}
%td.center #{k[4].split.size}
%td
%p #{k[4]}
%p.toggle
%a.tiny Features
%table.kbest_features.small.mono.black{:style => "display:none"}
%tr
%th Feature
%th Value
- k[3].split.sort.each do |i|
- k,_,v = i.rpartition "="
%tr
%td #{k}
%td #{v}
%p.up
%a{ :href => "#" } ^ up