- 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
%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.tiny Session: ##{session_key}
/=#########################################################################
%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_new_rules", :href => "#controls"} Reset new rules
%li
%a.ajax{:tgt => "/shutdown", :href => "#controls"} Initiate shutdown
%h3 Learning rates & weights
%p Set default weight or rate for specific features:
%select#features_type
%option{ :value => "/set_weights" } Weight
%option{ :value => "/set_learning_rates" } Rate
%input#features{ :value => "Feature", :style => "text-align:center; width:20em" }
%input#features_value{ :value => "1e-05", :style => "text-align:right; width:5em" }
%button#set_features
Set
%p Set rate for feature groups:
%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:5em" }
%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 MT Input:
%td.left.noborder #{data["source_segments"][[0,progress].max]}
%tr
%td.noborder
%strong Raw source:
%td.left.noborder #{data["raw_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 #{pairwise_ranking_data["best_match"]}
%h3 Metadata
%p K: #{pairwise_ranking_data["samples_size"]}
%p Number of updates: #{pairwise_ranking_data["num_up"]}
%p Updated features: #{pairwise_ranking_data["updated_features"]}
%p Duration: #{data["durations"][progress]}ms
%p Updated: #{data["updated"][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
%h3
New Rules
%p Including OOV fixes.
%table.sortable
%thead
%th Source
%th
%th Target
%tbody
- additional_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
- rejected_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 N.B. that updates are only done if the post-edit is different from the original 1-best output of the decoder.
%h3 Weight updates
%table.sortable
%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').toggle()" } Explanations
%table#features{ :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 (Denkowski)
%p.up
%a{ :href => "#" } ^ up
/=#########################################################################
%h2#kbest K-best list
%p
%span.red In red:
%span Update needed, i.e. "any of the above hypotheses has a lower model score" (in default order).
%table.sortable
%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