Lign/CSE 256, Programming Assignment 1: Language Models

Similar documents
Please note that some of the resources used in this assignment require a Stanford Network Account and therefore may not be accessible.

CS 288: Statistical NLP Assignment 1: Language Modeling

CS 124/LING 180/LING 280 From Languages to Information Week 2: Group Exercises on Language Modeling Winter 2018

CS159 - Assignment 2b

Project Collaboration

LSA 354. Programming Assignment: A Treebank Parser

Smoothing. BM1: Advanced Natural Language Processing. University of Potsdam. Tatjana Scheffler

CS 051 Homework Laboratory #2

CMPSCI 187 / Spring 2015 Sorting Kata

Scalable Trigram Backoff Language Models

For Volunteers An Elvanto Guide

Important Project Dates

Proofwriting Checklist

CMPSCI 187 / Spring 2015 Hangman

CMSC 201 Spring 2018 Project 3 Minesweeper

CS 188: Artificial Intelligence Fall 2011

CS 224N: Assignment #1

Writing Cover Letters

Question 1: knn classification [100 points]

CSE 143: Computer Programming II Winter 2019 HW6: AnagramSolver (due Thursday, Feb 28, :30pm)

- 1 - Handout #33 March 14, 2014 JAR Files. CS106A Winter

CS 553 Compiler Construction Fall 2007 Project #1 Adding floats to MiniJava Due August 31, 2005

CMPSCI 187 / Spring 2015 Hanoi

CS 553 Compiler Construction Fall 2009 Project #1 Adding doubles to MiniJava Due September 8, 2009

The name of our class will be Yo. Type that in where it says Class Name. Don t hit the OK button yet.

Project 1 Balanced binary

Handout 4: Version Control Reference

Script.byu.edu SharePoint Instructions

Introduction to Programming

Natural Language Processing

Intro. Scheme Basics. scm> 5 5. scm>

Due: 9 February 2017 at 1159pm (2359, Pacific Standard Time)

UMass CS690N: Advanced Natural Language Processing, Spring Assignment 1

Written Communication

The Dynamic Typing Interlude

Karlen Communications Track Changes and Comments in Word. Karen McCall, M.Ed.

Getting Started with Eclipse/Java

Business Writing In English

Moodle Tutorial. Tak Auyeung. April 5, 2006

Due: March 8, 11:59pm. Project 1

Barchard Introduction to SPSS Marks

Manage Duplicate Records in Salesforce PREVIEW

Heart and Stroke Foundation CIRCUlink

CS 224d: Assignment #1

Installing Dolphin on Your PC

2019 Referee Recertification Instructions (All Grades)

Barchard Introduction to SPSS Marks

Java Program Structure and Eclipse. Overview. Eclipse Projects and Project Structure. COMP 210: Object-Oriented Programming Lecture Notes 1

CMPSCI 187 / Spring 2015 Postfix Expression Evaluator

BIOL591: Introduction to Bioinformatics Alignment of pairs of sequences

CS 4349 Lecture August 21st, 2017

Nearest Neighbor Classification

LANGUAGE MODEL SIZE REDUCTION BY PRUNING AND CLUSTERING

Detection and Extraction of Events from s

Making a PowerPoint Accessible

Assignment 3 ITCS-6010/8010: Cloud Computing for Data Analysis

EECS 496 Statistical Language Models. Winter 2018

CS 343: Artificial Intelligence

CSC209. Software Tools and Systems Programming.

CIS220 In Class/Lab 1: Due Sunday night at midnight. Submit all files through Canvas (25 pts)

CS451 - Assignment 8 Faster Naive Bayes? Say it ain t so...

Network Administration/System Administration (NTU CSIE, Spring 2018) Homework #1. Homework #1

CS 224N: Assignment #1

CS350 : Operating Systems. General Assignment Information

Orientation Assignment for Statistics Software (nothing to hand in) Mary Parker,

CSC209. Software Tools and Systems Programming.

Lecture 14: Exceptions 10:00 AM, Feb 26, 2018

Programming Assignment 3

Essbase Installation Tutorial Tim Tow, President and Oracle ACE Director. Applied OLAP, Inc

Lab 1: Silver Dollar Game 1 CSCI 2101B Fall 2018

Artificial Intelligence Naïve Bayes

Principles of Algorithm Design

Programming Assignment III

CS 188: Artificial Intelligence Fall Machine Learning

Programming assignment A

Public Meeting Agenda Formatting Best Practices

Business Letter. Assignment

Hands on Assignment 1

Introduction to Programming Style

User Manual. Version 1.0. Submitted in partial fulfillment of the Masters of Software Engineering degree.

Project #1: Tracing, System Calls, and Processes

Project 6: Assembler

Note: This is a miniassignment and the grading is automated. If you do not submit it correctly, you will receive at most half credit.

Welcome to the Contra Costa Community College District and InSite

Student Success Guide

Natural Language Processing

Learner. Help Guide. Page 1 of 36 Training Partner (Learner Help Guide) Revised 09/16/09

QUIZ. Source:

9.2 Linux Essentials Exam Objectives

1. Welcome. (1) Hello. My name is Dr. Christopher Raridan (Dr. R). (3) In this tutorial I will introduce you to the amsart documentclass.

Understanding Recursion

Programming Assignment 3

Sams Teach Yourself Java 2 in 21 Days, Fourth Edition. Copyright 2004 by Sams Publishing. International Standard Book Number:

Divisibility Rules and Their Explanations

How to build Simbody 2.2 from source on Windows

Web Site Documentation Eugene School District 4J

Homework 2: Parsing and Machine Learning

Laboratory 1: Eclipse and Karel the Robot

CHAPTER 18: CLIENT COMMUNICATION

Note: This is a miniassignment and the grading is automated. If you do not submit it correctly, you will receive at most half credit.

Transcription:

Lign/CSE 256, Programming Assignment 1: Language Models 16 January 2008 due 1 Feb 2008 1 Preliminaries First, make sure you can access the course materials. 1 The components are: ˆ code1.zip: the Java source code provided for this course, at http://grammar.ucsd. edu/courses/lign256/protected/code1.zip ˆ data1.zip: the data sets used in this assignment, at http://grammar.ucsd.edu/ courses/lign256/protected/data1.zip I have emailed out the username and password for accessing this code to everyone enrolled in the class. Please contact me if you haven t received this information. In addition, on your computer(s) you ll need a version of the Java Development Kit (JDK), which you can get from here: http://java.sun.com/javase/downloads/?intcmp=1281 Unzip the source files to your local working directory. Some of the classes and packages won t be relevant until later assignments, but feel free to poke around. Make sure you can compile the entirety of the course code without errors (if you get warnings about unchecked casts, ignore them that s a Java 1.5 issue; if you cannot get the code to compile, please email me, stop by office hours, or post to the mailing list). If you are at the directory containing the src and classes directories, you can compile the provided code with javac -d classes src/*/*/*/*.java src/*/*/*/*/*.java You can then run a simple test file by typing java -cp classes edu.berkeley.nlp.test 1 This assignment is a minor adaptation of an assignment put together by Dan Klein. Many thanks to Dan for his permission to use this assignment, the code, and the datasets. 1

You should get a confirmation message back. You may wish to use an integrated development environment (IDE) such as Eclipse, available for free at http://www.eclipse.org/ downloads/ (this is recommended). If so, it is expected that you be able to set it up yourself. The majority of the students in the class are experienced in Java programming. If you are not, I highly recommend that you plan on collaborating with one of the more experienced students, to facilitate your own learning. Next, unzip the data into a directory of your choice. For this assignment, the first Java file to inspect is: src/edu/berkeley/nlp/assignments/languagemodeltester.java Try running it with: java -cp classes edu.berkeley.nlp.assignments.languagemodeltester -path DATA -model baseline where DATA is the directory containing the contents of the data zip. If everything s working, you ll get some output about the performance of a baseline language model being tested. The code is reading in some newswire and building a basic unigram language model that I ve provided. This is a phenomenally bad language model, as you can see from the strings it generates you ll improve on it. 2 Description In this assignment, you will construct several language models and test them with the provided harness. Take a look at the main method of LanguageModelTester.java, and its output. Preliminaries: The language model you construct should be open-vocabulary. You can choose the vocabulary list, but see below under Training regarding what the word list should contain. Please state how you define your vocabulary list, and stick to a single list for the entire assignment. Training: Several data objects are loaded by the harness. First, it loads about 1M words of WSJ text (from the Penn treebank, which will appear again later in class). These sentences have been speechified, for example translating $ to dollars, and tokenized for you. The WSJ data is split into training data (80%), validation (held-out) data (10%), and test data (10%). In addition to the WSJ text, the harness loads a set of speech recognition problems (from the HUB data set). Each HUB problem consists of a set of candidate transcriptions of a given spoken sentence. For this assignment, the candidate list always includes the correct transcription and never includes words seen less than twice in the WSJ training data. You should make sure that every word appearing in candidate list appears on your vocabulary list (hence your list must minimally consist of all words appearing at least twice in the training set, though you are welcome to use a larger list if you like). Each candidate transcription is accompanied by a pre-computed acoustic score, which represents Linguistics/CSE 256 programming assignment 1, page 2 Roger Levy, Winter 2008

the degree to which an acoustic model matched that transcription. These lists are stored in SpeechNBestList objects. Once all the WSJ data and HUB lists are loaded, a language model is built from the WSJ training sentences (the validation sentences are ignored entirely by the provided baseline language model, but may be used by your implementations for tuning). For simplicity, all words are automatically converted to lower case (so don t worry about this). Then, several tests are run using the resulting language model. Evaluation: Each language model is tested in two ways. First, the harness calculates the perplexity of the WSJ test sentences. In the WSJ test data, there will be unknown words. Your language models should treat all entirely unseen words as if they were a single UNK token. This means that, for example, a good unigram model will actually assign a larger probability to each unknown word than to a known but rare word this is because the aggregate probability of the UNK event is large, even though each specific unknown word itself may be rare. To emphasize, your model s WSJ perplexity score will not strictly speaking be the perplexity of the extact test sentences, but the UNKed test sentences (a lower number). Second, the harness will calculate the perplexity of the correct HUB transcriptions. This number will, in general, be worse than the WSJ perplexity, since these sentences are drawn from a different source. Language models predict less well on distributions which do not match their training data. The HUB sentences, however, will not contain any unseen words. Third, the harness will compute a word error rate (WER) on the HUB recognition task. The code takes the candidate transcriptions, scores each one with the language model, and combines those scores with the pre-computed acoustic scores. The best-scoring candidates are compared against the correct answers, and WER is computed. The testing code also provides information on the range of WER scores which are possible: note that the candidates are only so bad to begin with (the lists are pre-pruned n-best lists). You should inspect the errors the system is making on the speech re-ranking task, by running the harness with the -verbose flag. Finally, the harness will generating sentences by randomly sampling your language models. The provided language model s outputs aren t even vaguely like well-formed English, though yours will hopefully be a little better. Note that improved fluency of generation does not mean improved modeling of unseen sentences. Experiments: You will implement at least two language models, though you can choose which specific ones to try out. To implement a language model, you need to do two things: 1. Write a class that implements the edu.berkeley.nlp.langmodel.languagemodel interface; such a class needs two methods: ˆ getsentenceprobability(list<string> sentence), which returns the joint probability (not log-probability) of a sentence as a double; ˆ generatesentence(), which returns a randomly generated sentence as a List of words, each of which is a String. An example of how to implement this is the class Linguistics/CSE 256 programming assignment 1, page 3 Roger Levy, Winter 2008

edu.berkeley.nlp.assignments.empiricalunigramlanguagemodel. You might want to start by reading that class carefully to understand how it implements a unigram language model. 2. fill in the TODO and preceding lines in the edu.berkeley.nlp.assignments.languagemodeltester class (the if statements with your model here in the test statement) such that passing -model XXX for your choice of XXX will cause your new language model(s) to be constructed. The LanguageModelTester harness will do the rest for you. Along the way you must build the following: ˆ Either a Katz or Kneser-Ney estimator (bigram ok) ˆ A trigram (or higher order) model which uses an interpolation method of your choice ˆ A method which makes some use of the held-out data set Note that if you build, for example, a Kneser-Ney trigram model with all hyperparameters tuned automatically on the held-out data, you re technically done, though it will be more instructional to build up models of increasing complexity. While you are building your language models, it may be that lower perplexity, especially on the HUB sentences, will translate into a better WER, but don t be surprised if it doesn t. The actual performance of your systems does not directly impact your grade on this assignment, though I will announce students who do particularly interesting or effective things. The most important determinant of your grade for the assignment is the degree to which you can present what you did clearly and make sense of what s going on in your experiments using thoughtful error analysis. When you do see improvements in WER, where are they coming from, specifically? Try to localize the improvements as much as possible. Some example questions you might consider: Do the errors that are corrected by a given change to the language model make any sense? Are there changes to the models which substantially improve perplexity without improving WER? Do certain models generate better text? Why? Similarly, you should do some data analysis on the speech errors that you cannot correct. Are there cases where the language model isn t selecting a candidate which seems clearly superior to a human reader? What would you have to do to your language model to fix these cases? For these kinds of questions, it s actually more important to sift through the data and find some good ideas than to implement those ideas. The bottom line is that your write-up should include concrete examples of errors or error-fixes, along with commentary. Linguistics/CSE 256 programming assignment 1, page 4 Roger Levy, Winter 2008

2.1 Collaboration I highly encourage team collaboration in the programming portion of the assignment; however, each student should submit their own writeup. One way to collaborate might be to divide and conquer: each member of the collaboration has the job of implementing one choice of language model, the other members inspect their teammates work, and the team discusses the overall set of results together. There are other ways of doing collaboration, of course. Also be careful about collaborations that are too large: there is nothing inherently wrong with large collaborations (they allow you to cover a larger part of the model space!) but they can easily get unwieldy to organize and maintain. 2.2 Writeup For this assignment, you should turn in a write-up of the work you ve done, but not the code (it is sometimes useful to mention code choices or even snippets in write-ups, and this is fine). The write-up should specify what models you implemented and what significant choices you made. It should include tables or graphs of the perplexities, accuracies, etc., of your systems. It should also include some error analysis enough to convince me that you looked at the specific behavior of your systems and thought about what it s doing wrong and how you d fix it. There is no set length for write-ups, but a ballpark length might be 3-4 pages, including your evaluation results, a graph or two, and some interesting examples. I m more interested in knowing what observations you made about the models or data than having a reiteration of the formal definitions of the various models. In the case of collaborations, the team should submit a brief statement of who did what work. 2.3 Miscellaneous advice You are likely to build a model that requires you to allocate larger amounts of memory to Java than the default. To do this, pass the argument -mx<n>m to java (i.e., next to the -cp argument and before the class name), where <N> is the number of megabytes you wish to allocate. In edu.berkeley.nlp.util there are some classes that might be of use particularly the Counter and CounterMap classes. These make dealing with word to count and history to word to count maps much easier. General advice regarding implementing models: it s often said that laziness is a virtue in programming. One way of interpreting this maxim with respect to implementing models is don t rush to implement a model that you don t yet understand fully. I personally find that it (a) is ultimately more time-efficient, and (b) leads to better code, to carefully work out simple cases for your model on paper before starting to write code. The tiny-corpus Kneser-Ney model I showed on the board at the end of class Wednesday is an example of how this might be done for KN smoothing. You can even include these simple worked-out cases in your writeup (in fact, this is encouraged.) Make sure you understand the model Linguistics/CSE 256 programming assignment 1, page 5 Roger Levy, Winter 2008

completely! Otherwise you might find yourself retracing your steps all too often in the coding process. Linguistics/CSE 256 programming assignment 1, page 6 Roger Levy, Winter 2008