Skip to content

LogonModeling

ErikVelldal edited this page Jun 12, 2008 · 25 revisions

Overview

This page contains various code examples showing how to estimate and apply statistical models within LOGON.

Discriminative Modeling

We here assume that the system and the grammar are already loaded.

Set the feature parameters. The defaults correspond to:

(let ((*feature-grandparenting* 4)
      (*feature-active-edges-p* t)
      (*feature-ngram-size* 4)
      (*feature-lm-p* nil)
      (*feature-ngram-back-off-p* t)
      (*feature-ngram-tag* :type)
      (*feature-use-preterminal-types-p* t)
      (*feature-lexicalization-p* t)
      (*feature-constituent-weight* 2)
      (*feature-lm-p* 10)
      (*feature-frequency-threshold* nil))

Create a feature cache for the profile jhpstg.g (we typically use the .g to denote a generation treebank):

(operate-on-profiles (list "jhpstg.g") :task :fc))

Run a single experiment using 5-fold cross-validation:

(setq test "jhpstg-test-profile")
(tsdb :create test :skeleton "jhpstg")
(rank-profile gold
              test
              :nfold 5)

Run batch grid of 10-fold maxent experiments on "jhpstg.g", iterating through several configurations of parameters:

(batch-experiment :type :mem
                  :variance '(nil 1000 100 10 1 1.0e-1 1.0e-2)
                  :absolute-tolerance 1.0e-10
                  :source "jhpstg.g"
                  :skeleton "jhpstg"
                  :random-sample-size nil
                  :ngram-size '(0 1 2 3)
                  :active-edges-p nil
                  :grandparenting '(0 1 2 3)
                  :counts-relevant 1
                  :nfold 10
                  :compact t
                  :train-percentage nil)

Estimate and export a maxent model:

(let ((*feature-grandparenting* 3)
      (*feature-ngram-size* 3)
      (*feature-lm-p* nil)
      (*maxent-variance* 8e-4)
      (*feature-frequency-threshold* (make-counts :relevant 1)))
  (train "jhpstg.g" "jhpstg.g.mem" :fcp nil :type :mem))

Apply the model trained above to a generation treebank rondane.g:

(tsdb :create "rondane-test-profile"
       :skeleton "rondane")

(operate-on-profiles (list "rondane.g")
                      :model (read-model model)
                      :target "rondane-test-profile"
                      :task :rank)
Clone this wiki locally