
Natural Language Processing with Flair: A practical guide to understanding and solving NLP problems with Flair
- Length: 200 pages
- Edition: 1
- Language: English
- Publisher: Packt Publishing
- Publication Date: 2022-04-29
- ISBN-10: 1801072310
- ISBN-13: 9781801072311
- Sales Rank: #0 (See Top 100 Books)
Learn how to solve practical NLP problems with the Flair Python framework, train sequence labeling models, work with text classifiers and word embeddings, and much more through hands-on practical exercises
Key Features
- Backed by the community and written by an NLP expert
- Get an understanding of basic NLP problems and terminology
- Solve real-world NLP problems with Flair with the help of practical hands-on exercises
Book Description
Flair is an easy-to-understand natural language processing (NLP) framework designed to facilitate training and distribution of state-of-the-art NLP models for named entity recognition, part-of-speech tagging, and text classification. Flair is also a text embedding library for combining different types of embeddings, such as document embeddings, Transformer embeddings, and the proposed Flair embeddings.
Natural Language Processing with Flair takes a hands-on approach to explaining and solving real-world NLP problems. You’ll begin by installing Flair and learning about the basic NLP concepts and terminology. You will explore Flair’s extensive features, such as sequence tagging, text classification, and word embeddings, through practical exercises. As you advance, you will train your own sequence labeling and text classification models and learn how to use hyperparameter tuning in order to choose the right training parameters. You will learn about the idea behind one-shot and few-shot learning through a novel text classification technique TARS. Finally, you will solve several real-world NLP problems through hands-on exercises, as well as learn how to deploy Flair models to production.
By the end of this Flair book, you’ll have developed a thorough understanding of typical NLP problems and you’ll be able to solve them with Flair.
What you will learn
- Gain an understanding of core NLP terminology and concepts
- Get to grips with the capabilities of the Flair NLP framework
- Find out how to use Flair’s state-of-the-art pre-built models
- Build custom sequence labeling models, embeddings, and classifiers
- Learn about a novel text classification technique called TARS
- Discover how to build applications with Flair and how to deploy them to production
Who this book is for
This Flair NLP book is for anyone who wants to learn about NLP through one of the most beginner-friendly, yet powerful Python NLP libraries out there. Software engineering students, developers, data scientists, and anyone who is transitioning into NLP and is interested in learning about practical approaches to solving problems with Flair will find this book useful. The book, however, is not recommended for readers aiming to get an in-depth theoretical understanding of the mathematics behind NLP. Beginner-level knowledge of Python programming is required to get the most out of this book.
Natural Language Processing with Flair Contributors About the author About the reviewers Preface Who this book is for What this book covers To get the most out of this book Download the example code files Download the color images Conventions used Get in touch Share Your Thoughts Part 1: Understanding and Solving NLP with Flair Chapter 1: Introduction to Flair Technical requirements A brief introduction to NLP Tokenization Text vectorization Named entity recognition Word-sense disambiguation Part-of-speech tagging Chunking Stemming and lemmatization Text classification Introducing Flair Setting up the development environment Creating the virtual environment Installing a published version of Flair in a virtual environment Installing directly from the GitHub repository (optional) Running code that uses Flair Summary Chapter 2: Flair Base Types Technical requirements Sentence and Token objects Understanding the Sentence class Understanding the Token class Tokenization in Flair Sentence and Token object helper methods Using custom tokenizers Using the TokenizerWrapper class Understanding the Corpus object Summary Chapter 3: Embeddings in Flair Technical requirements Understanding word embeddings Cosine similarity The "king – man ≈ queen – woman" analogy Classic word embeddings in Flair Flair embeddings Understanding the contextuality of Flair embeddings Character-level sequence modeling in Flair embeddings Pooled Flair embeddings Available Flair embeddings Stacked embeddings Document embeddings Other embeddings in Flair Summary Chapter 4: Sequence Tagging Technical requirements Understanding sequence tagging in Flair Named entity recognition in Flair Types of NER taggers in Flair Part-of-speech tagging in Flair Part-of-speech tagging tag sets Types of PoS taggers in Flair Other tagging tasks in Flair Sequence labeling metrics Measuring accuracy for sequence labeling tasks Measuring the F1 score for sequence labeling tasks Summary Part 2: Deep Dive into Flair – Training Custom Models Chapter 5: Training Sequence Labeling Models Technical requirements The motivation behind training custom models Understanding the hardware requirements for training models Working with parameters for training and evaluation Understanding neural model training Parameters and terminology used in Flair model training Training custom sequence labeling models Loading a tagged corpus Loading the tag dictionary Building the embedding stack Initializing the SequenceTagger object Training the model Understanding training output files Loading and using custom Flair models Knowing when to stop and try again Monitoring loss Assessing and comparing performance metrics Summary Chapter 6: Hyperparameter Optimization in Flair Technical requirements Understanding hyperparameter tuning Optimization methods Hyperparameter tuning in Python Hyperparameter tuning in Python hands-on Hyperparameter optimization in Flair Hyperparameter tuning in Flair hands-on Summary Chapter 7: Train Your Own Embeddings Technical requirements Understanding the how and why behind custom Flair embeddings Why training embeddings rarely ever means training embeddings Corpora for Flair embeddings Dictionaries for training Flair embeddings Evaluating word embeddings Training Flair embeddings on the world's smallest language Preparing the dictionary Preparing the corpus Training the language model Using custom embeddings on downstream tasks Performing intrinsic evaluation on custom Flair embeddings Summary Chapter 8: Text Classification in Flair Technical requirements Understanding text classification Training text classifiers Text classification in Flair Using pre-trained Flair text classification models Document embeddings in Flair Text classifiers in Flair Training a text classifier in Flair Working with text classifiers that require little to no training data Zero-shot classification with TARS Few-shot classification with TARS Summary Part 3: Real-World Applications with Flair Chapter 9: Deploying and Using Models in Production Technical requirements Technical considerations for NLP models in production Client-side versus server-side inference When to use managed services and when to self-serve server-side models Managed services for Flair models A model deployment decision-making flowchart Self-serving flair models A proof-of-concept self-serve tool for Flair Using managed services for deploying and using Flair models The Hugging Face Models Hub Summary Chapter 10: Hands-On Exercise – Building a Trading Bot with Flair Technical requirements Understanding the trading strategy Implementing the Flair trading bot A Flair coding cheat sheet Summary Why subscribe? Other Books You May Enjoy Packt is searching for authors like you Share Your Thoughts
How to download source code?
1. Go to: https://github.com/PacktPublishing
2. In the Find a repository… box, search the book title: Natural Language Processing with Flair: A practical guide to understanding and solving NLP problems with Flair
, sometime you may not get the results, please search the main title.
3. Click the book title in the search results.
3. Click Code to download.
1. Disable the AdBlock plugin. Otherwise, you may not get any links.
2. Solve the CAPTCHA.
3. Click download link.
4. Lead to download server to download.