Digital Library

Practical Solutions for Modern NLP Challenges Mastering LLMs and SLMs for Real-World NLP in Cloud and Open-Source (Venkata Gunnu, Shubham Shah etc.)(Z-Library)

Venkata Gunnu, Shubham Shah, Anvesh Minukuri, Jayanth Gopu

Practical Solutions for Modern NLP Challenges Mastering LLMs and SLMs for Real-World NLP in Cloud and Open-Source (Venkata Gunnu, Shubham Shah etc.)(Z-Library)

Author Venkata Gunnu, Shubham Shah, Anvesh Minukuri, Jayanth Gopu

人工智能

Large Language Models (LLMs) have revolutionized Natural Language Processing (NLP), enabling advanced applications such as machine translation, text summarization, and sentiment analysis. This book serves as a comprehensive guide for data scientists, machine learning engineers, and developers, offering foundational theory and practical skills to harness the power of LLMs for real-world problems. From understanding the fundamentals of LLMs to deploying them in cloud and open-source environments, this book equips readers with the essential knowledge to excel in modern NLP. The book takes a hands-on approach, guiding readers through the end-to-end deployment of LLMs—from data collection and preprocessing to model training, evaluation, and real-time inference. Using popular frameworks like Amazon SageMaker and Hugging Face Transformers, you’ll explore practical tasks such as text generation, classification, and named entity recognition. Additionally, it delves into industry use cases like customer support chatbots and content generation while addressing emerging trends, scaling techniques, and ethical considerations like bias and fairness in AI. This is your ultimate resource for mastering LLMs in production-ready environments. You Will: • Learn to implement cutting-edge NLP tasks such as text generation, sentiment analysis, and named entity recognition using AWS services and open-source tools like Hugging Face. • Understand best practices for scaling and maintaining NLP models in production, focusing on real-time performance, monitoring, and iterative improvements. • Practice techniques for training and optimizing LLMs, covering data preprocessing, hyperparameter tuning, and evaluation strategies. This book is for: Data scientists, Machine learning engineers, and developers

Format PDF
Size 2.7 MB
16
Views
0
Downloads
0.00
Total Donations
(First 20 pages)

Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Page 1
Practical Solutions for Modern NLP Challenges Mastering LLMs and SLMs for Real-World NLP in Cloud and Open-Source — Venkata Gunnu Shubham Shah Anvesh Minukuri Jayanth Gopu
Page 2
Practical Solutions for Modern NLP Challenges Mastering LLMs and SLMs for  Real-World NLP in Cloud and Open-Source Venkata Gunnu Shubham Shah Anvesh Minukuri Jayanth Gopu
Page 3
Practical Solutions for Modern NLP Challenges: Mastering LLMs and SLMs for Real-World NLP in Cloud and Open-Source ISBN-13 (pbk): 979-8-8688-2055-7 ISBN-13 (electronic): 979-8-8688-2056-4 https://doi.org/10.1007/979-8-8688-2056-4 Copyright © 2025 by Venkata Gunnu, Shubham Shah, Anvesh Minukuri and Jayanth Gopu This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed. Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights. While the advice and information in this book are believed to be true and accurate at the date of publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made. The publisher makes no warranty, express or implied, with respect to the material contained herein. Managing Director, Apress Media LLC: Welmoed Spahr Acquisitions Editor: Aditee Mirashi Editorial Assistant: Gryffin Winkler Copy Editor: Kezia Endsley Cover designed by eStudioCalamar Distributed to the book trade worldwide by Springer Science+Business Media New York, 1 New York Plaza, New York, NY 10004. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer-sbm.com, or visit www.springeronline.com. Apress Media, LLC is a Delaware LLC and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation. For information on translations, please e-mail booktranslations@springernature.com; for reprint, paperback, or audio rights, please e-mail bookpermissions@springernature.com. Apress titles may be purchased in bulk for academic, corporate, or promotional use. eBook versions and licenses are also available for most titles. For more information, reference our Print and eBook Bulk Sales web page at http://www.apress.com/bulk-sales. Any source code or other supplementary material referenced by the author in this book is available to readers on GitHub. For more detailed information, please visit https://www.apress.com/gp/services/ source-code. If disposing of this product, please recycle the paper Venkata Gunnu malvern, PA, USA Shubham Shah Rajkot, Gujarat, India Anvesh Minukuri middletown, DE, USA Jayanth Gopu Hyderabad, Andhra Pradesh, India
Page 4
Dedicated to the practitioners and engineers advancing NLP—from fine-tuning to inference, from open-source to cloud—turning language models into real-world solutions across modern NLP tasks
Page 5
v Table of Contents About the Authors xvii About the Technical Reviewers xix Acknowledgments xxi Introduction xxiii Chapter 1: Introduction to LLMs, SLMs, and Modern NLP Challenges 1 1.1 Introduction: Understanding LLMs and SLMs in the NLP Landscape ...................................... 1 1.2 What Is an LLM? ...................................................................................................................... 5 1.2.1 Defining LLMs ................................................................................................................. 5 1.2.2 Key Features and Significance ....................................................................................... 6 1.2.3 Evolution of LLMs ........................................................................................................... 6 1.2.4 Practical Applications of LLMs ....................................................................................... 7 1.2.5 Challenges in Scaling LLMs ............................................................................................ 8 1.2.6 Future Directions for LLMs ............................................................................................. 9 1.3 What Is an SLM? ................................................................................................................... 10 1.3.1 Defining SLMs .............................................................................................................. 10 1.3.2 Key Features of SLMs ................................................................................................... 10 1.3.3 Evolution of SLMs ......................................................................................................... 11 1.3.4 Practical Applications of SLMs ..................................................................................... 11 1.3.5 Innovations Driving SLMs Forward ............................................................................... 12 1.3.6 Challenges and Limitations .......................................................................................... 12 1.3.7 Case Studies and Real-World Scenarios ...................................................................... 12 1.3.8 Future Directions for SLMs ........................................................................................... 13 1.3.9 Techniques Enhancing SLM Efficiency ......................................................................... 13
Page 6
vi 1.4 Overview of Modern NLP Tasks............................................................................................. 14 1.4.1 Text Classification ......................................................................................................... 14 1.4.2 Sentiment Analysis ....................................................................................................... 15 1.4.3 Text Summarization ...................................................................................................... 15 1.4.4 Question Answering (QA) .............................................................................................. 16 1.5 LLMs on AWS vs. Open-Source Frameworks ........................................................................ 18 1.5.1 AWS Suite Features for Modern NLP Tasks .................................................................. 18 1.5.2 Open-Source Frameworks ............................................................................................ 21 1.5.3 Benefits of Cloud Platforms vs. Open-Source Frameworks ......................................... 22 1.5.4 When to Choose Cloud Platforms vs. Open- Source Frameworks ................................. 23 1.5.5 The Hybrid Approach .................................................................................................... 24 1.6 LLM Lifecycle Activities ......................................................................................................... 24 1.6.1 Data Collection and Preparation ................................................................................... 24 1.6.2 Model Training and Fine-Tuning ................................................................................... 26 1.6.3 Model Evaluation and Testing ....................................................................................... 27 1.6.4 Deployment and Monitoring ......................................................................................... 31 1.7 LLM Selection Based on Cost, Compute, and Effectiveness and SLM Exploration ................ 33 1.7.1 The LLM vs. SLM Dilemma ........................................................................................... 34 1.7.2 Effectiveness: Balancing Performance and Efficiency ................................................. 36 1.7.3 SLM Techniques and Innovations ................................................................................. 38 1.7.4 The Future of SLMs in NLP ........................................................................................... 39 1.8 Summary............................................................................................................................... 40 Chapter 2: Text Generation with LLMs and SLMs 41 2.1 Text Generation with LLMs and SLMs ................................................................................... 42 2.2 Types of Text Generation Tasks ............................................................................................. 43 2.2.1 Creative Writing ............................................................................................................ 43 2.2.2 Automated Content Generation ..................................................................................... 44 2.2.3 Chatbots and Conversational Agents ............................................................................ 46 2.2.4 Generative vs. Extractive Tasks .................................................................................... 47 Table of ConTenTs
Page 7
vii 2.3 Building and Deploying LLMs and SLMs for Text Generation ................................................ 48 2.3.1 Choosing the Right LLM or SLM for Text Generation .................................................... 52 2.3.2 Training and Fine-Tuning LLMs and SLMs .................................................................... 53 2.3.3 Efficient Inference and Deployment of LLMs and SLMs ............................................... 54 2.4 Implementing Text Generation on AWS ................................................................................. 56 2.4.1 Transition from Building SLMs to AWS Implementation................................................ 56 2.4.2 Deploying LLMs with AWS SageMaker ......................................................................... 57 2.4.3 Real-Time Inference Using AWS Lambda (Continued) .................................................. 59 2.4.4 Optimizing Models for Edge Deployment with Amazon SageMaker Neo...................... 60 2.4.5 Integrating AWS Services for Comprehensive Text Generation Solutions ..................... 62 2.4.6 Use Case A: SLM for Technical Support Ticket Triage ................................................... 63 2.4.7 Use Case B: Deploying an LLM for Marketing Content Generation ............................... 66 2.4.8 Best Practices and Architectural Considerations .......................................................... 70 2.4.9 Conclusion .................................................................................................................... 73 2.5 Open-Source Implementation ............................................................................................... 73 2.5.1 Fine-Tuning GPT-2 LLM with Hugging Face .................................................................. 73 2.5.2 SLM Local Deployment ................................................................................................. 78 2.6 Industry Use Cases ............................................................................................................... 79 2.6.1 Content Generation and Marketing ............................................................................... 81 2.6.2 Industry-Level Best Practices ....................................................................................... 81 2.6.3 Chatbots and Customer Support .................................................................................. 84 2.6.4 On-Device Text Generation ........................................................................................... 86 2.7 Summary............................................................................................................................... 88 Chapter 3: Text Classification with LLMs and SLMs 89 3.1 Types of Classification Tasks ................................................................................................. 90 3.1.1 Binary Classification ..................................................................................................... 90 3.1.2 Multi-Class Classification ............................................................................................. 92 3.1.3 Multi-Label Classification ............................................................................................. 93 3.1.4 Conclusion .................................................................................................................... 97 Table of ConTenTs
Page 8
viii 3.2 Implementation on AWS ........................................................................................................ 97 3.2.1 Amazon Comprehend for Built-In Models ..................................................................... 97 3.2.2 Custom Model Training with SageMaker .................................................................... 102 3.2.3 Inference and Deployment ......................................................................................... 104 3.3 Open-Source Implementation ............................................................................................. 105 3.3.1 Building Text Classifiers Using Hugging Face Transformers ....................................... 105 3.3.2 Using SLMs for Faster Training and Inference ............................................................ 106 3.3.3 Data Preparation Techniques ...................................................................................... 112 3.3.4 Summary .................................................................................................................... 113 3.4 Industry Use Cases ............................................................................................................. 113 3.4.1 Spam Detection .......................................................................................................... 113 3.4.2 Customer Feedback Categorization ............................................................................ 114 3.4.3 Social Media Sentiment Analysis ............................................................................... 115 3.4.4 Automated Customer Support .................................................................................... 115 3.5 Summary............................................................................................................................. 116 Chapter 4: Named Entity Recognition (NER) with LLMs and SLMs 117 4.1 Introduction to Named Entity Recognition (NER) ................................................................. 118 4.1.1 What Is Named Entity Recognition?............................................................................ 118 4.1.2 Why NER Matters: Real-World Applications ................................................................ 120 4.1.3 Techniques for NER: Traditional Models vs. LLMs ....................................................... 121 4.1.4 LLM Agents and Automated NER Pipelines ................................................................. 128 4.2 Implementation on AWS with SLMs and LLMs .................................................................... 130 4.2.1 Using Amazon Comprehend for NER Tasks ................................................................. 130 4.2.2 Training Custom NER Models on SageMaker .............................................................. 134 4.2.3 Deployment Considerations on AWS ........................................................................... 139 4.2.4 Example Use Case: Real-World Deployment............................................................... 144 4.2.5 Key Takeaways and Practical Insights ........................................................................ 147 4.2.6 Summary of NER Implementation with AWS Services................................................ 148 4.3 Open-Source Implementation ............................................................................................. 149 4.3.1 From AWS Solutions to Open-Source Alternatives ..................................................... 149 4.3.2 Fine-Tuning with Hugging Face Transformers (BERT, RoBERTa, etc.) ......................... 149 Table of ConTenTs
Page 9
ix 4.3.3 Embracing Smaller Models: DistilBERT and TinyBERT ................................................ 153 4.3.4 spaCy: Industrial-Strength NER Pipelines ................................................................... 154 4.3.5 Flair: Simple and Flexible NER Training ...................................................................... 156 4.3.6 Model Evaluation and Optimization ............................................................................ 158 4.3.7 Quantizing the Model for Efficient Inference .............................................................. 161 4.4 Low-level LLM Exploration: Small LLM Cost-Effective Alternatives .................................... 162 4.4.1 Cost-Effectiveness of SLMs in NER ............................................................................ 162 4.4.2 Use Case: Small LLMs for Real-Time NER .................................................................. 169 4.4.3 Fine-Tuning SLMs for NER Tasks ................................................................................ 169 4.5 Industry Use Cases ............................................................................................................. 170 4.5.1 Resume Parsing ......................................................................................................... 170 4.5.2 Legal Document Analysis ........................................................................................... 171 4.5.3 Customer Data Extraction ........................................................................................... 172 4.6 Summary............................................................................................................................. 173 Chapter 5: Sentiment Analysis with LLMs and SLMs 175 5.1 Understanding Sentiment Analysis ..................................................................................... 176 5.1.1 Sentiment Analysis: Definition and Significance ........................................................ 176 5.1.2 Challenges in Analyzing Sentiment ............................................................................ 178 5.1.3 LLMs in Sentiment Analysis ........................................................................................ 180 5.1.4 SLMs in Sentiment Analysis ....................................................................................... 182 5.1.5 LLMs vs. SLMs: A Comparative View .......................................................................... 183 5.1.6 Example: Classifying Customer Reviews with Transformers ...................................... 186 5.1.7 Next Steps: Implementing Sentiment Analysis on AWS .............................................. 189 5.2 Implementing Financial Sentiment Analysis with AWS Services ........................................ 189 5.2.1 Overview and Architecture ......................................................................................... 190 5.2.2 Using Amazon Comprehend for Financial Sentiment Analysis ................................... 191 5.2.3 Deploying SLMs on AWS Lambda for Real-Time Sentiment ....................................... 193 5.2.4 Custom Model Training and Deployment Using Amazon SageMaker ......................... 199 5.2.5 Comparing Approaches: Comprehend vs. Custom Models vs. Lambda-deployed SLMs ........................................................................................................................... 205 5.2.6 Choosing the Best Approach....................................................................................... 208 5.2.7 Conclusion and Next Steps ......................................................................................... 210 Table of ConTenTs
Page 10
x 5.3 Open-Source Implementation ............................................................................................. 210 5.3.1 Implementing Sentiment Analysis with Hugging Face Transformers ......................... 210 5.3.2 MLOps Considerations for LLMs and SLMs in Sentiment Analysis ............................. 214 5.3.3 Techniques for Deployment of LLMs and SLMs .......................................................... 215 5.3.4 Data Labeling Techniques and Challenges for Sentiment Classification .................... 218 5.4 Industry Use Cases ............................................................................................................. 220 5.4.1 Brand Monitoring ........................................................................................................ 220 5.4.2 Social Media Analysis ................................................................................................. 221 5.4.3 Customer Satisfaction Insights ................................................................................... 221 5.5 Summary............................................................................................................................. 224 Chapter 6: Question Answering (QA) 225 6.1 Introduction to Question Answering .................................................................................... 226 6.1.1 Extractive Question Answering ................................................................................... 226 6.1.2 Abstractive Question Answering ................................................................................. 230 6.1.3 Large vs. Small Language Models in QA .................................................................... 234 6.1.4 LLM Agents and Multi-step Reasoning in QA ............................................................. 238 6.2 Implementation of QA Systems on AWS .............................................................................. 243 6.2.1 Extractive vs. Abstractive QA on AWS ......................................................................... 243 6.2.2 Model Selection Strategies for QA .............................................................................. 245 6.2.3 Cost and Performance Benchmarks ........................................................................... 253 6.2.4 Conclusion .................................................................................................................. 257 6.3 Open-Source Implementation ............................................................................................. 258 6.3.1 Implementing QA with Hugging Face Transformers ................................................... 258 6.3.2 Fine-Tuning T5 for Generative QA ............................................................................... 260 6.3.3 Fine-Tuning DistilBERT for Extractive QA .................................................................... 261 6.3.4 Next-Gen Fine-Tuning Strategies................................................................................ 262 6.3.5 Deployment of QA Models .......................................................................................... 263 6.3.6 Inference Optimization Strategies for QA Models ....................................................... 264 6.3.7 Evaluation Metrics for QA Performance...................................................................... 267 Table of ConTenTs
Page 11
xi 6.4 Industry Use Cases ............................................................................................................. 272 6.4.1 Customer Support Chatbot ......................................................................................... 272 6.4.2 Knowledge Base Querying (Legal, HR) ....................................................................... 274 6.4.3 Automated Assistants ................................................................................................. 276 6.5 Summary............................................................................................................................. 279 Chapter 7: Text Summarization 281 7.1 Overview of Text Summarization......................................................................................... 282 7.1.1 Extractive vs. Abstractive Summarization Techniques ............................................... 282 7.1.2 Extractive Summarization Approaches (BERT and Other Models) .............................. 285 7.1.3 Abstractive Summarization Approaches (PEGASUS, BART, GPT-3, T5) ........................ 287 7.1.4 Recent Trends: Efficient SLMs, Retrieval-Augmented Summarization, and LLM Agents ........................................................................................................................ 290 7.2 Implementation on AWS: Using SageMaker and Lambda to Deploy Summarization at Scale ................................................................................................................................... 294 7.2.1 Architectural Overview: Deploying Summarization Pipelines at Scale on AWS .......... 295 7.2.2 Deploying Extractive Summarization with DistilBERT on AWS Lambda ...................... 298 7.2.3 Deploying Abstractive Summarization with T5 on AWS SageMaker ........................... 300 7.3 Open-Source Summarization Systems ............................................................................... 303 7.3.1 Implementing Summarization with Hugging Face Transformers ............................... 303 7.3.2 Fine-Tuning T5 for Abstractive Summarization........................................................... 304 7.3.3 Fine-Tuning DistilBERT for Extractive Summarization ................................................ 305 7.3.4 Next-Gen Fine-Tuning Strategies................................................................................ 305 7.3.5 Deployment of Summarization Models ....................................................................... 306 7.3.6 Inference Optimization Strategies for Summarization Models ................................... 307 7.3.7 Evaluation Metrics for Summarization Quality ........................................................... 307 7.3.8 Conclusion: Building Future-Ready Summarization Systems ..................................... 308 7.4 Industry Uses Cases ............................................................................................................ 309 7.4.1 News Aggregation Use Case ....................................................................................... 309 7.4.2 Business Document Summarization Use Case ........................................................... 310 7.4.3 Automated Email Summarization Use Case ............................................................... 318 7.5 Summary............................................................................................................................. 323 Table of ConTenTs
Page 12
xii Chapter 8: Language Translation 325 8.1 Introduction to Language Translation .................................................................................. 326 8.1.1 Translation Challenges................................................................................................ 326 8.1.2 Importance of NLP in Translation ................................................................................ 328 8.1.3 LLMs for Translation ................................................................................................... 330 8.1.4 SLMs for Translation ................................................................................................... 332 8.2 Implementation on AWS ...................................................................................................... 335 8.2.1 Amazon Translate ....................................................................................................... 336 8.2.2 Using LLMs on AWS (Custom Models) ........................................................................ 341 8.2.3 Using SLMs on AWS (DistilBART, TinyBERT for Fast Translation) ................................ 346 8.2.4 Custom Training on SageMaker (T5, mBART, and so on) ............................................ 351 8.3 Open-Source Translation Systems ...................................................................................... 356 8.3.1 Implementing Translation with Hugging Face Transformers ...................................... 357 8.3.2 Fine-Tuning MarianMT for Custom Language Pairs ................................................... 358 8.3.3 Fine-Tuning DistilBART for Lightweight Translation .................................................... 358 8.3.4 Parameter-Efficient Translation with PEFT ................................................................. 358 8.3.5 Deploying Translation Models ..................................................................................... 359 8.3.6 Inference Optimization Strategies for Translation Models .......................................... 360 8.3.7 Evaluation Metrics for Translation Quality .................................................................. 360 8.4 Industry Use Cases ............................................................................................................. 361 8.4.1 Use Case: Global Customer Support Chatbots ............................................................ 361 8.4.2 Industry Use Case: Multilingual Content Delivery ....................................................... 363 8.5 Summary............................................................................................................................. 365 Chapter 9: Dialogue Systems 367 9.1 Understanding Dialogue Systems ....................................................................................... 368 9.1.1 Rule-based vs. Generative Dialogue Systems ............................................................ 369 9.1.2 The Role of LLMs and SLMs in Dialogue Systems ...................................................... 375 9.2 Implementation on AWS ...................................................................................................... 379 9.2.1 Amazon Lex: Rule-Based Conversational Agents ....................................................... 380 9.2.2 Amazon SageMaker: Fine-Tuning LLMs for Dialogue ................................................. 387 Table of ConTenTs
Page 13
xiii 9.2.3 SLM Implementation: Using DistilGPT-2 and DistilT5 for Lightweight Deployment ................................................................................................................ 394 9.3 Open-Source Implementation ............................................................................................. 404 9.3.1 Rasa and Hugging Face Transformers ........................................................................ 404 9.3.2 Fine-Tuning a Generative SLM for Open-Source ........................................................ 407 9.4 Industrial Use Cases ........................................................................................................... 407 9.4.1 Virtual Customer Assistants ........................................................................................ 407 9.4.2 Interactive Voice Response Systems (IVR) Use Case .................................................. 410 9.4.3 Healthcare Virtual Assistants ...................................................................................... 412 9.5 Summary............................................................................................................................. 416 Chapter 10: Text Correction and Language Modeling 417 10.1 Introduction to Text Correction .......................................................................................... 418 10.1.1 The Importance of Grammar and Spelling Correction .............................................. 418 10.1.2 Common Applications of Text Correction .................................................................. 419 10.1.3 Traditional Approaches to Text Correction (Rules and Heuristics) ............................ 421 10.1.4 AI-Powered Approaches (Statistical, Neural, and LLM-based) ................................. 423 10.2 Implementation on AWS: Building Text Correction Models with SageMaker ..................... 426 10.2.1 Why Use AWS SageMaker for Text Correction? ........................................................ 426 10.2.2 Data Preparation: Grammar Correction Dataset on S3 ............................................. 428 10.2.3 Fine-Tuning an LLM on SageMaker .......................................................................... 431 10.2.4 Fine-Tuning a SLM and the Tradeoffs ....................................................................... 435 10.2.5 Deploying the Model on AWS SageMaker for Scalable Inference............................. 438 10.3 Open-Source Implementation: Training with Hugging Face .............................................. 443 10.3.1 Fine-Tuning an LLM or SLM for Grammar Correction ............................................... 444 10.3.2 Evaluation and User Feedback ................................................................................. 447 10.4 Industrial Use Cases ......................................................................................................... 449 10.4.1 Writing Assistance Tools ........................................................................................... 449 10.4.2 Proofreading Applications......................................................................................... 452 10.5 Summary........................................................................................................................... 455 Table of ConTenTs
Page 14
xiv Chapter 11: Coreference Resolution and Text Entailment 457 11.1 Overview of Coreference Resolution ................................................................................. 458 11.1.1 Importance of Understanding Context and Semantics ............................................. 459 11.1.2 Coreference Resolution ............................................................................................ 461 11.1.3 Text Entailment ......................................................................................................... 464 11.2 Implementation on AWS .................................................................................................... 467 11.2.1 Custom Model Development on SageMaker............................................................. 467 11.2.2 LLMs for Coreference and Entailment ...................................................................... 474 11.2.3 The SLM Approach .................................................................................................... 479 11.3 Open-Source Implementation for Coreference Resolution and Text Entailment ............... 484 11.3.1 Coreference Resolution ............................................................................................ 485 11.3.2 Textual Entailment .................................................................................................... 486 11.3.3 Improving Model Accuracy ....................................................................................... 486 11.4 Industry Use Cases ........................................................................................................... 488 11.4.1 Enhancing AI-driven Customer Support ................................................................... 488 11.4.2 Industry Use Cases: LegalTech and Contract Review ............................................... 490 11.5 Summary........................................................................................................................... 493 Chapter 12: Emerging Trends and Future Directions in NLP 495 12.1 LLM Evolution: Multimodality, Zero/Few-Shot, and Reasoning ......................................... 496 12.1.1 From BERT/T5 Pretraining to Prompting Paradigms ................................................. 496 12.1.2 In-Context Learning and Instruction-Tuning ............................................................. 498 12.1.3 RLHF, Multimodal Integration, and Tool Use .............................................................. 498 12.1.4 Long-Context Reasoning and Chain-of-Thought Advances ...................................... 499 12.2 New Training Techniques and Responsible Alignment ...................................................... 499 12.2.1 Instruction-Tuning, RLHF, and Red Teaming.............................................................. 499 12.2.2 Bias Mitigation, Fairness-Aware Learning, and Governance .................................... 500 12.2.3 Empathy-Informed Reinforcement Learning and Human- in-the-Loop Protocols ..... 500 12.3 SLM Innovation: Efficiency and Accessibility .................................................................... 500 12.3.1 Edge AI, Distilled/Quantized Models, and IoT Deployments ...................................... 501 12.3.2 Benchmarking Efficiency: Latency, Memory, and Context Tradeoffs ......................... 501 Table of ConTenTs
Page 15
xv 12.3.3 Transfer Learning with SLMs: Knowledge Distillation, Task Adapters, and LoRA ..... 501 12.3.4 Hybrid Collaboration: SLM–LLM Router Systems and Cascade Pipelines ................ 502 12.4 Scaling Models: Tradeoffs Between Size, Accuracy, and Efficiency .................................. 502 12.4.1 The Three Axes of Scaling ........................................................................................ 503 12.4.2 From Dense to Sparse: Mixture-of-Experts (MoE) .................................................... 506 12.4.3 SLMs: Efficiency First ............................................................................................... 510 12.5 Future Applications ........................................................................................................... 515 12.6 Ethical Considerations ...................................................................................................... 516 12.6.1 Bias Mitigation .......................................................................................................... 517 12.6.2 Responsible AI .......................................................................................................... 518 12.6.3 Environmental Sustainability .................................................................................... 519 Index 521 Table of ConTenTs
Page 16
xvii Venkata Gunnu is a senior executive director of knowledge management and innovation at JPM Chase. He is an executive with a successful background crafting enterprise-wide data and data science solutions, GenAI, process improvements, and data- and data science-centric products. He is a concept-to-implementation strategist with demonstrated success controlling multiple projects that elevate organizational efficiency while optimizing resources. Venkat is data-focused and analytical, with a track record of automating functions, standardizing data management protocol, and introducing new business intelligence solutions. Shubham Shah is a software engineer with expertise in machine learning, cloud technologies, and AI- powered solutions. He has experience developing and optimizing Retrieval Augmented Generation (RAG) models, as well as integrating AI technologies like ChatGPT and Mistral for smarter, real-time information retrieval. Skilled in building scalable microservices and cloud-based architectures, he is passionate about solving complex challenges, improving system performance, and driving technological innovation. Shubham is always eager to learn, collaborate, and stay ahead in the fast-evolving tech landscape. About the Authors
Page 17
xviii Anvesh Minukuri currently serves as a VP, senior lead ML engineer (LLM) at JP Morgan Chase, specializing in NLP applications. With a fervent interest in data science and artificial intelligence, he boasts more than 12 years in IT and ten years of experience in the analytics field, executing predictive, prescriptive, and GenAI solutions. Holding a master’s degree from Oklahoma State University, he majored in data mining, following his bachelor’s in computer science from JNTU University in India. Originating from South India, he began his career as a software engineer, catering to esteemed Fortune 500 clients such as GE, Cisco, and Tech Mahindra. Additionally, he aided stakeholders in capitalizing on the true value of AI and ML by using actionable data insights and was responsible for overseeing the design of ML. His primary focus lies in crafting data science solutions and machine learning pipeline frameworks to address predictive, prescriptive, and NLP challenges. Proficient in LLM model development, assessment, and optimization, he excels in NLP preprocessing, data storage, infrastructure management, and scaling endeavors. With a wealth of experience in driving adoption across diverse NLP applications, he has contributed significantly to the field through various published papers and posts in the realm of AI/ML. Jayanth Gopu is a seasoned machine learning engineer with 12 years of experience, specializing in Python programming, LLMs, ModelOps, and automation technologies. With a strong background in deploying and optimizing machine learning models, he excels in creating efficient workflows that streamline the model lifecycle, from development to production. By leveraging AWS services, he designs and implements robust cloud-based solutions that enhance scalability and reliability. At an architect level, he has expertise in automation tools like Alteryx and UiPath, enabling the development of sophisticated automated processes that improve operational efficiency. He is known for guiding cross-functional teams and fostering a collaborative environment that encourages innovation and continuous improvement. Passionate about solving complex challenges and driving technological innovation, he is committed to mentoring emerging talent and staying at the forefront of advancements in the rapidly evolving field of machine learning engineering and automation. abouT The auThors
Page 18
xix About the Technical Reviewers Kafui Nukunya is an experienced leader who has successfully led teams at Comcast and Walgreens and is currently serving as the head of customer machine learning and AI at Altice. Kafui holds a PhD in economics from Claremont Graduate University and an MA in economics from Bowling Green State University. With a solid foundation in econometrics, he integrates analytical expertise with cutting-edge machine learning techniques to deliver impactful business results. Throughout his career, Kafui has led the development and implementation of advanced ML models, streamlined business processes, and driven transformative initiatives that have greatly enhanced operational efficiency and customer experience. He is known for his ability to build and guide high-performing teams, fostering a collaborative environment that produces innovative solutions at the intersection of technology and business. Combining technical expertise, leadership acumen, and a strong econometric background, Kafui is dedicated to shaping the future of AI and machine learning, helping organizations harness the full potential of data-driven strategies. Sundar Krishnan is an accomplished AI and data science leader with over 13 years of experience driving innovation and impact across industries. He currently serves as director of AI/ML at Altice/Optimum, where he leads the data science and ML engineering teams to develop solutions that enhance customer experience and enable personalized targeting strategies. Before Altice, Sundar held a leadership role at CVS Health, where he spearheaded initiatives focused on improving member health outcomes through data-driven insights.
Page 19
xx He holds a bachelor’s degree from Government College of Technology, Coimbatore, and a master’s degree from Oklahoma State University, Stillwater. Sundar is also the author of Applied Data Science Using PySpark and regularly shares his expertise through writing on Medium. An active member of the AI community, Sundar frequently participates as a speaker, judge, and mentor in various industry forums and events. abouT The TeChniCal reviewers
Page 20
xxi Acknowledgments This book could not have been written without the participation and support of many incredible individuals. I am profoundly grateful for the encouragement and assistance I received from my friends, family, and colleagues throughout this journey. Their unwavering belief in me, especially during the most challenging times, has been truly invaluable. I would like to express my heartfelt thanks to Dr. Goutam Chakraborty, director of the master’s business analytics program at Oklahoma State University, for introducing me to the field of data science over a decade ago. Serving as a pro-bono seasonal guest lecturer, I had the opportunity to design and deliver sessions on Apache Spark, anomaly detection, and introduction to LLMs, which helped shape the vision for this book. These experiences deepened my engagement with emerging technologies and inspired me to transform that content into a resource for a broader audience, ultimately leading to the creation of this book. A special note of gratitude goes to my parents, Mr. Indrasena Reddy Minukuri and Mrs. Padma Thummala, whose constant motivation has always been a source of strength. I am equally thankful to my life partner, Mrs. Varshitha Yendapally, and my son, Avyaan Minukuri, for their unwavering support and love throughout this journey. I am sincerely grateful to my co-authors, Mr. Shubham Shah and Mr. Jayanth Gopu, for their collaboration and insights. A very special thanks to Mr. Venkata Gunnu, not only for being a co-author and a mentor but also as the first person with whom I discussed the idea of writing this book, and his guidance and encouragement played a key role in bringing this project to life. My deepest appreciation also goes to the technical reviewers of this book, whose meticulous feedback and thoughtful suggestions significantly improved the final work. —Anvesh Minukuri
The above is a preview of the first 20 pages. Register to read the complete e-book.

Support Author

0.00
Total Amount (¥)
0
Donation Count
Please enter an amount Minimum ¥1

You will be redirected to Alipay to complete payment, then return here.

Recommended for You

Loading recommended books...
Failed to load, please try again later
Back to List