summaryrefslogtreecommitdiff
path: root/views/debug.haml
blob: 45cb5983b3c81e83b34523e45bb6b0533c0ebf99 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
- require 'zipf'
!!!
%html
  %head
    %title debug view (for session ##{session_key})
  %link(rel="stylesheet" type="text/css" href="debug.css")
  %body
    %h1 debug view
    %p (for session ##{session_key})
    %p
      %a{:href => "/reset", :target => "_blank"} reset progress,
      %a{:href => "/reset_weights", :target => "_blank"} reset weights,
      %a{:href => "/reset_extractor", :target => "_blank"} reset extractor,
      %a{:href => "/shutdown", :target => "_blank"} shutdown,
      %span learning rate
      %select
        - [1000,100,10,1,0.1,0.01,0.001,0.0001,0.00001,0.000001].each do |i|
          %option{:value => i, :onclick => "window.open(\"http://\"+window.location.host+\"/set_learning_rate/#{i}\");"} #{i}
      %span , learning rate (sparse)
      %select
        - [1000,100,10,1,0.1,0.01,0.001,0.0001,0.00001,0.000001].each do |i|
          %option{:value => i, :onclick => "window.open(\"http://\"+window.location.host+\"/set_sparse_learning_rate/#{i}\");"} #{i}
    %table
      %tr
        %td.noborder
          %strong source:
        %td.left #{data["source"]}
      %tr
        %td.noborder
          %strong post-edit:
        %td.left #{data["target"]}
      %tr
        %td.noborder
          %strong original mt:
        %td.left #{data["1best"]}
      %tr
        %td.noborder
          %strong best match (bleu=#{data["best_match_score"]}):
        %td.left #{data["best_match"]}
    %h2 meta
    %p <strong>k:</strong> #{data["samples_size"]}
    %p <strong>number of updates:</strong> #{data["num_up"]}
    %p <strong>updated features:</strong> #{data["updated_features"]}
    %p <strong>learning rate:</strong> #{data["learning_rate"]}
    %p <strong>learning rate (sparse):</strong> #{data["learning_rate_sparse"]}
    %h2 k-best
    %p bleu | model score | original rank | \|e\| | translation \n features
    %p.red update needed
    %ol
      - kbest = []
      - 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|
        - b = kbest[0,j].map { |l| l[0]>k[0] && l[1]<k[1] }.include? true
        -if b
          %li.red
            %strong #{"%.2f"%(k[0].to_f*100)} | #{k[1]} | #{k[2]} | #{k[4].split.size} |#{k[4]} <br/>
            %p{:style=>"font-size:80%"} #{k[3]}
        - else
          %li
            %strong #{"%.2f"%(k[0].to_f*100)} | #{k[1]} | #{k[2]} | #{k[4].split.size} | #{k[4]} <br/>
            %p{:style=>"font-size:80%"} #{k[3]}
        - if [9,89].include? j
          %hr
    %h2 weight updates
    %table
      %tr
        %th feature
        %th before
        %th after
        %th diff
        %th raw diff
      - data["weights_before"].default = 0
      - data["weights_after"].keys.each.sort { |a,b| a[0] <=> b[0] }.each do |k|
        %tr
          %td.noborder <strong> #{k} </strong>
          %td #{"%+.3f"%data["weights_before"][k].round(4)}
          %td #{"%+.3f"%data["weights_after"][k].round(4)}
          - diff = data["weights_after"][k]-data["weights_before"][k]
          - if diff < 0
            %td.red #{"%+.3f"%(diff).round(4)}
          - elsif diff > 0
            %td.green #{"%+.3f"%(diff).round(4)}
          - else
            %td #{"%+.3f"%(diff).round(4)}
          - if !k.start_with? "R:"
            %td #{"%+.1f"%((data["weights_after"][k]-data["weights_before"][k])/data["learning_rate"]).round(2)}
          - else
            %td #{"%+.1f"%((data["weights_after"][k]-data["weights_before"][k])/data["learning_rate_sparse"]).round(2)}
    %h3 dense features explained
    %table
      %tr
        %td.noborder EgivenFCoherent (TM)
        %td.left -log10[ c(e, f) / sample c(f) ]
      %tr
        %td.noborder Glue
        %td.left absolute number of rules used from glue grammar
      %tr
        %td.noborder IsSingletonF/E (TM)
        %td.left true|false (1|0) (sum)
      %tr
        %td.noborder IsSingletonFE (TM)
        %td.left true|false (1|0) (sum)
      %tr
        %td.noborder LanguageModel
        %td.left -log?[ score ]
      %tr
        %td.noborder LanguageModel_OOV
        %td.left abs. count of OOV unigrams
      %tr
        %td.noborder MaxLexFgivenE (TM)
        %td.left Sum_f -log10(maxScore) (maxScore = max_e(ttable(f))
      %tr
        %td.noborder MaxLexEgivenF (TM)
        %td.left Sum_e -log10(maxScore) (maxScore = max_f(ttable(e))
      %tr
        %td.noborder PassThrough
        %td.left absolute count of used PassThrough rules (1 per word)
      %tr
        %td.noborder SampleCountF
        %td.left log10 [ sample c(f) ]
      %tr
        %td.noborder WordPenalty
        %td.left log_10(e)*|e| = 1/log(10) * |e| (*-1) = -0.43429448190325176*|e|
      %tr
        %td.noborder SourceWordPenalty (per edge/rule)
        %td.left ^^^ (|e| <=> |f|)
      %tr
        %td.noborder R:*
        %td.left rule indicator features, sum over full derivation per rule