hi everyone welcome to economics 2355 my name is Melissa I'm a professor in the economics department and for this course which is on using deep learning methods to process economic data I'm going to be pre-recording these lectures and so our time in class will focus on discussion and everybody should watch these pre-recorded lectures beforehand become familiar with the materials I'm also going to be making these publicly available in the hopes that they might help other economists who are interested in learning how deep learning methods may be relevant for their research I know it's a bit
weird for me to be sitting here just talking to the computer we're going to go with it and see how this flip format works for the course this year so let's delve right in this is the introductory lecture and broadly speaking the motivation for this course is that deep learning has revolutionized the processing of unstructured data and by unstructured data I mean things like text images audio and video These are types of data that would not be computable in their raw format and this has in turn transformed a variety of disciplines ranging from things like
allowing NASA to land a Rover on rugged Martian terrain to changing how doctors diagnose disease so while there have been a lot of efforts within economics to incorporate machine learning methods into econometric toolkits for processing structured data deep learning methods have been used less frequently to process unstructured data and economics than they have been in many other disciplines and so if you're working with structured data you want to do econometric analyzes you're not generally going to use deep learning for that there's machine learning methods that are well suited to those applications those are not the
focus of this course what we are going to focus on on in this course is using deep learning deep neural networks and we'll talk about what that means subsequently to be able to take unstructured data and convert it into a format that is computable that you can use for your Downstream analyzes this is also not a course that's going to be about econometrics we'll talk a little bit about inference but by and large in this entire literature you will not see a standard error but really what it's about is taking this information say taking a
a text taking a picture taking a video taking the satellite image which in its raw format you cannot use in your analyzes and encoding that into something that is suitable for whatever Downstream task whatever Downstream analysis you might want to perform and so there's massive quantities of non-computable data that could power economic analyzes if they were converted into a computable format so let me give some examples libraries and archives have scanned literally billions of pages of historical documents um those are in the format of image scans which is essentially a series of x coordinates Y
coordinates and pixel values RGB values um you can't take that and import that into R and run of regression but if you were to take that image and convert it into structured tabular data then that could power your Downstream analyzes data can also be tracked in other types of images things like Satellite photographs or aerial photographs a text contains massive amounts of unstructured information audio and video as well and while the raw information is very different um say between text versus an image the Deep learning methods to convert these into computable information are very closely
related often drawing on the same underlying in architectures all right so generally speaking there are two distinct approaches to processing unstructured data you could write a set of instructions that tells the computer how to process the data by defining a series of rules um and so in the case of digitizing tables you might tell the computer how to detect its layouts by telling it to look for connected white pixels that separate rows and separate columns I'm learning how to you know on the other hand instead of writing the rules that tells the computer what to
look for um you could let the computer learn how to process the data by showing in empirical examples and this is what deep learning does the model learns in this example that I gave to detect layouts by seeing annotated examples of what a table layout is um and so rule-based approaches have the advantage of being easy to understand most of us are used to interacting with computers via rules they certainly have their place but they oftentimes perform poorly both in computer vision tasks analyzing image data as well as in natural language processing application patients complexity
and noise in general are the enemies of rules and unstructured economic data tends to be right with complexity and noise so in the example I gave where you're trying to detect white space that separates columns and rows suppose that your scan is a little bit skewed or a little bit warped that might throw off your rule and you'll need to write an exception to the rule or suppose that there is ink lead um that again could throw off on the rules that you've written and you can go down this really deep Rabbit Hole of writing
exceptions to the exceptions to the exceptions even if at the end of the day you're able to process the particular set of documents or data that you set out to process that pipeline that you designed is not going to apply to anything else because you've hard-coded so many things into it and so what deep learning does is to learn a robust mapping between the input and the desired output and so you can think of deep learning as an incredibly powerful Universal function approximator um in many economic applications the inputs would be things like um images
um so x coordinate y coordinate RGB value at the pixel level or they might be tokenized text um and you take um text and um convert it into a series of vectors and the output is often some high dimensional dense Vector representation or encoding that powers Downstream analyzes so what I mean by dense factor is that the positions of that Vector are non-zero and so the deep and deep learning comes from the many layers in the neural network that Maps the inputs to the outputs on these models typically entail tens of millions to tens of
billions of learn parameters um the first question you might have is what is a neural network if you're not familiar with what a neural network is um on the web page where you found this lecture or on the syllabus you'll see links to a lot of really great resources um one of my favorites is by Grant Sanderson or known as three blue one brown um on YouTube and he has these wonderful visual introduction to a neural network and how you optimize in neural networks there's in short there's tons of resources out there I'm going to
assume from this point forward that you're familiar with what a neural network is and so in deep learning the neural network has many many layers and that network is going to map your inputs to the outputs um and obviously you know for this to be something you need um there needs to be a pretty complex mapping between the inputs and the outputs which is certainly the case with unstructured data like images or text um okay and so you might be asking now how is this feasible um first of all how do we have enough data
and economics to estimate a model that has you know tens of millions to even billions of parameters um and the reason you know why oftentimes we do have enough data is that we use something called transfer learning to leverage pre-trained models um so um you may start with a pre-trained language model and um an entity like Google or Facebook may have spent millions of dollars of compute pre-training that language model on a massive Corpus of text that comes from like all the public domain texts on the internet and so this model already basically understands how
language works but it might not understand kind of the idiosyncrasies of your task or of your data and so you can take that model and maybe it does good enough off the shelf I'd say in our applications typically we find that models don't typically do as well as we would like off the shelf even if they kind of have okay performance but with a modest number of labeled examples you can take this pre-trained model which has been made publicly available and you can tune it to your novel setting with a fairly modest amount of labeled
data and so we're going to see over and over again sort of examples of transfer learning in the course it's actually incredibly rare I think that as an economist you would train a deep neural network completely from scratch um because even if you had a massive label data set um it's a lot of compute and most of us don't have access to kind of those kinds of compute resources but fortunately this field is pretty open um and in both kind of the vision space on the language space um there's great pre-trained models that are out
there and that exist um second you might say well how do you optimize a complicated non-linear function with Millions to billions of parameters and that's going to be a focus of this course because if you want to be serious about using deep learning methods and your research I think it's pretty important to understand what's going on under the hood because otherwise it's going to be difficult to know how to apply these methods appropriately all right um so Computing has a long history in economics on the Advent of personal Computing in the 1990s really revolutionized the
discipline it went from being highly theoretical to much more empirical um and I'd argue that today advances in GPU compute and the availability of cheap Cloud compute again have the potential to transform the types of data and questions that economists can study and so GPU compute is important to be able to um estimate these kind of very large deep learning models and then with cheap Cloud compute you can take them and apply them to kind of millions and millions of images for example in parallel on the cloud for a reasonably modest amount of money you
know I've you know spent months running a thousand virtual CPUs on Azure in parallel I'm not going to have a thousand CPUs in my office but they can be rented on the cloud for a fairly modest amount of resources okay um so broadly speaking deep learning transforms the ability to process unstructured economic data in two ways it allows us to unlock traditional sources of data um where people have used that type of data before typically they would have manually digitized that information but it's not feasible in your context because of the scale of the problem
um so this would be things like digitizing tables um moreover it can allow us to change the types of information that can be converted into structured data so things that we wouldn't have even thought of as a data source before could become a data source if we have the methods to take them and to process them forward on stream tasks and so today I'm going to briefly provide an example of each of these types of applications okay so first of all processing traditional data sources at scale so many Central questions in economics such as thinking
about misallocation inequality social Mobility required disaggregated data you're going to have a hard time thinking about inequality between individuals if you only have aggregated data yet it's quite rare to have Digital disaggregated Data over long periods and the data that do exist are overwhelmingly from a few High resource contexts many of those contexts are concentrated in historical us and historical Europe I have a long-standing interest in East Asia's spectacular growth performance in the 20th century but efforts you know that I made to try to understand it better with more aggregated data so things even like
municipal or county level data were unsatisfactory because I felt like I really needed individual like firm level data to know what was going on and so when I first got interested in this I thought well maybe you don't see these data you as much because they don't exist um actually they do exist incredibly Rich from an individual level data stretching back to the early 20th century um exists in incredibly Rich form for Japan um yet there's nearly 16 000 uh kanji Japanese characters um and so manual digitization even if you get a Japanese you know
history PhD student to do it tends to be quite inaccurate because there's so many characters and most of them aren't in use today anymore and moreover the data are vast um and so there's just not the human capital to be able to digitize it by hand even if you had vast resources which I don't um and um people might say well take a sample but as we know um from many questions such as questions involving networks um taking a sample could lead to biases and so this is an example of firm level data from Japan
these data are from 1957 and they contain information about the board members the shareholders the firms the Personnel the balance sheets Etc and so this is what the raw input would look like this is a scan of a page of the book you know there's thousands and thousands of these pages and then you have the books from multiple years and so all together you have tens or even hundreds of thousands of pages that look like this okay so you're never going to digitize this by hand even if you try to just digitize a little bit
by hand it'll be a huge pain because there's going to be a lot of mistakes um we want to do things like tracing people across time people's names have a few characters if you get one of them wrong you're not going to be able to trace that person across time and so in short you need a super high quality digitization of this and it needs to be automated um and so kind of stacking stepping back more generally this is an example of document image analysis and so we have some document inputs and then we're going
to have some kind of Pop pipeline um and we want to produce structured output with that that you can then take and you know import to statistical software um and do your Downstream economic analyzes with and so um you know when I started working on this there was really no full-fledged infrastructure for easily curating document image data sets and fine-tuning or retraining uh the models to recognize the layouts of these documents um the relevant resources to the extent they did exist were in different repositories and used inconsistent back-ends and apis and so just to give
an example maybe you needed to do some pre-processing and you could find something kind of helpful to do that in Java but then to do the layout detection you're going to need to use Pi torch and to do character recognition maybe you use Tesseract and call that with C plus and then you need to do some post-processing maybe you decide to do that in Matlab and then you also need to store the data and so as you can see this is convoluted it's not going to be very reproducible for most people it's not going to
be very accessible to people who don't have a pretty strong programming background and so what I did was to work with my pre-doctoral fellows as a jinxin in particular who really took a lead on this prior project Jake Carlson um and open source collaborators to integrate on the models and tools that we were working on into an open source package called layout parser and so the aim of layout parser is to streamline the use of deep learning in document image analysis pipelines also being able to take documents and extract their layouts um which you're going
to need to automate the digitization of those documents layout parser provides simple and intuitive interfaces for applying and customizing deep learning models for layout detection and other document processing tasks um so we aim to make it as simple and comprehensible customizable extensible as possible and it's also open source so layout parser has an off-the-shelf toolkit for applying deep learning models for lab detection character recognition and other tasks this is supported by a repository of pre-trained neural network models that underlie the off-the-shelf usage it also has tools for data annotation and model tuning to support different
levels of customization if your documents look different than the documents that the pre-trained models are for which they probably will you'll need to customize your own model and it has tools to do that and then a model Hub and the library is implemented with simple python apis so it's straightforward to install I will say if you want to install it um please use Google collab definitely do not use Windows don't use Windows to do anything in deep learning just do not do not try that the resolving dependencies can be pretty involved and you will just
make your life easier um by by using colab and so this is an example of using layout parser off the shelf to recognize the document layouts of this PDF um and so let me break down a little bit more detail what this code is doing we're going to specify the model configuration which consists of a training data set name and so the model is trained on empirical examples remember that what's deep learning does in this case it was Trend in a document called public net which has PDFs PDF articles um and um and then there's
the model architecture name in this case this is using something called mask or CNN with 50 layers um in the neural network um the model initialization which has a back end in this case it's using detectron 2 which is a backend from uh from Facebook and then you have the standardized model detection API so if you want to make some changes um now I change the model to something called faster rcnn you know we'll talk about what all this means later in the course when we talk about document layout analysis I changed the data set
it was trained onto Primo which is magazines I trained the change the back end to paddle detection which is just another kind of set of software for doing object detection okay so this is an example of our pre-trained model Zoo you know of course your documents may not look like these documents um and so when you're using layout parser you need to ask yourself a few questions on how different is your target data from the pre-trained models what are your accuracy and efficiency requirements and how much training data are available okay so um and kind
of one scenario um your data look a lot like one of the pre-train models and you care about things being efficient well then you can use it off the shelf and you might want to use the efficient back end which may come at some cost in terms of accuracy but will be very cheap to run on the other hand your data might look really different from the pre-trained models um and you might need things to be really accurate which is a common scenario with academic research and there's no label data available in that case you're
going to need um to create some labels um and so kind of we we've bundled um we bundled a layout parser with label Studio but you know by this point you're also probably better off just going and downloading label Studio which is another open source software since it's been kind of updated since then um and you can use it to create kind of the the labels like those that you see on the screen that is telling um telling the model what you want it to learn and so in the case of this newspaper here you
see we've told it to learn individual headlines and articles and pictures and captions and the header of the newspaper all right another thing that we're going to cover is like you might not want to just label at random if you think about um a distribution of different types of layout objects on your page um you know there might be very common objects in the center of your distribution and then your distribution might have long tails and ideally you'd like to have your labels represent that full distribution you don't want to if you just sample that
random you're going to get too many labels from the middle of the distribution which means you're going to waste your your effort creating labels but you already have enough information for the model to learn from and you're not going to have enough labels from the Tails um and so we'll be talking also in this course about Active Learning which is an approach that you know potentially allows you to to um um to make better use of your annotation efforts all right layout parser allows you to call Google Cloud Vision or Tesseract and use them off
the shelf um it allows you um uh as you can see here to visualize your OCR output again you can do that with a few lines of code um it also allows you to export the data to different formats like Json and CSV um and it's built with an API where you can visualize um the document layouts on the original document um and you can visualize the location of the OCR text on the original document and so coming back to the motivating example I gave you these are rows from those Japanese books and you can
see that we use this um to detect um different types of content in the documents we detect different types of columns and then we did to detect different types of segments which are like individual pieces of information and so the red is um title the yellow is address or sorry the pink is address um and then the other pink is variable names the green is variable values the blue is numbers um and this is all done kind of using using layout parser which calls a model called mascar CNN that you know was designed for recognizing
objects in natural images you know so finding cats and dogs and that sort of thing but can be very readily applied to document images to identify different layout objects in your document and we need this information right if you just fed this to OCR you wouldn't know which piece of information was which and so in order to extract the structure from these documents we need to know what's a title what's an address what's a variable name what's a variable value Etc and the layout analysis which is by Deep learning allows us to do that you
know that this pipeline was a particularly challenging one um the Japanese documents um use thousands and thousands of kanji characters most of which are no longer in use and some of which are very similar to each other we try to existing OCR solutions they just did not give us anywhere near the accuracy required for Downstream analyzes um and this is a pretty widespread problem with historical documents and it's especially a widespread problem in historical documents that are not kind of in very high resource languages um like English and other languages using the Latin alphabet when
you kind of extend beyond those the quality tends to deteriorate um and so we thought well um we can um just create some labeled data and we can tune an existing OCR model to this application um but the problem here is that um OCR traditionally uses an architecture that we'll see in the course called sequence to sequence where you jointly learn um uh Vision the visual features of document and a language model and so the problem with this is that it takes a lot of data to jointly learn a language and vision model and um
it's very costly to create the labeled text sequences that we would need for the model to jointly learn the visual appearance of the document as well as how characters are used in sequence to form language um and we just didn't have you know the resources um to create that number of labels and so I worked with um Jake Carlson and Tom Bryan who is the TA for the course to develop a novel character-based OCR um that really comes full circle with how people originally conceptualize OCR and that it just focuses on the visual appearance of
individual characters on and so this is comparing our model which we call focr for efficient OCR to a traditional sequence a sequence of CR which is what um dominates in the literature and so what focr does is we pass it lines of of data and it first of all recognizes the individual characters that's called localization it uses the same methods that I was telling you all about with layout parts of the same methods that are used to dock to detect the document layouts we can use those to detect individual characters and then we pass those
individual characters to a recognizer which has been trained to take characters that are the same character even if they use very different fonts even if they have a very different sort of appearance with the background and noise Etc and take characters that are the same underlying character and map them to the same location map them nearby in a dense Vector space and characters that are different it's trained to map them further apart um and so if you have two a's that are written with very different fonts it's been trained to map them um nearby into
map you know an O and A C which looks sort of similar but are not the same character further apart and then we just OCR that document by taking these dense vectors which are 768 dimensional vectors and finding the nearest Vector from an embedding index that we uh you know created with a single font um and that's how we OCR we localize the characters and then we recognize what they are sequence to sequence instead first of all you pass your line of text into a visual features extractor and um it outputs embeddings these do not
correspond to characters there's nothing about this architecture that recognized characters um it will essentially just um you know create um dense representations of um um of this line of text and then it will pass those sequentially to a language model which will um then output the characters um and so um focr does not have a language model that makes it much much more efficient to train because just like children learn how to recognize their letters before they learn how to read it's much easier to learn the visual appearance of characters than it is to learn
the language um we train localization and recognition separately which is also a big Advantage because you might just need a few labels to train the recognizer and then some more labels for recognition or kind of vice versa so for Japanese it's really easy to learn where characters are because they have similar aspect ratios but it takes a bit more data to learn um to recognize the characters because there's a lot of them whereas for English characters have very different aspect ratios and so it's a little bit harder to learn to localize them but it takes
really very little data to learn how to recognize them because there's not many characters and so these are Benchmark data sets that we evaluate on WE you see here we have Japanese written horizontally and vertically um and we have both Japanese pros and Japanese tables and then we also have U.S historical newspapers and so these are pretty diverse documents on because we wanted to really test on how focr applies to diverse settings so we create Benchmark data sets with a fairly modest number number of labeled lines and characters and we do this for each of
the four data sets that you just saw so really it's anywhere from you know a few hundred to a little bit over a thousand lines where lines are like lines of a single column and a newspaper or individual cells in the tables um and so it's really quite a modest amount of data um are Baseline results um we find very very accurate results our character error rate is under one percent um for the tables it's a little bit higher for pros because we intentionally chose documents that were low resolution where in some places they weren't
legible without language in order to have a context where you might think that there would be an advantage to sequence the sequence you see here that there's three lines of this table that's just different versions of our model I'm not going to talk about those differences now but we'll come back to this after we've seen different models the one important thing here though is that the very small parameter sorry the very small model it only has 9.3 million parameters this is deep learning model meant to be run on mobile phones and 9.3 million parameters is
really really small for a deep learning model it's doing like almost as well as the much larger models this is an example of kind of different errors we make and you see that when focr gets it wrong it's generally like you know um you can see why it gets it wrong it's actually you know um pretty hard to distinguish on the correct match which is in column one um from the prediction sample efficiency how well does the model learn and so we look at Splits of our training data as small as five percent um which
in the case of the newspapers is under a hundred labeled rows of data so really very very small training sets that you could label in an afternoon and the model is already very accurate you see focr is the orange there's some comparisons here again we'll come back to what those mean after we've kind of introduced the background that you need to understand what these different models are doing and the bottom line is focr is more accurate and it learns very very quickly um we compare it to other Solutions um and so these are kind of
Google Cloud vision is the main commercial solution Bilu is like the main commercial solution for Asian languages um tesseracts and open source engine these are used off the shelf you can see that Google Cloud Vision actually does really really well on the newspapers however we're feeding it individual lines and if you feed it the full documents it gets really confused about the layouts and does quite poorly and it would cost something like 28 million dollars to feed it individual lines from The Collection newspapers that we want to digitize which is obviously out of the question
and so getting this accuracy is not kind of practical in the real world um on the Japanese data it kind of just especially the um the vertical Japanese it does pretty horrible um the vertical Japanese tables focr is getting only you know half a percent of the characters wrong where's the next best alternative which is um Baidu is getting like 55 of the characters wrong um and we can look at other models that are either trained from scratch or where we take their pre-trained model and fine tune it um and we're still by and large
beating out these models um another important thing um that will also come up for you guys if you want to process data at scale is you care about how fast the model is um because you have these really large models like trocr um is a sequence to sequence Transformer OCR model it did pretty good on the English um but it is extremely slow to run so it's probably going to cost you too much money if you have a lot of documents on whereas focr the small version is actually quite fast the only thing that beats
it out is a a product called easy OCR which is is much smaller um but at some cost to accuracy um and you know so we've very much developed this to process like actual important social science documents at scale um and to be able to be both very accurate and affordable um it's highly extensible all that you need to extend focr to a new language is digital font renders of that character set we're also going to be extending it to handwriting but you know kind of using a similar approach but we haven't done that yet
it solves key problems with OCR of low resource languages and endangered languages it's very sample efficient you don't need to see characters in sequence you can mix and match character sets um Etc okay and this is kind of part of a broader goal I have to make digital history more representative of documentary history and so historians think of you know historians spend a long time thinking about how um the documents that let get left behind are not representative of humanity which is certainly true um but even beyond that problem the documents that do exist that
get digitized are not representative of documentary history because they're skewed towards a few High resource settings um that are not representative of the documents that that exist um and that leads economic research I think in particular to be skewed towards those High resource settings um because we need data and OCR errors are also really costly in data if you you know mistake a one for a three you know the number could be way off right so we need very accurate OCR um and um so the model architectures that exist they've been heavily tailored towards commercial
applications and Wealthy economies and they're often poorly suited towards low resource settings which tend to be kind of disproportionately kind of in developing countries Asian economies um and so another Central aim of my research is to make digital history a more representative of documentary history um by using deep learning um and this course is going to take kind of you know this angle right if we were developing a commercial OCR it might look quite different because we'd be focused on ocrine receipts um which is the main commercial application whereas the focus of this course is
going to be really on kind of using this for academic research and an important part of that is you that you can take these tools and you can use them in lower resource settings that are not large commercial applications but that are important for um for human knowledge and so I think that that gives us a very kind of different perspective than most of the development in this field where really there is a lot more of a focus on those commercial applications um and so I think actually deep learning is incredibly powerful for lower resource
settings but it's important to come at it with that angle and this is like one of the reasons why it's important to actually understand what's going on um because if you have a lower resource setting it might suggest kind of a very different approach than what's used by the off-the-shelf technology um one final kind of thing I want to say about this point of you know digitizing and working with tables is that for many tasks OCR even if it's pretty accurate can be an information bottleneck and we've gone through kind of you know um this
work to locate individual pieces of information in the document you know we can actually directly use those image crops for Downstream tasks um and so one of those Downstream taxes record linkage overwhelmingly the way record linkage is done is to OCR the content and then once the content is OCR do you use string matching techniques um in order to to link records across documents well even if you have a fairly minor OCR error as shown here that can really complicate your record linkage um instead of OCR in it in fact you could use object detection
to localize the crops of where those entities are mentioned in the original document so in this picture we have one document that's written horizontally in Japanese and one that's written vertically in the horizontal document we have lists of the customers and suppliers of each firms and in the vertical document we have more information about all those firms where we can learn their characteristics we can localize the segments that contain the firm names and then use a deep learning model to say which of these are the same firms and which of these are different firms um
and just cut out the OCR bottleneck altogether and achieve a more accurate record linkage all right um so that's processing kind of traditional data sources in this case tables if this isn't making a lot of you know a tremendous amount of sense right now that's fine you know we're going to go over all these methods in a lot more detail but I just want to give a sense for sort of for what can be done um the second thing you can do is just create completely novel types of data um and so for this example
I want to talk about historical newspapers we've used deep learning to extract structured text Data from over 50 million page scans of historical us newspapers um this means we have extracted over a billion objects from historical newspaper if we're an object could be like a headline or a caption or an article or an image um when processing is complete we will be releasing all of this data that is in the public domain this is something that Tom who's the TA for this course has been working very intensively on um and so once we have that
structured text we can use state-of-the-art NLP methods um and on those headlines on those articles captions to create a variety of data for Downstream analyzes and so if you were to take a historical newspaper scan and feed it to Google Cloud Vision which is what we use to make this figure almost always it's going to read it like it's a single column book and everything's going to get all the words are getting all scrambled up even if the layouts are pretty simple it's going to get very confused the words are scrambled up some of them
are missed altogether some of them are detected twice and so if this is what your output looks like um pretty much all you can do is like a keyword Search and say you know up to OCR did this word appear in this document and that's overwhelmingly what the literature on historical newspapers does um because that's the format that the data is in um but using deep learning we can actually do a lot more than that um and so we can first of all recognize the document layouts I'm using the same methods I was talking about
with the tables then we can use OCR so specifically use fo which I just showed you apply to the Japanese tables but we can use it to histor on historical newspapers um we can use deep learning um to um infer the um which are pieces of Articles go together right because an article can spam multiple columns or multiple Pages um and then finally we can take this and we can use that information for Downstream analysis and deep learning Powers all facets of this pipeline um so this is an example layout um where we've detected the
layouts of this newspaper so you see the yellows headlines and the pink that bright pink is a table The Greener articles the light pink is a caption we have the purple is an image and the blue at the top is the title of newspaper Etc um so what can we do with the digitized content um we can use deep learning methods to retrieve content from a database of hundreds of millions of articles with robustness to complex vocabulary and noise and text retrieval is going to be a topic we cover we can also retrieve images um
image retrieval is going to be a topic we covered topic classification what is this talking about again we're going to cover that entity um uh recognition and disambiguation so which of the words in this document are named entities and which named entity is this if we see um you know Senator Kennedy is that Senator John Kennedy Senator Ted Kennedy Senator Robert Kennedy um it could be um you know if we see John Kennedy it could be John Kennedy Airport John Kennedy Elementary School we can take all of those and say which of those mentions refer
to the same entity and we can also link them to Wikipedia if they're in Wikipedia again a topic we're going to cover um detect which of these um articles come from the same news story and detect the reproduction of content and so in U.S newspapers historically over half of all content was not written by local newspapers it was obtained from a newswire or from a Syndicate service um and um these are all applications we're going to talk about I want to briefly talk about the last of these applications here um and so uh media historian
Julia watanieri um wrote by the 1910s and 1920s most of the articles that Americans read in their local papers have either been bought or sold on the national news Market this constructed a broadly understood American way of life that would become a touchstone of U.S domestic politics and international relations throughout the 20th century um and so we wanted to detect which articles come from the same underlying wire newswire or Syndicate Source in a context where there's heavy abridgement so newspapers would edit down the Articles to fit into the space they had um and there's also
noise from OCR and so what we discovered is despite being important for a range of deep learning applications text deduplication methods are overwhelmingly rule-based and they lead to pretty poor results and so um with Emily um and Luca Di Amigo Wong and jinlin yang we developed deep neural methods to detect reproduced articles um and this is a um um work that I'm going to briefly talk about now and so we train a model to detect which articles come from the same Source um in this context that's right with abridgement and ocrs and so what the
model aims to do is learn a mapping from the raw article to a dense Vector representation of that article where articles from the same Source are nearby and articles from different sources are further apart and so this is like essentially the same um the same model in some sense asks Foci which you just saw and so this is a type of problem called contrastive learning which again will have a lecture on contrastive learning in the in the course um and so just like focr was um learning okay these two characters have different fonts different noises
but they're the same so I want to push their dance factors closer together whereas these two characters look pretty similar but they're actually different characters so the model should push their their dense representations further apart we're doing the same kind of the exact same thing with the news articles these are the same articles even though one of them was Abridged or has OCR noise pushed their representations close together different articles push them further apart once we have those representations we use single linkage clustering on those dense representations um to extract article clusters we can also
add a re-ranking step that jointly feeds these articles through the neural network and classifies whether they are the same or not um and so this is a training data um that that we assembled for this project um and so you can see we actually in the full data set have quite a few positive pairs so articles that are the same um and a big part of this data is evaluation data so for four days in the 1930s 50s and 70s we labeled every front page article that appeared in the hundreds of newspapers in our database
to say which of those came from the same wire source and which came from different wire sources and we had fantastic research assistance um who worked on putting together these data which allow us to really evaluate how we're doing and this context it's actually fairly unique because of the timely nature of news we can get all the duplicate articles whereas that would be harder um in in a context brain you didn't have that structure because obviously you know you can't label an entire massive Corpus okay so with these unique data so we're evaluating this on
those full days where we are confident we've labeled every article that comes from the same Source um and we look at neural methods and non-neural methods which we'll also discuss um I'm not going to go into detail now about what these are doing but I more want to just illustrate the power of neural networks and so uh this is reporting the adjusted Rand index um and you can see the neural methods you know it ranges from zero to a hundred um where 100 is the best that you could possibly do and neural methods are doing
much better than the non-neural methods this is a pretty significant difference um we want to say is this scalable um and so this kind of blows my mind um so we take 10 million articles and first of all we have to create those dins Factor representations which is called embedding articles on a single GPU that takes about eight hours um to feed each of these 10 million articles through this neural network to get a dense representation then we have to compute similarity and that is 10 to the 14 calculations because we're comparing 10 million things
to 10 million other things and yet with this Library called Facebook AI similarity search you can do that on a single GPU card in about three hours just mind-blowing and then the rest of it's trivial um you know it's hashing which is kind of a fast method for rule-based comparison of text you know it's it's it's faster but not kind of appreciably so um and you can see that with the hashing approach um the mean number of times that an article is reproduced blows up um when you apply to 10 million whereas with our neural
approach in the top row um an article on average appears in six newspapers which is nearly exactly the same as it is in our labeled data which gives us uh confidence in the neural approach all right um so again I know I've gone over this kind of quickly I don't expect people to understand all the details but I wanted to give kind of a flavor before we spend a lot of time delving into the methods of what you can do with these methods so to conclude deep learning provides powerful tools for processing unstructured economic data
text images video audio and oftentimes what you do is you take that raw information you create robust representations for Downstream analyzes um and becoming familiar with these methods how they apply to economics how they can be implemented and debugged can entail really significant startup costs I certainly um spent and probably wasted a lot of effort becoming familiar with these methods and so my goal for this course for these videos is to make it easier um to study questions you find fascinating and meaningful um using deep learning to you know either create data that it would
just be too costly to do it manually or that you know you wouldn't have even thought could be Data before and that includes in low resource contexts um and so I'm really looking forward to the rest of the course um as I have a chance to complete these videos um they'll be uploaded to the canvas site as well as uploaded um to my website um so thanks everyone and I'll see you in class on Thursday