- Hands-On Natural Language Processing with PyTorch 1.x
- Thomas Dop
- 1255字
- 2022-08-25 16:45:12
Preface
In the internet age, where an increasing volume of text data is being generated daily from social media and other platforms, being able to make sense of that data is a crucial skill. This book will help you build deep learning models for Natural Language Processing (NLP) tasks that will help you extract valuable insights from text.
We will start by understanding how to install PyTorch and using CUDA to accelerate the processing speed. You'll then explore how the NLP architecture works through practical examples. Later chapters will guide you through important principles, such as word embeddings, CBOW, and tokenization in PyTorch. You'll then learn some techniques for processing textual data and how deep learning can be used for NLP tasks. Next, we will demonstrate how to implement deep learning and neural network architectures to build models that allow you to classify and translate text and perform sentiment analysis. Finally, you will learn how to build advanced NLP models, such as conversational chatbots.
By the end of this book, you'll understand how different NLP problems can be solved using deep learning with PyTorch, as well as how to build models to solve them.
Who this book is for
This PyTorch book is for NLP developers, machine learning and deep learning developers, or anyone working toward building intelligent language applications using both traditional NLP approaches and deep learning architectures. If you're looking to adopt modern NLP techniques and models for your development projects, then this book is for you. Working knowledge of Python programming and basic working knowledge of NLP tasks are a must.
What this book covers
Chapter 1, Fundamentals of Machine Learning and Deep Learning, provides an overview of the fundamental aspects of machine learning and neural networks.
Chapter 2, Getting Started with PyTorch 1.x for NLP, shows you how to download, install, and start PyTorch. We will also run through some of the basic functionality of the package.
Chapter 3, NLP and Text Embeddings, shows you how to create text embeddings for NLP and use them in basic language models.
Chapter 4, Text Preprocessing, Stemming, and Lemmatization, shows you how to preprocess textual data for use in NLP deep learning models.
Chapter 5, Recurrent Neural Networks and Sentiment Analysis, runs through the fundamentals of recurrent neural networks and shows you how to use them to build a sentiment analysis model from scratch.
Chapter 6, Convolutional Neural Networks for Text Classification, runs through the fundamentals of convolutional neural networks and shows you how you can use them to build a working model for classifying text.
Chapter 7, Text Translation Using Sequence-to-Sequence Neural Networks, introduces the concept of sequence-to-sequence models for deep learning and runs through how to use them to construct a model to translate text into another language.
Chapter 8, Building a Chatbot Using Attention-Based Neural Networks, covers the concept of attention for use within sequence-to-sequence deep learning models and also shows you how they can be used to build a fully working chatbot from scratch.
Chapter 9, The Road Ahead, covers some of the state-of-the-art models currently used within NLP deep learning and looks at some of the challenges and problems facing the field of NLP going forward.
To get the most out of this book
You will need a version of Python installed on your computer. All code examples have been tested using version 3.7. You will also need a working PyTorch environment for the deep learning components of this book. All deep learning models were constructed using version 1.4; however, the majority of the code should work with later versions.
There are several Python libraries used within the code throughout this book; however, these will be covered in the relevant chapters.
If you are using the digital version of this book, we advise you to type the code yourself or access the code via the GitHub repository (link available in the next section). Doing so will help you avoid any potential errors related to the copying and pasting of code.
Download the example code files
You can download the example code files for this book from your account at www.packt.com. If you purchased this book elsewhere, you can visit www.packtpub.com/support and register to have the files emailed directly to you.
You can download the code files by following these steps:
- Log in or register at www.packt.com.
- Select the Support tab.
- Click on Code Downloads.
- Enter the name of the book in the Search box and follow the onscreen instructions.
Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:
- WinRAR/7-Zip for Windows
- Zipeg/iZip/UnRarX for Mac
- 7-Zip/PeaZip for Linux
The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Hands-On-Natural-Language-Processing-with-PyTorch-1.x. In case there's an update to the code, it will be updated on the existing GitHub repository.
We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!
Download the color images
We also provide a PDF file that has color images of the screenshots/diagrams used in this book. You can download it here: https://static.packt-cdn.com/downloads/9781789802740_ColorImages.pdf.
Conventions used
There are a number of text conventions used throughout this book.
Code in text: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: “Mount the downloaded WebStorm-10*.dmg disk image file as another disk in your system.”
A block of code is set as follows:
import torch
When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:
word_1 = ‘cat'
word_2 = ‘dog'
word_3 = ‘bird'
Any command-line input or output is written as follows:
$ mkdir flaskAPI
$ cd flaskAPI
Bold: Indicates a new term, an important word, or words that you see onscreen. For example, words in menus or dialog boxes appear in the text like this. Here is an example: “Select System info from the Administration panel.”
Tips or important notes
Appear like this.
Get in touch
Feedback from our readers is always welcome.
General feedback: If you have questions about any aspect of this book, mention the book title in the subject of your message and email us at customercare@packtpub.com.
Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packtpub.com/support/errata, selecting your book, clicking on the Errata Submission Form link, and entering the details.
Piracy: If you come across any illegal copies of our works in any form on the Internet, we would be grateful if you would provide us with the location address or website name. Please contact us at copyright@packt.com with a link to the material.
If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.
Reviews
Please leave a review. Once you have read and used this book, why not leave a review on the site that you purchased it from? Potential readers can then see and use your unbiased opinion to make purchase decisions, we at Packt can understand what you think about our products, and our authors can see your feedback on their book. Thank you!
For more information about Packt, please visit packt.com.