From e1949ba21b9a87e19aad3934a256722eecf896a3 Mon Sep 17 00:00:00 2001 From: Rahul Konda Date: Wed, 11 Jun 2025 18:15:49 +0530 Subject: [PATCH 1/2] update/_toctree.yml --- chapters/te/_toctree.yml | 29 ++- chapters/te/chapter1/1.mdx | 160 ++++++++++++++ chapters/te/chapter1/10.mdx | 66 ++++++ chapters/te/chapter1/11.mdx | 21 ++ chapters/te/chapter1/2.mdx | 55 +++++ chapters/te/chapter1/3.mdx | 415 ++++++++++++++++++++++++++++++++++++ chapters/te/chapter1/4.mdx | 191 +++++++++++++++++ chapters/te/chapter1/5.mdx | 263 +++++++++++++++++++++++ chapters/te/chapter1/6.mdx | 224 +++++++++++++++++++ chapters/te/chapter1/7.mdx | 257 ++++++++++++++++++++++ chapters/te/chapter1/8.mdx | 272 +++++++++++++++++++++++ chapters/te/chapter1/9.mdx | 32 +++ 12 files changed, 1983 insertions(+), 2 deletions(-) create mode 100644 chapters/te/chapter1/1.mdx create mode 100644 chapters/te/chapter1/10.mdx create mode 100644 chapters/te/chapter1/11.mdx create mode 100644 chapters/te/chapter1/2.mdx create mode 100644 chapters/te/chapter1/3.mdx create mode 100644 chapters/te/chapter1/4.mdx create mode 100644 chapters/te/chapter1/5.mdx create mode 100644 chapters/te/chapter1/6.mdx create mode 100644 chapters/te/chapter1/7.mdx create mode 100644 chapters/te/chapter1/8.mdx create mode 100644 chapters/te/chapter1/9.mdx diff --git a/chapters/te/_toctree.yml b/chapters/te/_toctree.yml index 4357673bf..189953e47 100644 --- a/chapters/te/_toctree.yml +++ b/chapters/te/_toctree.yml @@ -1,5 +1,30 @@ - title: 0. అమరిక sections: - - local: chapter0/1 - title: పరిచయం + - local: chapter0/1 + title: పరిచయం +- title: 1. ట్రాన్స్‌ఫార్మర్ నమూనాలు + sections: + - local: chapter1/1 + title: పరిచయం + - local: chapter1/2 + title: Natural Language Processing (NLP) మరియు Large Language Models (LLMs) + - local: chapter1/3 + title: ట్రాన్స్‌ఫార్మర్‌లు, అవి ఏమి చేయగలవు? + - local: chapter1/4 + title: ట్రాన్స్‌ఫార్మర్‌లు ఎలా పని చేస్తాయి? + - local: chapter1/5 + title: 🤗 ట్రాన్స్‌ఫార్మర్‌లు పనులను ఎలా పరిష్కరిస్తాయి + - local: chapter1/6 + title: ట్రాన్స్‌ఫార్మర్ ఆర్కిటెక్చర్‌లు + - local: chapter1/7 + title: క్విజ్ + - local: chapter1/8 + title: LLMలతో పనులు చేయడం + - local: chapter1/9 + title: పక్షపాతం మరియు పరిమితులు + - local: chapter1/10 + title: సారాంశం + - local: chapter1/11 + title: ధృవీకరణ పరీక్ష + quiz: 1 diff --git a/chapters/te/chapter1/1.mdx b/chapters/te/chapter1/1.mdx new file mode 100644 index 000000000..ff9f55560 --- /dev/null +++ b/chapters/te/chapter1/1.mdx @@ -0,0 +1,160 @@ +# Introduction[[introduction]] + + + +## Welcome to the 🤗 Course![[welcome-to-the-course]] + + + +This course will teach you about large language models (LLMs) and natural language processing (NLP) using libraries from the [Hugging Face](https://huggingface.co/) ecosystem — [🤗 Transformers](https://github.com/huggingface/transformers), [🤗 Datasets](https://github.com/huggingface/datasets), [🤗 Tokenizers](https://github.com/huggingface/tokenizers), and [🤗 Accelerate](https://github.com/huggingface/accelerate) — as well as the [Hugging Face Hub](https://huggingface.co/models). + +We'll also cover libraries outside the Hugging Face ecosystem. These are amazing contributions to the AI community and incredibly useful tools. + +It's completely free and without ads. + +## Understanding NLP and LLMs[[understanding-nlp-and-llms]] + +While this course was originally focused on NLP (Natural Language Processing), it has evolved to emphasize Large Language Models (LLMs), which represent the latest advancement in the field. + +**What's the difference?** +- **NLP (Natural Language Processing)** is the broader field focused on enabling computers to understand, interpret, and generate human language. NLP encompasses many techniques and tasks such as sentiment analysis, named entity recognition, and machine translation. +- **LLMs (Large Language Models)** are a powerful subset of NLP models characterized by their massive size, extensive training data, and ability to perform a wide range of language tasks with minimal task-specific training. Models like the Llama, GPT, or Claude series are examples of LLMs that have revolutionized what's possible in NLP. + +Throughout this course, you'll learn about both traditional NLP concepts and cutting-edge LLM techniques, as understanding the foundations of NLP is crucial for working effectively with LLMs. + +## What to expect?[[what-to-expect]] + +Here is a brief overview of the course: + +
+Brief overview of the chapters of the course. + +
+ +- Chapters 1 to 4 provide an introduction to the main concepts of the 🤗 Transformers library. By the end of this part of the course, you will be familiar with how Transformer models work and will know how to use a model from the [Hugging Face Hub](https://huggingface.co/models), fine-tune it on a dataset, and share your results on the Hub! +- Chapters 5 to 8 teach the basics of 🤗 Datasets and 🤗 Tokenizers before diving into classic NLP tasks and LLM techniques. By the end of this part, you will be able to tackle the most common language processing challenges by yourself. +- Chapter 9 goes beyond NLP to cover how to build and share demos of your models on the 🤗 Hub. By the end of this part, you will be ready to showcase your 🤗 Transformers application to the world! +- Chapters 10 to 12 dive into advanced LLM topics like fine-tuning, curating high-quality datasets, and building reasoning models. + +This course: + +* Requires a good knowledge of Python +* Is better taken after an introductory deep learning course, such as [fast.ai's](https://www.fast.ai/) [Practical Deep Learning for Coders](https://course.fast.ai/) or one of the programs developed by [DeepLearning.AI](https://www.deeplearning.ai/) +* Does not expect prior [PyTorch](https://pytorch.org/) or [TensorFlow](https://www.tensorflow.org/) knowledge, though some familiarity with either of those will help + +After you've completed this course, we recommend checking out DeepLearning.AI's [Natural Language Processing Specialization](https://www.coursera.org/specializations/natural-language-processing?utm_source=deeplearning-ai&utm_medium=institutions&utm_campaign=20211011-nlp-2-hugging_face-page-nlp-refresh), which covers a wide range of traditional NLP models like naive Bayes and LSTMs that are well worth knowing about! + +## Who are we?[[who-are-we]] + +About the authors: + +[**Abubakar Abid**](https://huggingface.co/abidlabs) completed his PhD at Stanford in applied machine learning. During his PhD, he founded [Gradio](https://github.com/gradio-app/gradio), an open-source Python library that has been used to build over 600,000 machine learning demos. Gradio was acquired by Hugging Face, which is where Abubakar now serves as a machine learning team lead. + +[**Ben Burtenshaw**](https://huggingface.co/burtenshaw) is a Machine Learning Engineer at Hugging Face. He completed his PhD in Natural Language Processing at the University of Antwerp, where he applied Transformer models to generate children stories for the purpose of improving literacy skills. Since then, he has focused on educational materials and tools for the wider community. + +[**Matthew Carrigan**](https://huggingface.co/Rocketknight1) is a Machine Learning Engineer at Hugging Face. He lives in Dublin, Ireland and previously worked as an ML engineer at Parse.ly and before that as a post-doctoral researcher at Trinity College Dublin. He does not believe we're going to get to AGI by scaling existing architectures, but has high hopes for robot immortality regardless. + +[**Lysandre Debut**](https://huggingface.co/lysandre) is a Machine Learning Engineer at Hugging Face and has been working on the 🤗 Transformers library since the very early development stages. His aim is to make NLP accessible for everyone by developing tools with a very simple API. + +[**Sylvain Gugger**](https://huggingface.co/sgugger) is a Research Engineer at Hugging Face and one of the core maintainers of the 🤗 Transformers library. Previously he was a Research Scientist at fast.ai, and he co-wrote _[Deep Learning for Coders with fastai and PyTorch](https://learning.oreilly.com/library/view/deep-learning-for/9781492045519/)_ with Jeremy Howard. The main focus of his research is on making deep learning more accessible, by designing and improving techniques that allow models to train fast on limited resources. + +[**Dawood Khan**](https://huggingface.co/dawoodkhan82) is a Machine Learning Engineer at Hugging Face. He's from NYC and graduated from New York University studying Computer Science. After working as an iOS Engineer for a few years, Dawood quit to start Gradio with his fellow co-founders. Gradio was eventually acquired by Hugging Face. + +[**Merve Noyan**](https://huggingface.co/merve) is a developer advocate at Hugging Face, working on developing tools and building content around them to democratize machine learning for everyone. + +[**Lucile Saulnier**](https://huggingface.co/SaulLu) is a machine learning engineer at Hugging Face, developing and supporting the use of open source tools. She is also actively involved in many research projects in the field of Natural Language Processing such as collaborative training and BigScience. + +[**Lewis Tunstall**](https://huggingface.co/lewtun) is a machine learning engineer at Hugging Face, focused on developing open-source tools and making them accessible to the wider community. He is also a co-author of the O'Reilly book [Natural Language Processing with Transformers](https://www.oreilly.com/library/view/natural-language-processing/9781098136789/). + +[**Leandro von Werra**](https://huggingface.co/lvwerra) is a machine learning engineer in the open-source team at Hugging Face and also a co-author of the O'Reilly book [Natural Language Processing with Transformers](https://www.oreilly.com/library/view/natural-language-processing/9781098136789/). He has several years of industry experience bringing NLP projects to production by working across the whole machine learning stack.. + +## FAQ[[faq]] + +Here are some answers to frequently asked questions: + +- **Does taking this course lead to a certification?** +Currently we do not have any certification for this course. However, we are working on a certification program for the Hugging Face ecosystem -- stay tuned! + +- **How much time should I spend on this course?** +Each chapter in this course is designed to be completed in 1 week, with approximately 6-8 hours of work per week. However, you can take as much time as you need to complete the course. + +- **Where can I ask a question if I have one?** +If you have a question about any section of the course, just click on the "*Ask a question*" banner at the top of the page to be automatically redirected to the right section of the [Hugging Face forums](https://discuss.huggingface.co/): + +Link to the Hugging Face forums + +Note that a list of [project ideas](https://discuss.huggingface.co/c/course/course-event/25) is also available on the forums if you wish to practice more once you have completed the course. + +- **Where can I get the code for the course?** +For each section, click on the banner at the top of the page to run the code in either Google Colab or Amazon SageMaker Studio Lab: + +Link to the Hugging Face course notebooks + +The Jupyter notebooks containing all the code from the course are hosted on the [`huggingface/notebooks`](https://github.com/huggingface/notebooks) repo. If you wish to generate them locally, check out the instructions in the [`course`](https://github.com/huggingface/course#-jupyter-notebooks) repo on GitHub. + + +- **How can I contribute to the course?** +There are many ways to contribute to the course! If you find a typo or a bug, please open an issue on the [`course`](https://github.com/huggingface/course) repo. If you would like to help translate the course into your native language, check out the instructions [here](https://github.com/huggingface/course#translating-the-course-into-your-language). + +- ** What were the choices made for each translation?** +Each translation has a glossary and `TRANSLATING.txt` file that details the choices that were made for machine learning jargon etc. You can find an example for German [here](https://github.com/huggingface/course/blob/main/chapters/de/TRANSLATING.txt). + + +- **Can I reuse this course?** +Of course! The course is released under the permissive [Apache 2 license](https://www.apache.org/licenses/LICENSE-2.0.html). This means that you must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use. If you would like to cite the course, please use the following BibTeX: + +``` +@misc{huggingfacecourse, + author = {Hugging Face}, + title = {The Hugging Face Course, 2022}, + howpublished = "\url{https://huggingface.co/course}", + year = {2022}, + note = "[Online; accessed ]" +} +``` + +## Languages and translations[[languages-and-translations]] + +Thanks to our wonderful community, the course is available in many languages beyond English 🔥! Check out the table below to see which languages are available and who contributed to the translations: + +| Language | Authors | +|:------------------------------------------------------------------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| [French](https://huggingface.co/course/fr/chapter1/1) | [@lbourdois](https://github.com/lbourdois), [@ChainYo](https://github.com/ChainYo), [@melaniedrevet](https://github.com/melaniedrevet), [@abdouaziz](https://github.com/abdouaziz) | +| [Vietnamese](https://huggingface.co/course/vi/chapter1/1) | [@honghanhh](https://github.com/honghanhh) | +| [Chinese (simplified)](https://huggingface.co/course/zh-CN/chapter1/1) | [@zhlhyx](https://github.com/zhlhyx), [petrichor1122](https://github.com/petrichor1122), [@yaoqih](https://github.com/yaoqih) | +| [Bengali](https://huggingface.co/course/bn/chapter1/1) (WIP) | [@avishek-018](https://github.com/avishek-018), [@eNipu](https://github.com/eNipu) | +| [German](https://huggingface.co/course/de/chapter1/1) (WIP) | [@JesperDramsch](https://github.com/JesperDramsch), [@MarcusFra](https://github.com/MarcusFra), [@fabridamicelli](https://github.com/fabridamicelli) | +| [Spanish](https://huggingface.co/course/es/chapter1/1) (WIP) | [@camartinezbu](https://github.com/camartinezbu), [@munozariasjm](https://github.com/munozariasjm), [@fordaz](https://github.com/fordaz) | +| [Persian](https://huggingface.co/course/fa/chapter1/1) (WIP) | [@jowharshamshiri](https://github.com/jowharshamshiri), [@schoobani](https://github.com/schoobani) | +| [Gujarati](https://huggingface.co/course/gu/chapter1/1) (WIP) | [@pandyaved98](https://github.com/pandyaved98) | +| [Hebrew](https://huggingface.co/course/he/chapter1/1) (WIP) | [@omer-dor](https://github.com/omer-dor) | +| [Hindi](https://huggingface.co/course/hi/chapter1/1) (WIP) | [@pandyaved98](https://github.com/pandyaved98) | +| [Bahasa Indonesia](https://huggingface.co/course/id/chapter1/1) (WIP) | [@gstdl](https://github.com/gstdl) | +| [Italian](https://huggingface.co/course/it/chapter1/1) (WIP) | [@CaterinaBi](https://github.com/CaterinaBi), [@ClonedOne](https://github.com/ClonedOne), [@Nolanogenn](https://github.com/Nolanogenn), [@EdAbati](https://github.com/EdAbati), [@gdacciaro](https://github.com/gdacciaro) | +| [Japanese](https://huggingface.co/course/ja/chapter1/1) (WIP) | [@hiromu166](https://github.com/@hiromu166), [@younesbelkada](https://github.com/@younesbelkada), [@HiromuHota](https://github.com/@HiromuHota) | +| [Korean](https://huggingface.co/course/ko/chapter1/1) (WIP) | [@Doohae](https://github.com/Doohae), [@wonhyeongseo](https://github.com/wonhyeongseo), [@dlfrnaos19](https://github.com/dlfrnaos19) | +| [Portuguese](https://huggingface.co/course/pt/chapter1/1) (WIP) | [@johnnv1](https://github.com/johnnv1), [@victorescosta](https://github.com/victorescosta), [@LincolnVS](https://github.com/LincolnVS) | +| [Russian](https://huggingface.co/course/ru/chapter1/1) (WIP) | [@pdumin](https://github.com/pdumin), [@svv73](https://github.com/svv73) | +| [Thai](https://huggingface.co/course/th/chapter1/1) (WIP) | [@peeraponw](https://github.com/peeraponw), [@a-krirk](https://github.com/a-krirk), [@jomariya23156](https://github.com/jomariya23156), [@ckingkan](https://github.com/ckingkan) | +| [Turkish](https://huggingface.co/course/tr/chapter1/1) (WIP) | [@tanersekmen](https://github.com/tanersekmen), [@mertbozkir](https://github.com/mertbozkir), [@ftarlaci](https://github.com/ftarlaci), [@akkasayaz](https://github.com/akkasayaz) | +| [Chinese (traditional)](https://huggingface.co/course/zh-TW/chapter1/1) (WIP) | [@davidpeng86](https://github.com/davidpeng86) | + +For some languages, the [course YouTube videos](https://youtube.com/playlist?list=PLo2EIpI_JMQvWfQndUesu0nPBAtZ9gP1o) have subtitles in the language. You can enable them by first clicking the _CC_ button in the bottom right corner of the video. Then, under the settings icon ⚙️, you can select the language you want by selecting the _Subtitles/CC_ option. + +Activating subtitles for the Hugging Face course YouTube videos + + +Don't see your language in the above table or you'd like to contribute to an existing translation? You can help us translate the course by following the instructions here. + + +## Let's go 🚀 + +Are you ready to roll? In this chapter, you will learn: + +* How to use the `pipeline()` function to solve NLP tasks such as text generation and classification +* About the Transformer architecture +* How to distinguish between encoder, decoder, and encoder-decoder architectures and use cases + diff --git a/chapters/te/chapter1/10.mdx b/chapters/te/chapter1/10.mdx new file mode 100644 index 000000000..b5d646a3c --- /dev/null +++ b/chapters/te/chapter1/10.mdx @@ -0,0 +1,66 @@ +# Summary[[summary]] + + + +In this chapter, you've been introduced to the fundamentals of Transformer models, Large Language Models (LLMs), and how they're revolutionizing AI and beyond. + +## Key concepts covered + +### Natural Language Processing and LLMs + +We explored what NLP is and how Large Language Models have transformed the field. You learned that: +- NLP encompasses a wide range of tasks from classification to generation +- LLMs are powerful models trained on massive amounts of text data +- These models can perform multiple tasks within a single architecture +- Despite their capabilities, LLMs have limitations including hallucinations and bias + +### Transformer capabilities + +You saw how the `pipeline()` function from 🤗 Transformers makes it easy to use pre-trained models for various tasks: +- Text classification, token classification, and question answering +- Text generation and summarization +- Translation and other sequence-to-sequence tasks +- Speech recognition and image classification + +### Transformer architecture + +We discussed how Transformer models work at a high level, including: +- The importance of the attention mechanism +- How transfer learning enables models to adapt to specific tasks +- The three main architectural variants: encoder-only, decoder-only, and encoder-decoder + +### Model architectures and their applications +A key aspect of this chapter was understanding which architecture to use for different tasks: + +| Model | Examples | Tasks | +|-----------------|--------------------------------------------|----------------------------------------------------------------------------------| +| Encoder-only | BERT, DistilBERT, ModernBERT | Sentence classification, named entity recognition, extractive question answering | +| Decoder-only | GPT, LLaMA, Gemma, SmolLM | Text generation, conversational AI, creative writing | +| Encoder-decoder | BART, T5, Marian, mBART | Summarization, translation, generative question answering | + +### Modern LLM developments +You also learned about recent developments in the field: +- How LLMs have grown in size and capability over time +- The concept of scaling laws and how they guide model development +- Specialized attention mechanisms that help models process longer sequences +- The two-phase training approach of pretraining and instruction tuning + +### Practical applications +Throughout the chapter, you've seen how these models can be applied to real-world problems: +- Using the Hugging Face Hub to find and use pre-trained models +- Leveraging the Inference API to test models directly in your browser +- Understanding which models are best suited for specific tasks + +## Looking ahead + +Now that you have a solid understanding of what Transformer models are and how they work at a high level, you're ready to dive deeper into how to use them effectively. In the next chapters, you'll learn how to: + +- Use the Transformers library to load and fine-tune models +- Process different types of data for model input +- Adapt pre-trained models to your specific tasks +- Deploy models for practical applications + +The foundation you've built in this chapter will serve you well as you explore more advanced topics and techniques in the coming sections. diff --git a/chapters/te/chapter1/11.mdx b/chapters/te/chapter1/11.mdx new file mode 100644 index 000000000..dddddf271 --- /dev/null +++ b/chapters/te/chapter1/11.mdx @@ -0,0 +1,21 @@ +# Exam Time! + +It's time to put your knowledge to the test! We've prepared a short quiz for you to test your understanding of the concepts covered in this chapter. + +To take the quiz, you will need to follow these steps: + +1. Sign in to your Hugging Face account. +2. Answer the questions in the quiz. +3. Submit your answers. + + +## Multiple Choice Quiz + +In this quiz, you will be asked to select the correct answer from a list of options. We'll test you on the fundamentals of supervised finetuning. + + diff --git a/chapters/te/chapter1/2.mdx b/chapters/te/chapter1/2.mdx new file mode 100644 index 000000000..13fa4eef2 --- /dev/null +++ b/chapters/te/chapter1/2.mdx @@ -0,0 +1,55 @@ +# Natural Language Processing and Large Language Models[[natural-language-processing-and-large-language-models]] + + + +Before jumping into Transformer models, let's do a quick overview of what natural language processing is, how large language models have transformed the field, and why we care about it. + +## What is NLP?[[what-is-nlp]] + + + +NLP is a field of linguistics and machine learning focused on understanding everything related to human language. The aim of NLP tasks is not only to understand single words individually, but to be able to understand the context of those words. + +The following is a list of common NLP tasks, with some examples of each: + +- **Classifying whole sentences**: Getting the sentiment of a review, detecting if an email is spam, determining if a sentence is grammatically correct or whether two sentences are logically related or not +- **Classifying each word in a sentence**: Identifying the grammatical components of a sentence (noun, verb, adjective), or the named entities (person, location, organization) +- **Generating text content**: Completing a prompt with auto-generated text, filling in the blanks in a text with masked words +- **Extracting an answer from a text**: Given a question and a context, extracting the answer to the question based on the information provided in the context +- **Generating a new sentence from an input text**: Translating a text into another language, summarizing a text + +NLP isn't limited to written text though. It also tackles complex challenges in speech recognition and computer vision, such as generating a transcript of an audio sample or a description of an image. + +## The Rise of Large Language Models (LLMs)[[rise-of-llms]] + +In recent years, the field of NLP has been revolutionized by Large Language Models (LLMs). These models, which include architectures like GPT (Generative Pre-trained Transformer) and [Llama](https://huggingface.co/meta-llama), have transformed what's possible in language processing. + + + +A large language model (LLM) is an AI model trained on massive amounts of text data that can understand and generate human-like text, recognize patterns in language, and perform a wide variety of language tasks without task-specific training. They represent a significant advancement in the field of natural language processing (NLP). + + + +LLMs are characterized by: +- **Scale**: They contain millions, billions, or even hundreds of billions of parameters +- **General capabilities**: They can perform multiple tasks without task-specific training +- **In-context learning**: They can learn from examples provided in the prompt +- **Emergent abilities**: As these models grow in size, they demonstrate capabilities that weren't explicitly programmed or anticipated + +The advent of LLMs has shifted the paradigm from building specialized models for specific NLP tasks to using a single, large model that can be prompted or fine-tuned to address a wide range of language tasks. This has made sophisticated language processing more accessible while also introducing new challenges in areas like efficiency, ethics, and deployment. + +However, LLMs also have important limitations: +- **Hallucinations**: They can generate incorrect information confidently +- **Lack of true understanding**: They lack true understanding of the world and operate purely on statistical patterns +- **Bias**: They may reproduce biases present in their training data or inputs. +- **Context windows**: They have limited context windows (though this is improving) +- **Computational resources**: They require significant computational resources + +## Why is language processing challenging?[[why-is-it-challenging]] + +Computers don't process information in the same way as humans. For example, when we read the sentence "I am hungry," we can easily understand its meaning. Similarly, given two sentences such as "I am hungry" and "I am sad," we're able to easily determine how similar they are. For machine learning (ML) models, such tasks are more difficult. The text needs to be processed in a way that enables the model to learn from it. And because language is complex, we need to think carefully about how this processing must be done. There has been a lot of research done on how to represent text, and we will look at some methods in the next chapter. + +Even with the advances in LLMs, many fundamental challenges remain. These include understanding ambiguity, cultural context, sarcasm, and humor. LLMs address these challenges through massive training on diverse datasets, but still often fall short of human-level understanding in many complex scenarios. diff --git a/chapters/te/chapter1/3.mdx b/chapters/te/chapter1/3.mdx new file mode 100644 index 000000000..df13888ec --- /dev/null +++ b/chapters/te/chapter1/3.mdx @@ -0,0 +1,415 @@ +# Transformers, what can they do?[[transformers-what-can-they-do]] + + + +In this section, we will look at what Transformer models can do and use our first tool from the 🤗 Transformers library: the `pipeline()` function. + + +👀 See that Open in Colab button on the top right? Click on it to open a Google Colab notebook with all the code samples of this section. This button will be present in any section containing code examples. + +If you want to run the examples locally, we recommend taking a look at the setup. + + +## Transformers are everywhere![[transformers-are-everywhere]] + +Transformer models are used to solve all kinds of tasks across different modalities, including natural language processing (NLP), computer vision, audio processing, and more. Here are some of the companies and organizations using Hugging Face and Transformer models, who also contribute back to the community by sharing their models: + +Companies using Hugging Face + +The [🤗 Transformers library](https://github.com/huggingface/transformers) provides the functionality to create and use those shared models. The [Model Hub](https://huggingface.co/models) contains millions of pretrained models that anyone can download and use. You can also upload your own models to the Hub! + + + +⚠️ The Hugging Face Hub is not limited to Transformer models. Anyone can share any kind of models or datasets they want! Create a huggingface.co account to benefit from all available features! + + + +Before diving into how Transformer models work under the hood, let's look at a few examples of how they can be used to solve some interesting NLP problems. + +## Working with pipelines[[working-with-pipelines]] + + + +The most basic object in the 🤗 Transformers library is the `pipeline()` function. It connects a model with its necessary preprocessing and postprocessing steps, allowing us to directly input any text and get an intelligible answer: + +```python +from transformers import pipeline + +classifier = pipeline("sentiment-analysis") +classifier("I've been waiting for a HuggingFace course my whole life.") +``` + +```python out +[{'label': 'POSITIVE', 'score': 0.9598047137260437}] +``` + +We can even pass several sentences! + +```python +classifier( + ["I've been waiting for a HuggingFace course my whole life.", "I hate this so much!"] +) +``` + +```python out +[{'label': 'POSITIVE', 'score': 0.9598047137260437}, + {'label': 'NEGATIVE', 'score': 0.9994558095932007}] +``` + +By default, this pipeline selects a particular pretrained model that has been fine-tuned for sentiment analysis in English. The model is downloaded and cached when you create the `classifier` object. If you rerun the command, the cached model will be used instead and there is no need to download the model again. + +There are three main steps involved when you pass some text to a pipeline: + +1. The text is preprocessed into a format the model can understand. +2. The preprocessed inputs are passed to the model. +3. The predictions of the model are post-processed, so you can make sense of them. + +## Available pipelines for different modalities + +The `pipeline()` function supports multiple modalities, allowing you to work with text, images, audio, and even multimodal tasks. In this course we'll focus on text tasks, but it's useful to understand the transformer architecture's potential, so we'll briefly outline it. + +Here's an overview of what's available: + + + +For a full and updated list of pipelines, see the [🤗 Transformers documentation](https://huggingface.co/docs/hub/en/models-tasks). + + + +### Text pipelines + +- `text-generation`: Generate text from a prompt +- `text-classification`: Classify text into predefined categories +- `summarization`: Create a shorter version of a text while preserving key information +- `translation`: Translate text from one language to another +- `zero-shot-classification`: Classify text without prior training on specific labels +- `feature-extraction`: Extract vector representations of text + +### Image pipelines + +- `image-to-text`: Generate text descriptions of images +- `image-classification`: Identify objects in an image +- `object-detection`: Locate and identify objects in images + +### Audio pipelines + +- `automatic-speech-recognition`: Convert speech to text +- `audio-classification`: Classify audio into categories +- `text-to-speech`: Convert text to spoken audio + +### Multimodal pipelines + +- `image-text-to-text`: Respond to an image based on a text prompt + +Let's explore some of these pipelines in more detail! + +## Zero-shot classification[[zero-shot-classification]] + +We'll start by tackling a more challenging task where we need to classify texts that haven't been labelled. This is a common scenario in real-world projects because annotating text is usually time-consuming and requires domain expertise. For this use case, the `zero-shot-classification` pipeline is very powerful: it allows you to specify which labels to use for the classification, so you don't have to rely on the labels of the pretrained model. You've already seen how the model can classify a sentence as positive or negative using those two labels — but it can also classify the text using any other set of labels you like. + +```python +from transformers import pipeline + +classifier = pipeline("zero-shot-classification") +classifier( + "This is a course about the Transformers library", + candidate_labels=["education", "politics", "business"], +) +``` + +```python out +{'sequence': 'This is a course about the Transformers library', + 'labels': ['education', 'business', 'politics'], + 'scores': [0.8445963859558105, 0.111976258456707, 0.043427448719739914]} +``` + +This pipeline is called _zero-shot_ because you don't need to fine-tune the model on your data to use it. It can directly return probability scores for any list of labels you want! + + + +✏️ **Try it out!** Play around with your own sequences and labels and see how the model behaves. + + + + +## Text generation[[text-generation]] + +Now let's see how to use a pipeline to generate some text. The main idea here is that you provide a prompt and the model will auto-complete it by generating the remaining text. This is similar to the predictive text feature that is found on many phones. Text generation involves randomness, so it's normal if you don't get the same results as shown below. + +```python +from transformers import pipeline + +generator = pipeline("text-generation") +generator("In this course, we will teach you how to") +``` + +```python out +[{'generated_text': 'In this course, we will teach you how to understand and use ' + 'data flow and data interchange when handling user data. We ' + 'will be working with one or more of the most commonly used ' + 'data flows — data flows of various types, as seen by the ' + 'HTTP'}] +``` + +You can control how many different sequences are generated with the argument `num_return_sequences` and the total length of the output text with the argument `max_length`. + + + +✏️ **Try it out!** Use the `num_return_sequences` and `max_length` arguments to generate two sentences of 15 words each. + + + +## Using any model from the Hub in a pipeline[[using-any-model-from-the-hub-in-a-pipeline]] + +The previous examples used the default model for the task at hand, but you can also choose a particular model from the Hub to use in a pipeline for a specific task — say, text generation. Go to the [Model Hub](https://huggingface.co/models) and click on the corresponding tag on the left to display only the supported models for that task. You should get to a page like [this one](https://huggingface.co/models?pipeline_tag=text-generation). + +Let's try the [`HuggingFaceTB/SmolLM2-360M`](https://huggingface.co/HuggingFaceTB/SmolLM2-360M) model! Here's how to load it in the same pipeline as before: + +```python +from transformers import pipeline + +generator = pipeline("text-generation", model="HuggingFaceTB/SmolLM2-360M") +generator( + "In this course, we will teach you how to", + max_length=30, + num_return_sequences=2, +) +``` + +```python out +[{'generated_text': 'In this course, we will teach you how to manipulate the world and ' + 'move your mental and physical capabilities to your advantage.'}, + {'generated_text': 'In this course, we will teach you how to become an expert and ' + 'practice realtime, and with a hands on experience on both real ' + 'time and real'}] +``` + +You can refine your search for a model by clicking on the language tags, and pick a model that will generate text in another language. The Model Hub even contains checkpoints for multilingual models that support several languages. + +Once you select a model by clicking on it, you'll see that there is a widget enabling you to try it directly online. This way you can quickly test the model's capabilities before downloading it. + + + +✏️ **Try it out!** Use the filters to find a text generation model for another language. Feel free to play with the widget and use it in a pipeline! + + + +### Inference Providers[[inference-providers]] + +All the models can be tested directly through your browser using the Inference Providers, which is available on the Hugging Face [website](https://huggingface.co/docs/inference-providers/en/index). You can play with the model directly on this page by inputting custom text and watching the model process the input data. + +Inference Providers that powers the widget is also available as a paid product, which comes in handy if you need it for your workflows. See the [pricing page](https://huggingface.co/docs/inference-providers/en/pricing) for more details. + +## Mask filling[[mask-filling]] + +The next pipeline you'll try is `fill-mask`. The idea of this task is to fill in the blanks in a given text: + +```python +from transformers import pipeline + +unmasker = pipeline("fill-mask") +unmasker("This course will teach you all about models.", top_k=2) +``` + +```python out +[{'sequence': 'This course will teach you all about mathematical models.', + 'score': 0.19619831442832947, + 'token': 30412, + 'token_str': ' mathematical'}, + {'sequence': 'This course will teach you all about computational models.', + 'score': 0.04052725434303284, + 'token': 38163, + 'token_str': ' computational'}] +``` + +The `top_k` argument controls how many possibilities you want to be displayed. Note that here the model fills in the special `` word, which is often referred to as a *mask token*. Other mask-filling models might have different mask tokens, so it's always good to verify the proper mask word when exploring other models. One way to check it is by looking at the mask word used in the widget. + + + +✏️ **Try it out!** Search for the `bert-base-cased` model on the Hub and identify its mask word in the Inference API widget. What does this model predict for the sentence in our `pipeline` example above? + + + +## Named entity recognition[[named-entity-recognition]] + +Named entity recognition (NER) is a task where the model has to find which parts of the input text correspond to entities such as persons, locations, or organizations. Let's look at an example: + +```python +from transformers import pipeline + +ner = pipeline("ner", grouped_entities=True) +ner("My name is Sylvain and I work at Hugging Face in Brooklyn.") +``` + +```python out +[{'entity_group': 'PER', 'score': 0.99816, 'word': 'Sylvain', 'start': 11, 'end': 18}, + {'entity_group': 'ORG', 'score': 0.97960, 'word': 'Hugging Face', 'start': 33, 'end': 45}, + {'entity_group': 'LOC', 'score': 0.99321, 'word': 'Brooklyn', 'start': 49, 'end': 57} +] +``` + +Here the model correctly identified that Sylvain is a person (PER), Hugging Face an organization (ORG), and Brooklyn a location (LOC). + +We pass the option `grouped_entities=True` in the pipeline creation function to tell the pipeline to regroup together the parts of the sentence that correspond to the same entity: here the model correctly grouped "Hugging" and "Face" as a single organization, even though the name consists of multiple words. In fact, as we will see in the next chapter, the preprocessing even splits some words into smaller parts. For instance, `Sylvain` is split into four pieces: `S`, `##yl`, `##va`, and `##in`. In the post-processing step, the pipeline successfully regrouped those pieces. + + + +✏️ **Try it out!** Search the Model Hub for a model able to do part-of-speech tagging (usually abbreviated as POS) in English. What does this model predict for the sentence in the example above? + + + +## Question answering[[question-answering]] + +The `question-answering` pipeline answers questions using information from a given context: + +```python +from transformers import pipeline + +question_answerer = pipeline("question-answering") +question_answerer( + question="Where do I work?", + context="My name is Sylvain and I work at Hugging Face in Brooklyn", +) +``` + +```python out +{'score': 0.6385916471481323, 'start': 33, 'end': 45, 'answer': 'Hugging Face'} +``` + +Note that this pipeline works by extracting information from the provided context; it does not generate the answer. + +## Summarization[[summarization]] + +Summarization is the task of reducing a text into a shorter text while keeping all (or most) of the important aspects referenced in the text. Here's an example: + +```python +from transformers import pipeline + +summarizer = pipeline("summarization") +summarizer( + """ + America has changed dramatically during recent years. Not only has the number of + graduates in traditional engineering disciplines such as mechanical, civil, + electrical, chemical, and aeronautical engineering declined, but in most of + the premier American universities engineering curricula now concentrate on + and encourage largely the study of engineering science. As a result, there + are declining offerings in engineering subjects dealing with infrastructure, + the environment, and related issues, and greater concentration on high + technology subjects, largely supporting increasingly complex scientific + developments. While the latter is important, it should not be at the expense + of more traditional engineering. + + Rapidly developing economies such as China and India, as well as other + industrial countries in Europe and Asia, continue to encourage and advance + the teaching of engineering. Both China and India, respectively, graduate + six and eight times as many traditional engineers as does the United States. + Other industrial countries at minimum maintain their output, while America + suffers an increasingly serious decline in the number of engineering graduates + and a lack of well-educated engineers. +""" +) +``` + +```python out +[{'summary_text': ' America has changed dramatically during recent years . The ' + 'number of engineering graduates in the U.S. has declined in ' + 'traditional engineering disciplines such as mechanical, civil ' + ', electrical, chemical, and aeronautical engineering . Rapidly ' + 'developing economies such as China and India, as well as other ' + 'industrial countries in Europe and Asia, continue to encourage ' + 'and advance engineering .'}] +``` + +Like with text generation, you can specify a `max_length` or a `min_length` for the result. + + +## Translation[[translation]] + +For translation, you can use a default model if you provide a language pair in the task name (such as `"translation_en_to_fr"`), but the easiest way is to pick the model you want to use on the [Model Hub](https://huggingface.co/models). Here we'll try translating from French to English: + +```python +from transformers import pipeline + +translator = pipeline("translation", model="Helsinki-NLP/opus-mt-fr-en") +translator("Ce cours est produit par Hugging Face.") +``` + +```python out +[{'translation_text': 'This course is produced by Hugging Face.'}] +``` + +Like with text generation and summarization, you can specify a `max_length` or a `min_length` for the result. + + + +✏️ **Try it out!** Search for translation models in other languages and try to translate the previous sentence into a few different languages. + + + +## Image and audio pipelines + +Beyond text, Transformer models can also work with images and audio. Here are a few examples: + +### Image classification + +```python +from transformers import pipeline + +image_classifier = pipeline( + task="image-classification", model="google/vit-base-patch16-224" +) +result = image_classifier( + "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg" +) +print(result) +``` + +```python out +[{'label': 'lynx, catamount', 'score': 0.43350091576576233}, + {'label': 'cougar, puma, catamount, mountain lion, painter, panther, Felis concolor', + 'score': 0.034796204417943954}, + {'label': 'snow leopard, ounce, Panthera uncia', + 'score': 0.03240183740854263}, + {'label': 'Egyptian cat', 'score': 0.02394474856555462}, + {'label': 'tiger cat', 'score': 0.02288915030658245}] +``` + +### Automatic speech recognition + +```python +from transformers import pipeline + +transcriber = pipeline( + task="automatic-speech-recognition", model="openai/whisper-large-v3" +) +result = transcriber( + "https://huggingface.co/datasets/Narsil/asr_dummy/resolve/main/mlk.flac" +) +print(result) +``` + +```python out +{'text': ' I have a dream that one day this nation will rise up and live out the true meaning of its creed.'} +``` + +## Combining data from multiple sources + +One powerful application of Transformer models is their ability to combine and process data from multiple sources. This is especially useful when you need to: + +1. Search across multiple databases or repositories +2. Consolidate information from different formats (text, images, audio) +3. Create a unified view of related information + +For example, you could build a system that: +- Searches for information across databases in multiple modalities like text and image. +- Combines results from different sources into a single coherent response. For example, from an audio file and text description. +- Presents the most relevant information from a database of documents and metadata. + +## Conclusion + +The pipelines shown in this chapter are mostly for demonstrative purposes. They were programmed for specific tasks and cannot perform variations of them. In the next chapter, you'll learn what's inside a `pipeline()` function and how to customize its behavior. diff --git a/chapters/te/chapter1/4.mdx b/chapters/te/chapter1/4.mdx new file mode 100644 index 000000000..3870b541f --- /dev/null +++ b/chapters/te/chapter1/4.mdx @@ -0,0 +1,191 @@ +# How do Transformers work?[[how-do-transformers-work]] + + + +In this section, we will take a look at the architecture of Transformer models and dive deeper into the concepts of attention, encoder-decoder architecture, and more. + + + +🚀 We're taking things up a notch here. This section is detailed and technical, so don't worry if you don't understand everything right away. We'll come back to these concepts later in the course. + + + +## A bit of Transformer history[[a-bit-of-transformer-history]] + +Here are some reference points in the (short) history of Transformer models: + +
+A brief chronology of Transformers models. + +
+ +The [Transformer architecture](https://arxiv.org/abs/1706.03762) was introduced in June 2017. The focus of the original research was on translation tasks. This was followed by the introduction of several influential models, including: + +- **June 2018**: [GPT](https://cdn.openai.com/research-covers/language-unsupervised/language_understanding_paper.pdf), the first pretrained Transformer model, used for fine-tuning on various NLP tasks and obtained state-of-the-art results + +- **October 2018**: [BERT](https://arxiv.org/abs/1810.04805), another large pretrained model, this one designed to produce better summaries of sentences (more on this in the next chapter!) + +- **February 2019**: [GPT-2](https://cdn.openai.com/better-language-models/language_models_are_unsupervised_multitask_learners.pdf), an improved (and bigger) version of GPT that was not immediately publicly released due to ethical concerns + +- **October 2019**: [T5](https://huggingface.co/papers/1910.10683), A multi-task focused implementation of the sequence-to-sequence Transformer architecture. + +- **May 2020**, [GPT-3](https://huggingface.co/papers/2005.14165), an even bigger version of GPT-2 that is able to perform well on a variety of tasks without the need for fine-tuning (called _zero-shot learning_) + +- **January 2022**: [InstructGPT](https://huggingface.co/papers/2203.02155), a version of GPT-3 that was trained to follow instructions better +This list is far from comprehensive, and is just meant to highlight a few of the different kinds of Transformer models. Broadly, they can be grouped into three categories: + +- **January 2023**: [Llama](https://huggingface.co/papers/2302.13971), a large language model that is able to generate text in a variety of languages. + +- **March 2023**: [Mistral](https://huggingface.co/papers/2310.06825), a 7-billion-parameter language model that outperforms Llama 2 13B across all evaluated benchmarks, leveraging grouped-query attention for faster inference and sliding window attention to handle sequences of arbitrary length. + +- **May 2024**: [Gemma 2](https://huggingface.co/papers/2408.00118), a family of lightweight, state-of-the-art open models ranging from 2B to 27B parameters that incorporate interleaved local-global attentions and group-query attention, with smaller models trained using knowledge distillation to deliver performance competitive with models 2-3 times larger. + +- **November 2024**: [SmolLM2](https://huggingface.co/papers/2502.02737), a state-of-the-art small language model (135 million to 1.7 billion parameters) that achieves impressive performance despite its compact size, and unlocking new possibilities for mobile and edge devices. + +- GPT-like (also called _auto-regressive_ Transformer models) +- BERT-like (also called _auto-encoding_ Transformer models) +- T5-like (also called _sequence-to-sequence_ Transformer models) + +We will dive into these families in more depth later on. + +## Transformers are language models[[transformers-are-language-models]] + +All the Transformer models mentioned above (GPT, BERT, T5, etc.) have been trained as *language models*. This means they have been trained on large amounts of raw text in a self-supervised fashion. + +Self-supervised learning is a type of training in which the objective is automatically computed from the inputs of the model. That means that humans are not needed to label the data! + +This type of model develops a statistical understanding of the language it has been trained on, but it's less useful for specific practical tasks. Because of this, the general pretrained model then goes through a process called *transfer learning* or *fine-tuning*. During this process, the model is fine-tuned in a supervised way -- that is, using human-annotated labels -- on a given task. + +An example of a task is predicting the next word in a sentence having read the *n* previous words. This is called *causal language modeling* because the output depends on the past and present inputs, but not the future ones. + +
+Example of causal language modeling in which the next word from a sentence is predicted. + +
+ +Another example is *masked language modeling*, in which the model predicts a masked word in the sentence. + +
+Example of masked language modeling in which a masked word from a sentence is predicted. + +
+ +## Transformers are big models[[transformers-are-big-models]] + +Apart from a few outliers (like DistilBERT), the general strategy to achieve better performance is by increasing the models' sizes as well as the amount of data they are pretrained on. + +
+Number of parameters of recent Transformers models +
+ +Unfortunately, training a model, especially a large one, requires a large amount of data. This becomes very costly in terms of time and compute resources. It even translates to environmental impact, as can be seen in the following graph. + +
+The carbon footprint of a large language model. + +
+ + + +And this is showing a project for a (very big) model led by a team consciously trying to reduce the environmental impact of pretraining. The footprint of running lots of trials to get the best hyperparameters would be even higher. + +Imagine if each time a research team, a student organization, or a company wanted to train a model, it did so from scratch. This would lead to huge, unnecessary global costs! + +This is why sharing language models is paramount: sharing the trained weights and building on top of already trained weights reduces the overall compute cost and carbon footprint of the community. + +By the way, you can evaluate the carbon footprint of your models' training through several tools. For example [ML CO2 Impact](https://mlco2.github.io/impact/) or [Code Carbon]( https://codecarbon.io/) which is integrated in 🤗 Transformers. To learn more about this, you can read this [blog post](https://huggingface.co/blog/carbon-emissions-on-the-hub) which will show you how to generate an `emissions.csv` file with an estimate of the footprint of your training, as well as the [documentation](https://huggingface.co/docs/hub/model-cards-co2) of 🤗 Transformers addressing this topic. + + +## Transfer Learning[[transfer-learning]] + + + +*Pretraining* is the act of training a model from scratch: the weights are randomly initialized, and the training starts without any prior knowledge. + +
+The pretraining of a language model is costly in both time and money. + +
+ +This pretraining is usually done on very large amounts of data. Therefore, it requires a very large corpus of data, and training can take up to several weeks. + +*Fine-tuning*, on the other hand, is the training done **after** a model has been pretrained. To perform fine-tuning, you first acquire a pretrained language model, then perform additional training with a dataset specific to your task. Wait -- why not simply train the model for your final use case from the start (**scratch**)? There are a couple of reasons: + +* The pretrained model was already trained on a dataset that has some similarities with the fine-tuning dataset. The fine-tuning process is thus able to take advantage of knowledge acquired by the initial model during pretraining (for instance, with NLP problems, the pretrained model will have some kind of statistical understanding of the language you are using for your task). +* Since the pretrained model was already trained on lots of data, the fine-tuning requires way less data to get decent results. +* For the same reason, the amount of time and resources needed to get good results are much lower. + +For example, one could leverage a pretrained model trained on the English language and then fine-tune it on an arXiv corpus, resulting in a science/research-based model. The fine-tuning will only require a limited amount of data: the knowledge the pretrained model has acquired is "transferred," hence the term *transfer learning*. + +
+The fine-tuning of a language model is cheaper than pretraining in both time and money. + +
+ +Fine-tuning a model therefore has lower time, data, financial, and environmental costs. It is also quicker and easier to iterate over different fine-tuning schemes, as the training is less constraining than a full pretraining. + +This process will also achieve better results than training from scratch (unless you have lots of data), which is why you should always try to leverage a pretrained model -- one as close as possible to the task you have at hand -- and fine-tune it. + +## General Transformer architecture[[general-transformer-architecture]] + +In this section, we'll go over the general architecture of the Transformer model. Don't worry if you don't understand some of the concepts; there are detailed sections later covering each of the components. + + + +The model is primarily composed of two blocks: + +* **Encoder (left)**: The encoder receives an input and builds a representation of it (its features). This means that the model is optimized to acquire understanding from the input. +* **Decoder (right)**: The decoder uses the encoder's representation (features) along with other inputs to generate a target sequence. This means that the model is optimized for generating outputs. + +
+Architecture of a Transformers models + +
+ +Each of these parts can be used independently, depending on the task: + +* **Encoder-only models**: Good for tasks that require understanding of the input, such as sentence classification and named entity recognition. +* **Decoder-only models**: Good for generative tasks such as text generation. +* **Encoder-decoder models** or **sequence-to-sequence models**: Good for generative tasks that require an input, such as translation or summarization. + +We will dive into those architectures independently in later sections. + +## Attention layers[[attention-layers]] + +A key feature of Transformer models is that they are built with special layers called *attention layers*. In fact, the title of the paper introducing the Transformer architecture was ["Attention Is All You Need"](https://arxiv.org/abs/1706.03762)! We will explore the details of attention layers later in the course; for now, all you need to know is that this layer will tell the model to pay specific attention to certain words in the sentence you passed it (and more or less ignore the others) when dealing with the representation of each word. + +To put this into context, consider the task of translating text from English to French. Given the input "You like this course", a translation model will need to also attend to the adjacent word "You" to get the proper translation for the word "like", because in French the verb "like" is conjugated differently depending on the subject. The rest of the sentence, however, is not useful for the translation of that word. In the same vein, when translating "this" the model will also need to pay attention to the word "course", because "this" translates differently depending on whether the associated noun is masculine or feminine. Again, the other words in the sentence will not matter for the translation of "course". With more complex sentences (and more complex grammar rules), the model would need to pay special attention to words that might appear farther away in the sentence to properly translate each word. + +The same concept applies to any task associated with natural language: a word by itself has a meaning, but that meaning is deeply affected by the context, which can be any other word (or words) before or after the word being studied. + +Now that you have an idea of what attention layers are all about, let's take a closer look at the Transformer architecture. + +## The original architecture[[the-original-architecture]] + +The Transformer architecture was originally designed for translation. During training, the encoder receives inputs (sentences) in a certain language, while the decoder receives the same sentences in the desired target language. In the encoder, the attention layers can use all the words in a sentence (since, as we just saw, the translation of a given word can be dependent on what is after as well as before it in the sentence). The decoder, however, works sequentially and can only pay attention to the words in the sentence that it has already translated (so, only the words before the word currently being generated). For example, when we have predicted the first three words of the translated target, we give them to the decoder which then uses all the inputs of the encoder to try to predict the fourth word. + +To speed things up during training (when the model has access to target sentences), the decoder is fed the whole target, but it is not allowed to use future words (if it had access to the word at position 2 when trying to predict the word at position 2, the problem would not be very hard!). For instance, when trying to predict the fourth word, the attention layer will only have access to the words in positions 1 to 3. + +The original Transformer architecture looked like this, with the encoder on the left and the decoder on the right: + +
+Architecture of a Transformers models + +
+ +Note that the first attention layer in a decoder block pays attention to all (past) inputs to the decoder, but the second attention layer uses the output of the encoder. It can thus access the whole input sentence to best predict the current word. This is very useful as different languages can have grammatical rules that put the words in different orders, or some context provided later in the sentence may be helpful to determine the best translation of a given word. + +The *attention mask* can also be used in the encoder/decoder to prevent the model from paying attention to some special words -- for instance, the special padding word used to make all the inputs the same length when batching together sentences. + +## Architectures vs. checkpoints[[architecture-vs-checkpoints]] + +As we dive into Transformer models in this course, you'll see mentions of *architectures* and *checkpoints* as well as *models*. These terms all have slightly different meanings: + +* **Architecture**: This is the skeleton of the model -- the definition of each layer and each operation that happens within the model. +* **Checkpoints**: These are the weights that will be loaded in a given architecture. +* **Model**: This is an umbrella term that isn't as precise as "architecture" or "checkpoint": it can mean both. This course will specify *architecture* or *checkpoint* when it matters to reduce ambiguity. + +For example, BERT is an architecture while `bert-base-cased`, a set of weights trained by the Google team for the first release of BERT, is a checkpoint. However, one can say "the BERT model" and "the `bert-base-cased` model." diff --git a/chapters/te/chapter1/5.mdx b/chapters/te/chapter1/5.mdx new file mode 100644 index 000000000..339fe62a4 --- /dev/null +++ b/chapters/te/chapter1/5.mdx @@ -0,0 +1,263 @@ +# How 🤗 Transformers solve tasks + + + +In [Transformers, what can they do?](/course/chapter1/3), you learned about natural language processing (NLP), speech and audio, computer vision tasks, and some important applications of them. This page will look closely at how models solve these tasks and explain what's happening under the hood. There are many ways to solve a given task, some models may implement certain techniques or even approach the task from a new angle, but for Transformer models, the general idea is the same. Owing to its flexible architecture, most models are a variant of an encoder, a decoder, or an encoder-decoder structure. + + + +Before diving into specific architectural variants, it's helpful to understand that most tasks follow a similar pattern: input data is processed through a model, and the output is interpreted for a specific task. The differences lie in how the data is prepared, what model architecture variant is used, and how the output is processed. + + + +To explain how tasks are solved, we'll walk through what goes on inside the model to output useful predictions. We'll cover the following models and their corresponding tasks: + +- [Wav2Vec2](https://huggingface.co/docs/transformers/model_doc/wav2vec2) for audio classification and automatic speech recognition (ASR) +- [Vision Transformer (ViT)](https://huggingface.co/docs/transformers/model_doc/vit) and [ConvNeXT](https://huggingface.co/docs/transformers/model_doc/convnext) for image classification +- [DETR](https://huggingface.co/docs/transformers/model_doc/detr) for object detection +- [Mask2Former](https://huggingface.co/docs/transformers/model_doc/mask2former) for image segmentation +- [GLPN](https://huggingface.co/docs/transformers/model_doc/glpn) for depth estimation +- [BERT](https://huggingface.co/docs/transformers/model_doc/bert) for NLP tasks like text classification, token classification and question answering that use an encoder +- [GPT2](https://huggingface.co/docs/transformers/model_doc/gpt2) for NLP tasks like text generation that use a decoder +- [BART](https://huggingface.co/docs/transformers/model_doc/bart) for NLP tasks like summarization and translation that use an encoder-decoder + + + +Before you go further, it is good to have some basic knowledge of the original Transformer architecture. Knowing how encoders, decoders, and attention work will aid you in understanding how different Transformer models work. Be sure to check out our [the previous section](https://huggingface.co/course/chapter1/4?fw=pt) for more information! + + + +## Transformer models for language + +Language models are at the heart of modern NLP. They're designed to understand and generate human language by learning the statistical patterns and relationships between words or tokens in text. + +The Transformer was initially designed for machine translation, and since then, it has become the default architecture for solving all AI tasks. Some tasks lend themselves to the Transformer's encoder structure, while others are better suited for the decoder. Still, other tasks make use of both the Transformer's encoder-decoder structure. + +### How language models work + +Language models work by being trained to predict the probability of a word given the context of surrounding words. This gives them a foundational understanding of language that can generalize to other tasks. + +There are two main approaches for training a transformer model: + +1. **Masked language modeling (MLM)**: Used by encoder models like BERT, this approach randomly masks some tokens in the input and trains the model to predict the original tokens based on the surrounding context. This allows the model to learn bidirectional context (looking at words both before and after the masked word). + +2. **Causal language modeling (CLM)**: Used by decoder models like GPT, this approach predicts the next token based on all previous tokens in the sequence. The model can only use context from the left (previous tokens) to predict the next token. + +### Types of language models + +In the Transformers library, language models generally fall into three architectural categories: + +1. **Encoder-only models** (like BERT): These models use a bidirectional approach to understand context from both directions. They're best suited for tasks that require deep understanding of text, such as classification, named entity recognition, and question answering. + +2. **Decoder-only models** (like GPT, Llama): These models process text from left to right and are particularly good at text generation tasks. They can complete sentences, write essays, or even generate code based on a prompt. + +3. **Encoder-decoder models** (like T5, BART): These models combine both approaches, using an encoder to understand the input and a decoder to generate output. They excel at sequence-to-sequence tasks like translation, summarization, and question answering. + +![transformer-models-for-language](https://huggingface.co/datasets/huggingface-course/documentation-images/resolve/main/en/chapter1/transformers_architecture.png) + +As we covered in the previous section, language models are typically pretrained on large amounts of text data in a self-supervised manner (without human annotations), then fine-tuned on specific tasks. This approach, known as transfer learning, allows these models to adapt to many different NLP tasks with relatively small amounts of task-specific data. + +In the following sections, we'll explore specific model architectures and how they're applied to various tasks across speech, vision, and text domains. + + + +Understanding which part of the Transformer architecture (encoder, decoder, or both) is best suited for a particular NLP task is key to choosing the right model. Generally, tasks requiring bidirectional context use encoders, tasks generating text use decoders, and tasks converting one sequence to another use encoder-decoders. + + + +### Text generation + +Text generation involves creating coherent and contextually relevant text based on a prompt or input. + +[GPT-2](https://huggingface.co/docs/transformers/model_doc/gpt2) is a decoder-only model pretrained on a large amount of text. It can generate convincing (though not always true!) text given a prompt and complete other NLP tasks like question answering despite not being explicitly trained to. + +
+ +
+ +1. GPT-2 uses [byte pair encoding (BPE)](https://huggingface.co/docs/transformers/tokenizer_summary#bytepair-encoding-bpe) to tokenize words and generate a token embedding. Positional encodings are added to the token embeddings to indicate the position of each token in the sequence. The input embeddings are passed through multiple decoder blocks to output some final hidden state. Within each decoder block, GPT-2 uses a *masked self-attention* layer which means GPT-2 can't attend to future tokens. It is only allowed to attend to tokens on the left. This is different from BERT's [`mask`] token because, in masked self-attention, an attention mask is used to set the score to `0` for future tokens. + +2. The output from the decoder is passed to a language modeling head, which performs a linear transformation to convert the hidden states into logits. The label is the next token in the sequence, which are created by shifting the logits to the right by one. The cross-entropy loss is calculated between the shifted logits and the labels to output the next most likely token. + +GPT-2's pretraining objective is based entirely on [causal language modeling](https://huggingface.co/docs/transformers/glossary#causal-language-modeling), predicting the next word in a sequence. This makes GPT-2 especially good at tasks that involve generating text. + +Ready to try your hand at text generation? Check out our complete [causal language modeling guide](https://huggingface.co/docs/transformers/tasks/language_modeling#causal-language-modeling) to learn how to finetune DistilGPT-2 and use it for inference! + + +For more information about text generation, check out the [text generation strategies](generation_strategies) guide! + + +### Text classification + +Text classification involves assigning predefined categories to text documents, such as sentiment analysis, topic classification, or spam detection. + +[BERT](https://huggingface.co/docs/transformers/model_doc/bert) is an encoder-only model and is the first model to effectively implement deep bidirectionality to learn richer representations of the text by attending to words on both sides. + +1. BERT uses [WordPiece](https://huggingface.co/docs/transformers/tokenizer_summary#wordpiece) tokenization to generate a token embedding of the text. To tell the difference between a single sentence and a pair of sentences, a special `[SEP]` token is added to differentiate them. A special `[CLS]` token is added to the beginning of every sequence of text. The final output with the `[CLS]` token is used as the input to the classification head for classification tasks. BERT also adds a segment embedding to denote whether a token belongs to the first or second sentence in a pair of sentences. + +2. BERT is pretrained with two objectives: masked language modeling and next-sentence prediction. In masked language modeling, some percentage of the input tokens are randomly masked, and the model needs to predict these. This solves the issue of bidirectionality, where the model could cheat and see all the words and "predict" the next word. The final hidden states of the predicted mask tokens are passed to a feedforward network with a softmax over the vocabulary to predict the masked word. + + The second pretraining object is next-sentence prediction. The model must predict whether sentence B follows sentence A. Half of the time sentence B is the next sentence, and the other half of the time, sentence B is a random sentence. The prediction, whether it is the next sentence or not, is passed to a feedforward network with a softmax over the two classes (`IsNext` and `NotNext`). + +3. The input embeddings are passed through multiple encoder layers to output some final hidden states. + +To use the pretrained model for text classification, add a sequence classification head on top of the base BERT model. The sequence classification head is a linear layer that accepts the final hidden states and performs a linear transformation to convert them into logits. The cross-entropy loss is calculated between the logits and target to find the most likely label. + +Ready to try your hand at text classification? Check out our complete [text classification guide](https://huggingface.co/docs/transformers/tasks/sequence_classification) to learn how to finetune DistilBERT and use it for inference! + +### Token classification + +Token classification involves assigning a label to each token in a sequence, such as in named entity recognition or part-of-speech tagging. + +To use BERT for token classification tasks like named entity recognition (NER), add a token classification head on top of the base BERT model. The token classification head is a linear layer that accepts the final hidden states and performs a linear transformation to convert them into logits. The cross-entropy loss is calculated between the logits and each token to find the most likely label. + +Ready to try your hand at token classification? Check out our complete [token classification guide](https://huggingface.co/docs/transformers/tasks/token_classification) to learn how to finetune DistilBERT and use it for inference! + +### Question answering + +Question answering involves finding the answer to a question within a given context or passage. + +To use BERT for question answering, add a span classification head on top of the base BERT model. This linear layer accepts the final hidden states and performs a linear transformation to compute the `span` start and end logits corresponding to the answer. The cross-entropy loss is calculated between the logits and the label position to find the most likely span of text corresponding to the answer. + +Ready to try your hand at question answering? Check out our complete [question answering guide](https://huggingface.co/docs/transformers/tasks/question_answering) to learn how to finetune DistilBERT and use it for inference! + + + +💡 Notice how easy it is to use BERT for different tasks once it's been pretrained. You only need to add a specific head to the pretrained model to manipulate the hidden states into your desired output! + + + +### Summarization + +Summarization involves condensing a longer text into a shorter version while preserving its key information and meaning. + +Encoder-decoder models like [BART](https://huggingface.co/docs/transformers/model_doc/bart) and [T5](model_doc/t5) are designed for the sequence-to-sequence pattern of a summarization task. We'll explain how BART works in this section, and then you can try finetuning T5 at the end. + +
+ +
+ +1. BART's encoder architecture is very similar to BERT and accepts a token and positional embedding of the text. BART is pretrained by corrupting the input and then reconstructing it with the decoder. Unlike other encoders with specific corruption strategies, BART can apply any type of corruption. The *text infilling* corruption strategy works the best though. In text infilling, a number of text spans are replaced with a **single** [`mask`] token. This is important because the model has to predict the masked tokens, and it teaches the model to predict the number of missing tokens. The input embeddings and masked spans are passed through the encoder to output some final hidden states, but unlike BERT, BART doesn't add a final feedforward network at the end to predict a word. + +2. The encoder's output is passed to the decoder, which must predict the masked tokens and any uncorrupted tokens from the encoder's output. This gives additional context to help the decoder restore the original text. The output from the decoder is passed to a language modeling head, which performs a linear transformation to convert the hidden states into logits. The cross-entropy loss is calculated between the logits and the label, which is just the token shifted to the right. + +Ready to try your hand at summarization? Check out our complete [summarization guide](https://huggingface.co/docs/transformers/tasks/summarization) to learn how to finetune T5 and use it for inference! + + + +For more information about text generation, check out the [text generation strategies](https://huggingface.co/docs/transformers/generation_strategies) guide! + + + +### Translation + +Translation involves converting text from one language to another while preserving its meaning. Translation is another example of a sequence-to-sequence task, which means you can use an encoder-decoder model like [BART](https://huggingface.co/docs/transformers/model_doc/bart) or [T5](model_doc/t5) to do it. We'll explain how BART works in this section, and then you can try finetuning T5 at the end. + +BART adapts to translation by adding a separate randomly initialized encoder to map a source language to an input that can be decoded into the target language. This new encoder's embeddings are passed to the pretrained encoder instead of the original word embeddings. The source encoder is trained by updating the source encoder, positional embeddings, and input embeddings with the cross-entropy loss from the model output. The model parameters are frozen in this first step, and all the model parameters are trained together in the second step. +BART has since been followed up by a multilingual version, mBART, intended for translation and pretrained on many different languages. + +Ready to try your hand at translation? Check out our complete [translation guide](https://huggingface.co/docs/transformers/tasks/translation) to learn how to finetune T5 and use it for inference! + + + +As you've seen throughout this guide, many models follow similar patterns despite addressing different tasks. Understanding these common patterns can help you quickly grasp how new models work and how to adapt existing models to your specific needs. + + + +## Modalities beyond text + +Transformers are not limited to text. They can also be applied to other modalities like speech and audio, images, and video. Of course, on this course we will focus on text, but we can briefly introduce the other modalities. + +### Speech and audio + +Let's start by exploring how Transformer models handle speech and audio data, which presents unique challenges compared to text or images. + +[Whisper](https://huggingface.co/docs/transformers/main/en/model_doc/whisper) is a encoder-decoder (sequence-to-sequence) transformer pretrained on 680,000 hours of labeled audio data. This amount of pretraining data enables zero-shot performance on audio tasks in English and many other languages. The decoder allows Whisper to map the encoders learned speech representations to useful outputs, such as text, without additional fine-tuning. Whisper just works out of the box. + +
+ +
+ +Diagram is from [Whisper paper](https://huggingface.co/papers/2212.04356). + +This model has two main components: + +1. An **encoder** processes the input audio. The raw audio is first converted into a log-Mel spectrogram. This spectrogram is then passed through a Transformer encoder network. + +2. A **decoder** takes the encoded audio representation and autoregressively predicts the corresponding text tokens. It's a standard Transformer decoder trained to predict the next text token given the previous tokens and the encoder output. Special tokens are used at the beginning of the decoder input to steer the model towards specific tasks like transcription, translation, or language identification. + +Whisper was pretrained on a massive and diverse dataset of 680,000 hours of labeled audio data collected from the web. This large-scale, weakly supervised pretraining is the key to its strong zero-shot performance across many languages and tasks. + +Now that Whisper is pretrained, you can use it directly for zero-shot inference or finetune it on your data for improved performance on specific tasks like automatic speech recognition or speech translation! + + + +The key innovation in Whisper is its training on an unprecedented scale of diverse, weakly supervised audio data from the internet. This allows it to generalize remarkably well to different languages, accents, and tasks without task-specific finetuning. + + + +### Automatic speech recognition + +To use the pretrained model for automatic speech recognition, you leverage its full encoder-decoder structure. The encoder processes the audio input, and the decoder autoregressively generates the transcript token by token. When fine-tuning, the model is typically trained using a standard sequence-to-sequence loss (like cross-entropy) to predict the correct text tokens based on the audio input. + +The easiest way to use a fine-tuned model for inference is within a `pipeline`. + +```python +from transformers import pipeline + +transcriber = pipeline( + task="automatic-speech-recognition", model="openai/whisper-base.en" +) +transcriber("https://huggingface.co/datasets/Narsil/asr_dummy/resolve/main/mlk.flac") +# Output: {'text': ' I have a dream that one day this nation will rise up and live out the true meaning of its creed.'} +``` + +Ready to try your hand at automatic speech recognition? Check out our complete [automatic speech recognition guide](https://huggingface.co/docs/transformers/tasks/asr) to learn how to finetune Whisper and use it for inference! + +### Computer vision + +Now let's move on to computer vision tasks, which deal with understanding and interpreting visual information from images or videos. + +There are two ways to approach computer vision tasks: + +1. Split an image into a sequence of patches and process them in parallel with a Transformer. +2. Use a modern CNN, like [ConvNeXT](https://huggingface.co/docs/transformers/model_doc/convnext), which relies on convolutional layers but adopts modern network designs. + + + +A third approach mixes Transformers with convolutions (for example, [Convolutional Vision Transformer](https://huggingface.co/docs/transformers/model_doc/cvt) or [LeViT](https://huggingface.co/docs/transformers/model_doc/levit)). We won't discuss those because they just combine the two approaches we examine here. + + + +ViT and ConvNeXT are commonly used for image classification, but for other vision tasks like object detection, segmentation, and depth estimation, we'll look at DETR, Mask2Former and GLPN, respectively; these models are better suited for those tasks. + +### Image classification + +Image classification is one of the fundamental computer vision tasks. Let's see how different model architectures approach this problem. + +ViT and ConvNeXT can both be used for image classification; the main difference is that ViT uses an attention mechanism while ConvNeXT uses convolutions. + +[ViT](https://huggingface.co/docs/transformers/model_doc/vit) replaces convolutions entirely with a pure Transformer architecture. If you're familiar with the original Transformer, then you're already most of the way toward understanding ViT. + +
+ +
+ +The main change ViT introduced was in how images are fed to a Transformer: + +1. An image is split into square non-overlapping patches, each of which gets turned into a vector or *patch embedding*. The patch embeddings are generated from a convolutional 2D layer which creates the proper input dimensions (which for a base Transformer is 768 values for each patch embedding). If you had a 224x224 pixel image, you could split it into 196 16x16 image patches. Just like how text is tokenized into words, an image is "tokenized" into a sequence of patches. + +2. A *learnable embedding* - a special `[CLS]` token - is added to the beginning of the patch embeddings just like BERT. The final hidden state of the `[CLS]` token is used as the input to the attached classification head; other outputs are ignored. This token helps the model learn how to encode a representation of the image. + +3. The last thing to add to the patch and learnable embeddings are the *position embeddings* because the model doesn't know how the image patches are ordered. The position embeddings are also learnable and have the same size as the patch embeddings. Finally, all of the embeddings are passed to the Transformer encoder. + +4. The output, specifically only the output with the `[CLS]` token, is passed to a multilayer perceptron head (MLP). ViT's pretraining objective is simply classification. Like other classification heads, the MLP head converts the output into logits over the class labels and calculates the cross-entropy loss to find the most likely class. + +Ready to try your hand at image classification? Check out our complete [image classification guide](https://huggingface.co/docs/transformers/tasks/image_classification) to learn how to fine-tune ViT and use it for inference! + + + + +Notice the parallel between ViT and BERT: both use a special token ([CLS]) to capture the overall representation, both add position information to their embeddings, and both use a Transformer encoder to process the sequence of tokens/patches. + + diff --git a/chapters/te/chapter1/6.mdx b/chapters/te/chapter1/6.mdx new file mode 100644 index 000000000..e540c8624 --- /dev/null +++ b/chapters/te/chapter1/6.mdx @@ -0,0 +1,224 @@ + + +# Transformer Architectures[[transformer-architectures]] + +In the previous sections, we introduced the general Transformer architecture and explored how these models can solve various tasks. Now, let's take a closer look at the three main architectural variants of Transformer models and understand when to use each one. Then, we looked at how those architectures are applied to different language tasks. + +In this section, we're going to dive deeper into the three main architectural variants of Transformer models and understand when to use each one. + + + + +Remember that most Transformer models use one of three architectures: encoder-only, decoder-only, or encoder-decoder (sequence-to-sequence). Understanding these differences will help you choose the right model for your specific task. + + + +## Encoder models[[encoder-models]] + + + +Encoder models use only the encoder of a Transformer model. At each stage, the attention layers can access all the words in the initial sentence. These models are often characterized as having "bi-directional" attention, and are often called *auto-encoding models*. + +The pretraining of these models usually revolves around somehow corrupting a given sentence (for instance, by masking random words in it) and tasking the model with finding or reconstructing the initial sentence. + +Encoder models are best suited for tasks requiring an understanding of the full sentence, such as sentence classification, named entity recognition (and more generally word classification), and extractive question answering. + + + +As we saw in [How 🤗 Transformers solve tasks](/chapter1/5), encoder models like BERT excel at understanding text because they can look at the entire context in both directions. This makes them perfect for tasks where comprehension of the whole input is important. + + + +Representatives of this family of models include: + +- [BERT](https://huggingface.co/docs/transformers/model_doc/bert) +- [DistilBERT](https://huggingface.co/docs/transformers/model_doc/distilbert) +- [ModernBERT](https://huggingface.co/docs/transformers/en/model_doc/modernbert) + +## Decoder models[[decoder-models]] + + + +Decoder models use only the decoder of a Transformer model. At each stage, for a given word the attention layers can only access the words positioned before it in the sentence. These models are often called *auto-regressive models*. + +The pretraining of decoder models usually revolves around predicting the next word in the sentence. + +These models are best suited for tasks involving text generation. + + + +Decoder models like GPT are designed to generate text by predicting one token at a time. As we explored in [How 🤗 Transformers solve tasks](/chapter1/5), they can only see previous tokens, which makes them excellent for creative text generation but less ideal for tasks requiring bidirectional understanding. + + + +Representatives of this family of models include: + +- [Hugging Face SmolLM Series](https://huggingface.co/HuggingFaceTB/SmolLM2-1.7B-Instruct) +- [Meta's Llama Series](https://huggingface.co/docs/transformers/en/model_doc/llama4) +- [Google's Gemma Series](https://huggingface.co/docs/transformers/main/en/model_doc/gemma3) +- [DeepSeek's V3](https://huggingface.co/deepseek-ai/DeepSeek-V3) + +### Modern Large Language Models (LLMs) + +Most modern Large Language Models (LLMs) use the decoder-only architecture. These models have grown dramatically in size and capabilities over the past few years, with some of the largest models containing hundreds of billions of parameters. + +Modern LLMs are typically trained in two phases: +1. **Pretraining**: The model learns to predict the next token on vast amounts of text data +2. **Instruction tuning**: The model is fine-tuned to follow instructions and generate helpful responses + +This approach has led to models that can understand and generate human-like text across a wide range of topics and tasks. + +#### Key capabilities of modern LLMs + +Modern decoder-based LLMs have demonstrated impressive capabilities: + +| Capability | Description | Example | +|------------|-------------|---------| +| Text generation | Creating coherent and contextually relevant text | Writing essays, stories, or emails | +| Summarization | Condensing long documents into shorter versions | Creating executive summaries of reports | +| Translation | Converting text between languages | Translating English to Spanish | +| Question answering | Providing answers to factual questions | "What is the capital of France?" | +| Code generation | Writing or completing code snippets | Creating a function based on a description | +| Reasoning | Working through problems step by step | Solving math problems or logical puzzles | +| Few-shot learning | Learning from a few examples in the prompt | Classifying text after seeing just 2-3 examples | + +You can experiment with decoder-based LLMs directly in your browser via model repo pages on the Hub. Here's an an example with the classic [GPT-2](https://huggingface.co/openai-community/gpt2) (OpenAI's finest open source model!): + + + +## Sequence-to-sequence models[[sequence-to-sequence-models]] + + + +Encoder-decoder models (also called *sequence-to-sequence models*) use both parts of the Transformer architecture. At each stage, the attention layers of the encoder can access all the words in the initial sentence, whereas the attention layers of the decoder can only access the words positioned before a given word in the input. + +The pretraining of these models can take different forms, but it often involves reconstructing a sentence for which the input has been somehow corrupted (for instance by masking random words). The pretraining of the T5 model consists of replacing random spans of text (that can contain several words) with a single mask special token, and the task is then to predict the text that this mask token replaces. + +Sequence-to-sequence models are best suited for tasks revolving around generating new sentences depending on a given input, such as summarization, translation, or generative question answering. + + + +As we saw in [How 🤗 Transformers solve tasks](/chapter1/5), encoder-decoder models like BART and T5 combine the strengths of both architectures. The encoder provides deep bidirectional understanding of the input, while the decoder generates appropriate output text. This makes them perfect for tasks that transform one sequence into another, like translation or summarization. + + + +### Practical applications + +Sequence-to-sequence models excel at tasks that require transforming one form of text into another while preserving meaning. Some practical applications include: + +| Application | Description | Example Model | +|-------------|-------------|---------------| +| Machine translation | Converting text between languages | Marian, T5 | +| Text summarization | Creating concise summaries of longer texts | BART, T5 | +| Data-to-text generation | Converting structured data into natural language | T5 | +| Grammar correction | Fixing grammatical errors in text | T5 | +| Question answering | Generating answers based on context | BART, T5 | + +Here's an interactive demo of a sequence-to-sequence model for translation: + + + +Representatives of this family of models include: + +- [BART](https://huggingface.co/docs/transformers/model_doc/bart) +- [mBART](https://huggingface.co/docs/transformers/model_doc/mbart) +- [Marian](https://huggingface.co/docs/transformers/model_doc/marian) +- [T5](https://huggingface.co/docs/transformers/model_doc/t5) + +## Choosing the right architecture[[choosing-the-right-architecture]] + +When working on a specific NLP task, how do you decide which architecture to use? Here's a quick guide: + +| Task | Suggested Architecture | Examples | +|------|------------------------|----------| +| Text classification (sentiment, topic) | Encoder | BERT, RoBERTa | +| Text generation (creative writing) | Decoder | GPT, LLaMA | +| Translation | Encoder-Decoder | T5, BART | +| Summarization | Encoder-Decoder | BART, T5 | +| Named entity recognition | Encoder | BERT, RoBERTa | +| Question answering (extractive) | Encoder | BERT, RoBERTa | +| Question answering (generative) | Encoder-Decoder or Decoder | T5, GPT | +| Conversational AI | Decoder | GPT, LLaMA | + + + +When in doubt about which model to use, consider: + +1. What kind of understanding does your task need? (Bidirectional or unidirectional) +2. Are you generating new text or analyzing existing text? +3. Do you need to transform one sequence into another? + +The answers to these questions will guide you toward the right architecture. + + + +## The evolution of LLMs + +Large Language Models have evolved rapidly in recent years, with each generation bringing significant improvements in capabilities. + +## Attention mechanisms[[attention-mechanisms]] + +Most transformer models use full attention in the sense that the attention matrix is square. It can be a big +computational bottleneck when you have long texts. Longformer and reformer are models that try to be more efficient and +use a sparse version of the attention matrix to speed up training. + + + +Standard attention mechanisms have a computational complexity of O(n²), where n is the sequence length. This becomes problematic for very long sequences. The specialized attention mechanisms below help address this limitation. + + + +### LSH attention + +[Reformer](https://huggingface.co/docs/transformers/model_doc/reformer) uses LSH attention. In the softmax(QK^t), only the biggest elements (in the softmax dimension) of the matrix QK^t are going to give useful contributions. So for each query q in Q, we can consider only +the keys k in K that are close to q. A hash function is used to determine if q and k are close. The attention mask is +modified to mask the current token (except at the first position), because it will give a query and a key equal (so +very similar to each other). Since the hash can be a bit random, several hash functions are used in practice +(determined by a n_rounds parameter) and then are averaged together. + +### Local attention + +[Longformer](https://huggingface.co/docs/transformers/model_doc/longformer) uses local attention: often, the local context (e.g., what are the two tokens to the left and right?) is enough to take action for a given token. Also, by stacking attention layers that have a small +window, the last layer will have a receptive field of more than just the tokens in the window, allowing them to build a +representation of the whole sentence. + +Some preselected input tokens are also given global attention: for those few tokens, the attention matrix can access +all tokens and this process is symmetric: all other tokens have access to those specific tokens (on top of the ones in +their local window). This is shown in Figure 2d of the paper, see below for a sample attention mask: + +
+ +
+ +Using those attention matrices with less parameters then allows the model to have inputs having a bigger sequence +length. + +### Axial positional encodings + +[Reformer](https://huggingface.co/docs/transformers/model_doc/reformer) uses axial positional encodings: in traditional transformer models, the positional encoding +E is a matrix of size \\(l\\) by \\(d\\), \\(l\\) being the sequence length and \\(d\\) the dimension of the +hidden state. If you have very long texts, this matrix can be huge and take way too much space on the GPU. To alleviate +that, axial positional encodings consist of factorizing that big matrix E in two smaller matrices E1 and E2, with +dimensions \\(l_{1} \times d_{1}\\) and \\(l_{2} \times d_{2}\\), such that \\(l_{1} \times l_{2} = l\\) and +\\(d_{1} + d_{2} = d\\) (with the product for the lengths, this ends up being way smaller). The embedding for time +step \\(j\\) in E is obtained by concatenating the embeddings for timestep \\(j \% l1\\) in E1 and \\(j // l1\\) +in E2. + +## Conclusion[[conclusion]] + +In this section, we've explored the three main Transformer architectures and some specialized attention mechanisms. Understanding these architectural differences is crucial for selecting the right model for your specific NLP task. + +As we move forward in the course, you'll get hands-on experience with these different architectures and learn how to fine-tune them for your specific needs. In the next section, we'll look at some of the limitations and biases present in these models that you should be aware of when deploying them. \ No newline at end of file diff --git a/chapters/te/chapter1/7.mdx b/chapters/te/chapter1/7.mdx new file mode 100644 index 000000000..a01a020fb --- /dev/null +++ b/chapters/te/chapter1/7.mdx @@ -0,0 +1,257 @@ + + +# Ungraded quiz[[ungraded-quiz]] + + + +So far, this chapter has covered a lot of ground! Don't worry if you didn't grasp all the details, but it's to reflect on what you've learned so far with a quiz. + +This quiz is ungraded, so you can try it as many times as you want. If you struggle with some questions, follow the tips and revisit the material. You'll be quizzed on this material again in the certification exam. + +### 1. Explore the Hub and look for the `roberta-large-mnli` checkpoint. What task does it perform? + + +roberta-large-mnli page." + }, + { + text: "Text classification", + explain: "More precisely, it classifies if two sentences are logically linked across three labels (contradiction, neutral, entailment) — a task also called natural language inference.", + correct: true + }, + { + text: "Text generation", + explain: "Look again on the roberta-large-mnli page." + } + ]} +/> + +### 2. What will the following code return? + +```py +from transformers import pipeline + +ner = pipeline("ner", grouped_entities=True) +ner("My name is Sylvain and I work at Hugging Face in Brooklyn.") +``` + +sentiment-analysis pipeline." + }, + { + text: "It will return a generated text completing this sentence.", + explain: "This is incorrect — it would be a text-generation pipeline.", + }, + { + text: "It will return the words representing persons, organizations or locations.", + explain: "Furthermore, with grouped_entities=True, it will group together the words belonging to the same entity, like \"Hugging Face\".", + correct: true + } + ]} +/> + +### 3. What should replace ... in this code sample? + +```py +from transformers import pipeline + +filler = pipeline("fill-mask", model="bert-base-cased") +result = filler("...") +``` + + has been waiting for you.", + explain: "This is incorrect. Check out the bert-base-cased model card and try to spot your mistake." + }, + { + text: "This [MASK] has been waiting for you.", + explain: "This model's mask token is [MASK].", + correct: true + }, + { + text: "This man has been waiting for you.", + explain: "This is incorrect. This pipeline fills in masked words, so it needs a mask token somewhere." + } + ]} +/> + +### 4. Why will this code fail? + +```py +from transformers import pipeline + +classifier = pipeline("zero-shot-classification") +result = classifier("This is a course about the Transformers library") +``` + +candidate_labels=[...].", + correct: true + }, + { + text: "This pipeline requires several sentences, not just one.", + explain: "This is incorrect, though when properly used, this pipeline can take a list of sentences to process (like all other pipelines)." + }, + { + text: "The 🤗 Transformers library is broken, as usual.", + explain: "We won't dignify this answer with a comment!" + }, + { + text: "This pipeline requires longer inputs; this one is too short.", + explain: "This is incorrect. Note that a very long text will be truncated when processed by this pipeline." + } + ]} +/> + +### 5. What does "transfer learning" mean? + + + +### 6. True or false? A language model usually does not need labels for its pretraining. + +self-supervised, which means the labels are created automatically from the inputs (like predicting the next word or filling in some masked words).", + correct: true + }, + { + text: "False", + explain: "This is not the correct answer." + } + ]} +/> + +### 7. Select the sentence that best describes the terms "model", "architecture", and "weights". + + + + +### 8. Which of these types of models would you use for completing prompts with generated text? + + + +### 9. Which of those types of models would you use for summarizing texts? + + + +### 10. Which of these types of models would you use for classifying text inputs according to certain labels? + + + +### 11. What possible source can the bias observed in a model have? + + diff --git a/chapters/te/chapter1/8.mdx b/chapters/te/chapter1/8.mdx new file mode 100644 index 000000000..a84e76f41 --- /dev/null +++ b/chapters/te/chapter1/8.mdx @@ -0,0 +1,272 @@ +# Deep dive into Text Generation Inference with LLMs[[inference-with-llms]] + + + + + +So far, we've explored the transformer architecture in relation to a range of discrete tasks, like text classification or summarization. However, Large Language Models are most used for text generation, and this is what we'll explore in this chapter. + +In this page, we'll explore the core concepts behind LLM inference, providing a comprehensive understanding of how these models generate text and the key components involved in the inference process. + +## Understanding the Basics + +Let's start with the fundamentals. Inference is the process of using a trained LLM to generate human-like text from a given input prompt. Language models use their knowledge from training to formulate responses one word at a time. The model leverages learned probabilities from billions of parameters to predict and generate the next token in a sequence. This sequential generation is what allows LLMs to produce coherent and contextually relevant text. + +## The Role of Attention + +The attention mechanism is what gives LLMs their ability to understand context and generate coherent responses. When predicting the next word, not every word in a sentence carries equal weight - for example, in the sentence *"The capital of France is ..."*, the words "France" and "capital" are crucial for determining that "Paris" should come next. This ability to focus on relevant information is what we call attention. + +Visual Gif of Attention + +This process of identifying the most relevant words to predict the next token has proven to be incredibly effective. Although the basic principle of training LLMs—predicting the next token—has remained generally consistent since BERT and GPT-2, there have been significant advancements in scaling neural networks and making the attention mechanism work for longer and longer sequences, at lower and lower costs. + + + +In short, the attention mechanism is the key to LLMs being able to generate text that is both coherent and context-aware. It sets modern LLMs apart from previous generations of language models. + + + +### Context Length and Attention Span + +Now that we understand attention, let's explore how much context an LLM can actually handle. This brings us to context length, or the model's 'attention span'. + +The context length refers to the maximum number of tokens (words or parts of words) that the LLM can process at once. Think of it as the size of the model's working memory. + +These capabilities are limited by several practical factors: +- The model's architecture and size +- Available computational resources +- The complexity of the input and desired output + +In an ideal world, we could feed unlimited context to the model, but hardware constraints and computational costs make this impractical. This is why different models are designed with different context lengths to balance capability with efficiency. + + + +The context length is the maximum number of tokens the model can consider at once when generating a response. + + + +### The Art of Prompting + +When we pass information to LLMs, we structure our input in a way that guides the generation of the LLM toward the desired output. This is called _prompting_. + +Understanding how LLMs process information helps us craft better prompts. Since the model's primary task is to predict the next token by analyzing the importance of each input token, the wording of your input sequence becomes crucial. + + + +Careful design of the prompt makes it easier **to guide the generation of the LLM toward the desired output**. + + + +## The Two-Phase Inference Process + +Now that we understand the basic components, let's dive into how LLMs actually generate text. The process can be broken down into two main phases: prefill and decode. These phases work together like an assembly line, each playing a crucial role in producing coherent text. + +### The Prefill Phase + +The prefill phase is like the preparation stage in cooking - it's where all the initial ingredients are processed and made ready. This phase involves three key steps: + +1. **Tokenization**: Converting the input text into tokens (think of these as the basic building blocks the model understands) +2. **Embedding Conversion**: Transforming these tokens into numerical representations that capture their meaning +3. **Initial Processing**: Running these embeddings through the model's neural networks to create a rich understanding of the context + +This phase is computationally intensive because it needs to process all input tokens at once. Think of it as reading and understanding an entire paragraph before starting to write a response. + +You can experiment with different tokenizers in the interactive playground below: + + + +### The Decode Phase + +After the prefill phase has processed the input, we move to the decode phase - this is where the actual text generation happens. The model generates one token at a time in what we call an autoregressive process (where each new token depends on all previous tokens). + +The decode phase involves several key steps that happen for each new token: +1. **Attention Computation**: Looking back at all previous tokens to understand context +2. **Probability Calculation**: Determining the likelihood of each possible next token +3. **Token Selection**: Choosing the next token based on these probabilities +4. **Continuation Check**: Deciding whether to continue or stop generation + +This phase is memory-intensive because the model needs to keep track of all previously generated tokens and their relationships. + +## Sampling Strategies + +Now that we understand how the model generates text, let's explore the various ways we can control this generation process. Just like a writer might choose between being more creative or more precise, we can adjust how the model makes its token selections. + +You can interact with the basic decoding process yourself with SmolLM2 in this Space (remember, it decodes until reaching an **EOS** token which is **<|im_end|>** for this model): + + + +### Understanding Token Selection: From Probabilities to Token Choices + +When the model needs to choose the next token, it starts with raw probabilities (called logits) for every word in its vocabulary. But how do we turn these probabilities into actual choices? Let's break down the process: + +![image](https://huggingface.co/reasoning-course/images/resolve/main/inference/1.png) + +1. **Raw Logits**: Think of these as the model's initial gut feelings about each possible next word +2. **Temperature Control**: Like a creativity dial - higher settings (>1.0) make choices more random and creative, lower settings (<1.0) make them more focused and deterministic +3. **Top-p (Nucleus) Sampling**: Instead of considering all possible words, we only look at the most likely ones that add up to our chosen probability threshold (e.g., top 90%) +4. **Top-k Filtering**: An alternative approach where we only consider the k most likely next words + +### Managing Repetition: Keeping Output Fresh + +One common challenge with LLMs is their tendency to repeat themselves - much like a speaker who keeps returning to the same points. To address this, we use two types of penalties: + +1. **Presence Penalty**: A fixed penalty applied to any token that has appeared before, regardless of how often. This helps prevent the model from reusing the same words. +2. **Frequency Penalty**: A scaling penalty that increases based on how often a token has been used. The more a word appears, the less likely it is to be chosen again. + +![image](https://huggingface.co/reasoning-course/images/resolve/main/inference/2.png) + +These penalties are applied early in the token selection process, adjusting the raw probabilities before other sampling strategies are applied. Think of them as gentle nudges encouraging the model to explore new vocabulary. + +### Controlling Generation Length: Setting Boundaries + +Just as a good story needs proper pacing and length, we need ways to control how much text our LLM generates. This is crucial for practical applications - whether we're generating a tweet-length response or a full blog post. + +We can control generation length in several ways: +1. **Token Limits**: Setting minimum and maximum token counts +2. **Stop Sequences**: Defining specific patterns that signal the end of generation +3. **End-of-Sequence Detection**: Letting the model naturally conclude its response + +For example, if we want to generate a single paragraph, we might set a maximum of 100 tokens and use "\n\n" as a stop sequence. This ensures our output stays focused and appropriately sized for its purpose. + +![image](https://huggingface.co/reasoning-course/images/resolve/main/inference/3.png) + +### Beam Search: Looking Ahead for Better Coherence + +While the strategies we've discussed so far make decisions one token at a time, beam search takes a more holistic approach. Instead of committing to a single choice at each step, it explores multiple possible paths simultaneously - like a chess player thinking several moves ahead. + +![image](https://huggingface.co/reasoning-course/images/resolve/main/inference/4.png) + +Here's how it works: +1. At each step, maintain multiple candidate sequences (typically 5-10) +2. For each candidate, compute probabilities for the next token +3. Keep only the most promising combinations of sequences and next tokens +4. Continue this process until reaching the desired length or stop condition +5. Select the sequence with the highest overall probability + +You can explore beam search visually here: + + + +This approach often produces more coherent and grammatically correct text, though it requires more computational resources than simpler methods. + +## Practical Challenges and Optimization + +As we wrap up our exploration of LLM inference, let's look at the practical challenges you'll face when deploying these models, and how to measure and optimize their performance. + +### Key Performance Metrics + +When working with LLMs, four critical metrics will shape your implementation decisions: + +1. **Time to First Token (TTFT)**: How quickly can you get the first response? This is crucial for user experience and is primarily affected by the prefill phase. +2. **Time Per Output Token (TPOT)**: How fast can you generate subsequent tokens? This determines the overall generation speed. +3. **Throughput**: How many requests can you handle simultaneously? This affects scaling and cost efficiency. +4. **VRAM Usage**: How much GPU memory do you need? This often becomes the primary constraint in real-world applications. + +### The Context Length Challenge + +One of the most significant challenges in LLM inference is managing context length effectively. Longer contexts provide more information but come with substantial costs: + +- **Memory Usage**: Grows quadratically with context length +- **Processing Speed**: Decreases linearly with longer contexts +- **Resource Allocation**: Requires careful balancing of VRAM usage + +Recent models like [Qwen2.5-1M](https://huggingface.co/Qwen/Qwen2.5-14B-Instruct-1M) offer impressive 1M token context windows, but this comes at the cost of significantly slower inference times. The key is finding the right balance for your specific use case. + + +
+
+
+
+ Input Text (Raw) +
+
+
+ Tokenized Input +
+
+
+
+ Context Window
(e.g., 4K tokens) +
+
+
+
+
+
+
+
+
+
+
+ Memory Usage
∝ Length² +
+
+
+
+ Processing Time
∝ Length +
+
+
+
+
+ +### The KV Cache Optimization + +To address these challenges, one of the most powerful optimizations is KV (Key-Value) caching. This technique significantly improves inference speed by storing and reusing intermediate calculations. This optimization: +- Reduces repeated calculations +- Improves generation speed +- Makes long-context generation practical + +The trade-off is additional memory usage, but the performance benefits usually far outweigh this cost. + +## Conclusion + +Understanding LLM inference is crucial for effectively deploying and optimizing these powerful models. We've covered the key components: + +- The fundamental role of attention and context +- The two-phase inference process +- Various sampling strategies for controlling generation +- Practical challenges and optimizations + +By mastering these concepts, you'll be better equipped to build applications that leverage LLMs effectively and efficiently. + +Remember that the field of LLM inference is rapidly evolving, with new techniques and optimizations emerging regularly. Stay curious and keep experimenting with different approaches to find what works best for your specific use cases. diff --git a/chapters/te/chapter1/9.mdx b/chapters/te/chapter1/9.mdx new file mode 100644 index 000000000..b5082b85e --- /dev/null +++ b/chapters/te/chapter1/9.mdx @@ -0,0 +1,32 @@ +# Bias and limitations[[bias-and-limitations]] + + + +If your intent is to use a pretrained model or a fine-tuned version in production, please be aware that, while these models are powerful tools, they come with limitations. The biggest of these is that, to enable pretraining on large amounts of data, researchers often scrape all the content they can find, taking the best as well as the worst of what is available on the internet. + +To give a quick illustration, let's go back the example of a `fill-mask` pipeline with the BERT model: + +```python +from transformers import pipeline + +unmasker = pipeline("fill-mask", model="bert-base-uncased") +result = unmasker("This man works as a [MASK].") +print([r["token_str"] for r in result]) + +result = unmasker("This woman works as a [MASK].") +print([r["token_str"] for r in result]) +``` + +```python out +['lawyer', 'carpenter', 'doctor', 'waiter', 'mechanic'] +['nurse', 'waitress', 'teacher', 'maid', 'prostitute'] +``` + +When asked to fill in the missing word in these two sentences, the model gives only one gender-free answer (waiter/waitress). The others are work occupations usually associated with one specific gender -- and yes, prostitute ended up in the top 5 possibilities the model associates with "woman" and "work." This happens even though BERT is one of the rare Transformer models not built by scraping data from all over the internet, but rather using apparently neutral data (it's trained on the [English Wikipedia](https://huggingface.co/datasets/wikipedia) and [BookCorpus](https://huggingface.co/datasets/bookcorpus) datasets). + +When you use these tools, you therefore need to keep in the back of your mind that the original model you are using could very easily generate sexist, racist, or homophobic content. Fine-tuning the model on your data won't make this intrinsic bias disappear. From aa3c90a6e30a7493e0cc68d0650ea19c882bee0f Mon Sep 17 00:00:00 2001 From: Rahul Konda Date: Wed, 11 Jun 2025 22:33:08 +0530 Subject: [PATCH 2/2] add/telugu-chapter1-translation --- chapters/te/_toctree.yml | 2 +- chapters/te/chapter1/1.mdx | 185 ++++++++-------- chapters/te/chapter1/10.mdx | 103 ++++----- chapters/te/chapter1/11.mdx | 25 ++- chapters/te/chapter1/2.mdx | 67 +++--- chapters/te/chapter1/3.mdx | 238 +++++++++++---------- chapters/te/chapter1/4.mdx | 151 +++++++------ chapters/te/chapter1/5.mdx | 227 ++++++++++---------- chapters/te/chapter1/6.mdx | 214 +++++++++---------- chapters/te/chapter1/7.mdx | 407 +++++++++++++++++++----------------- chapters/te/chapter1/8.mdx | 379 ++++++++++++++++++--------------- chapters/te/chapter1/9.mdx | 32 ++- 12 files changed, 1053 insertions(+), 977 deletions(-) diff --git a/chapters/te/_toctree.yml b/chapters/te/_toctree.yml index 189953e47..457882aab 100644 --- a/chapters/te/_toctree.yml +++ b/chapters/te/_toctree.yml @@ -26,5 +26,5 @@ - local: chapter1/10 title: సారాంశం - local: chapter1/11 - title: ధృవీకరణ పరీక్ష + title: పరీక్ష quiz: 1 diff --git a/chapters/te/chapter1/1.mdx b/chapters/te/chapter1/1.mdx index ff9f55560..676819db1 100644 --- a/chapters/te/chapter1/1.mdx +++ b/chapters/te/chapter1/1.mdx @@ -1,110 +1,109 @@ -# Introduction[[introduction]] +# పరిచయం[[introduction]] - + -## Welcome to the 🤗 Course![[welcome-to-the-course]] +## 🤗 కోర్స్‌కు స్వాగతం![[welcome-to-the-course]] -This course will teach you about large language models (LLMs) and natural language processing (NLP) using libraries from the [Hugging Face](https://huggingface.co/) ecosystem — [🤗 Transformers](https://github.com/huggingface/transformers), [🤗 Datasets](https://github.com/huggingface/datasets), [🤗 Tokenizers](https://github.com/huggingface/tokenizers), and [🤗 Accelerate](https://github.com/huggingface/accelerate) — as well as the [Hugging Face Hub](https://huggingface.co/models). +ఈ కోర్సు మీకు Large Language Models (LLMs) మరియు Natural Language Processing (NLP) గురించి [Hugging Face](https://huggingface.co/) ఎకోసిస్టమ్‌లోని లైబ్రరీలను — [🤗 Transformers](https://github.com/huggingface/transformers), [🤗 Datasets](https://github.com/huggingface/datasets), [🤗 Tokenizers](https://github.com/huggingface/tokenizers), and [🤗 Accelerate](https://github.com/huggingface/accelerate) — అలాగే [Hugging Face Hub](https://huggingface.co/models) ఉపయోగించి నేర్పుతుంది.. -We'll also cover libraries outside the Hugging Face ecosystem. These are amazing contributions to the AI community and incredibly useful tools. +మేము Hugging Face ఎకోసిస్టమ్ వెలుపల ఉన్న లైబ్రరీలను కూడా కవర్ చేస్తాం. ఇవి AI కమ్యూనిటీకి అద్భుతమైన సహకారాలు మరియు చాలా ఉపయోగకరమైన సాధనాలు. -It's completely free and without ads. +ఇది పూర్తిగా ఉచితం మరియు ప్రకటనలు లేవు. -## Understanding NLP and LLMs[[understanding-nlp-and-llms]] +## NLP మరియు LLMలను అర్థం చేసుకోవడం[[understanding-nlp-and-llms]] -While this course was originally focused on NLP (Natural Language Processing), it has evolved to emphasize Large Language Models (LLMs), which represent the latest advancement in the field. +ఈ కోర్సు మొదట NLP (Natural Language Processing) పై దృష్టి సారించినప్పటికీ, ఇది Large Language Models (LLMs) పై దృష్టి సారించడానికి అభివృద్ధి చెందింది, ఇది ఈ రంగంలో తాజా పురోగతిని సూచిస్తుంది. -**What's the difference?** -- **NLP (Natural Language Processing)** is the broader field focused on enabling computers to understand, interpret, and generate human language. NLP encompasses many techniques and tasks such as sentiment analysis, named entity recognition, and machine translation. -- **LLMs (Large Language Models)** are a powerful subset of NLP models characterized by their massive size, extensive training data, and ability to perform a wide range of language tasks with minimal task-specific training. Models like the Llama, GPT, or Claude series are examples of LLMs that have revolutionized what's possible in NLP. +**తేడా ఏమిటి?** -Throughout this course, you'll learn about both traditional NLP concepts and cutting-edge LLM techniques, as understanding the foundations of NLP is crucial for working effectively with LLMs. +- **NLP (Natural Language Processing)** అనేది కంప్యూటర్‌లు మానవ భాషను అర్థం చేసుకోవడానికి, వివరించడానికి మరియు రూపొందించడానికి వీలు కల్పించడంపై దృష్టి సారించిన విస్తృత రంగం. NLP సెంటిమెంట్ అనాలిసిస్, నేమ్డ్ ఎంటిటీ రికగ్నిషన్ మరియు మెషిన్ ట్రాన్స్‌లేషన్ వంటి అనేక పద్ధతులు మరియు పనులను కలిగి ఉంటుంది. +- **LLMs (Large Language Models)** అనేవి NLP మోడల్‌లలోని ఒక శక్తివంతమైన ఉపసమితి, వాటి భారీ పరిమాణం, విస్తృతమైన శిక్షణ డేటా మరియు కనీస టాస్క్-నిర్దిష్ట శిక్షణతో విస్తృత శ్రేణి భాషా పనులను చేయగల సామర్థ్యం కలిగి ఉంటాయి. Llama, GPT, లేదా Claude సిరీస్ వంటి మోడల్‌లు NLPలో సాధ్యమయ్యే వాటిని విప్లవాత్మకం చేసిన LLMలకు ఉదాహరణలు. -## What to expect?[[what-to-expect]] +ఈ కోర్సు అంతటా, మీరు సాంప్రదాయ NLP భావనలు మరియు అత్యాధునిక LLM పద్ధతులు రెండింటి గురించి నేర్చుకుంటారు, ఎందుకంటే LLMలతో సమర్థవంతంగా పనిచేయడానికి NLP యొక్క పునాదులను అర్థం చేసుకోవడం చాలా ముఖ్యం. -Here is a brief overview of the course: +## ఏమి ఆశించాలి??[[what-to-expect]] + +కోర్సు యొక్క సంక్షిప్త అవలోకనం ఇక్కడ ఉంది:
Brief overview of the chapters of the course. - +
-- Chapters 1 to 4 provide an introduction to the main concepts of the 🤗 Transformers library. By the end of this part of the course, you will be familiar with how Transformer models work and will know how to use a model from the [Hugging Face Hub](https://huggingface.co/models), fine-tune it on a dataset, and share your results on the Hub! -- Chapters 5 to 8 teach the basics of 🤗 Datasets and 🤗 Tokenizers before diving into classic NLP tasks and LLM techniques. By the end of this part, you will be able to tackle the most common language processing challenges by yourself. -- Chapter 9 goes beyond NLP to cover how to build and share demos of your models on the 🤗 Hub. By the end of this part, you will be ready to showcase your 🤗 Transformers application to the world! -- Chapters 10 to 12 dive into advanced LLM topics like fine-tuning, curating high-quality datasets, and building reasoning models. +- అధ్యాయాలు 1 నుండి 4 వరకు 🤗 Transformers లైబ్రరీ యొక్క ప్రధాన భావనలకు పరిచయాన్ని అందిస్తాయి. కోర్సులోని ఈ భాగం ముగిసేనాటికి, మీరు Transformer మోడల్‌లు ఎలా పనిచేస్తాయో పరిచయం చేసుకుంటారు మరియు Hugging Face Hub నుండి మోడల్‌ను ఎలా ఉపయోగించాలి, డేటాసెట్‌పై దాన్ని ఫైన్-ట్యూన్ చేయడం మరియు మీ ఫలితాలను Hubలో పంచుకోవడం ఎలాగో తెలుసుకుంటారు! +- అధ్యాయాలు 5 నుండి 8 వరకు 🤗 Datasets మరియు 🤗 Tokenizers యొక్క ప్రాథమికాంశాలను బోధిస్తాయి, ఆపై క్లాసిక్ NLP పనులు మరియు LLM పద్ధతులలోకి వెళ్తాయి. ఈ భాగం ముగిసేనాటికి, మీరు చాలా సాధారణ భాషా ప్రాసెసింగ్ సవాళ్లను మీరే పరిష్కరించగలరు. +- అధ్యాయం 9 NLPకి మించి మీ మోడల్‌ల డెమోలను 🤗 Hubలో ఎలా నిర్మించాలో మరియు పంచుకోవాలో కవర్ చేస్తుంది. ఈ భాగం ముగిసేనాటికి, మీరు మీ 🤗 Transformers అప్లికేషన్‌ను ప్రపంచానికి ప్రదర్శించడానికి సిద్ధంగా ఉంటారు! +- అధ్యాయాలు 10 నుండి 12 వరకు ఫైన్-ట్యూనింగ్, అధిక-నాణ్యత డేటాసెట్‌లను క్యూరేట్ చేయడం మరియు రీజనింగ్ మోడల్‌లను నిర్మించడం వంటి అధునాతన LLM అంశాలలోకి వెళ్తాయి. -This course: +ఈ కోర్సు: -* Requires a good knowledge of Python -* Is better taken after an introductory deep learning course, such as [fast.ai's](https://www.fast.ai/) [Practical Deep Learning for Coders](https://course.fast.ai/) or one of the programs developed by [DeepLearning.AI](https://www.deeplearning.ai/) -* Does not expect prior [PyTorch](https://pytorch.org/) or [TensorFlow](https://www.tensorflow.org/) knowledge, though some familiarity with either of those will help +- Python పై మంచి జ్ఞానం అవసరం +- fast.ai యొక్క Practical Deep Learning for Coders లేదా DeepLearning.AI అభివృద్ధి చేసిన ప్రోగ్రామ్‌లలో ఒకటైన పరిచయ డీప్ లెర్నింగ్ కోర్సు తర్వాత తీసుకోవడం మంచిది +- ముందస్తు PyTorch లేదా TensorFlow జ్ఞానం అవసరం లేదు, అయితే వాటిలో ఏదో ఒకదానితో కొంత పరిచయం సహాయపడుతుంది. -After you've completed this course, we recommend checking out DeepLearning.AI's [Natural Language Processing Specialization](https://www.coursera.org/specializations/natural-language-processing?utm_source=deeplearning-ai&utm_medium=institutions&utm_campaign=20211011-nlp-2-hugging_face-page-nlp-refresh), which covers a wide range of traditional NLP models like naive Bayes and LSTMs that are well worth knowing about! +మీరు ఈ కోర్సును పూర్తి చేసిన తర్వాత, మీరు DeepLearning.AI యొక్క Natural Language Processing Specializationను పరిశీలించమని సిఫార్సు చేస్తున్నాము, ఇది naive Bayes మరియు LSTMs వంటి విస్తృత శ్రేణి సాంప్రదాయ NLP మోడల్‌లను కవర్ చేస్తుంది, అవి తెలుసుకోవడం చాలా విలువైనవి! -## Who are we?[[who-are-we]] +## మేము ఎవరము?[[who-are-we]] -About the authors: +రచయితల గురించి: -[**Abubakar Abid**](https://huggingface.co/abidlabs) completed his PhD at Stanford in applied machine learning. During his PhD, he founded [Gradio](https://github.com/gradio-app/gradio), an open-source Python library that has been used to build over 600,000 machine learning demos. Gradio was acquired by Hugging Face, which is where Abubakar now serves as a machine learning team lead. +[**Abubakar Abid**](https://huggingface.co/abidlabs) స్టాన్‌ఫోర్డ్‌లో అప్లైడ్ మెషిన్ లెర్నింగ్‌లో పీహెచ్‌డీ పూర్తి చేశారు. తన పీహెచ్‌డీ సమయంలో, అతను Gradio అనే ఓపెన్ సోర్స్ పైథాన్ లైబ్రరీని స్థాపించారు, ఇది 600,000 పైగా మెషిన్ లెర్నింగ్ డెమోలను రూపొందించడానికి ఉపయోగించబడింది. Gradio ను Hugging Face కొనుగోలు చేసింది, అక్కడ ఇప్పుడు Abubakar మెషిన్ లెర్నింగ్ టీమ్ లీడ్‌గా పనిచేస్తున్నారు. -[**Ben Burtenshaw**](https://huggingface.co/burtenshaw) is a Machine Learning Engineer at Hugging Face. He completed his PhD in Natural Language Processing at the University of Antwerp, where he applied Transformer models to generate children stories for the purpose of improving literacy skills. Since then, he has focused on educational materials and tools for the wider community. +[**Ben Burtenshaw**](https://huggingface.co/burtenshaw) Hugging Face లో మెషిన్ లెర్నింగ్ ఇంజనీర్. అతను ఆంట్‌వెర్ప్ విశ్వవిద్యాలయంలో నాచురల్ లాంగ్వేజ్ ప్రాసెసింగ్‌లో పీహెచ్‌డీ పూర్తి చేశారు, అక్కడ అతను అక్షరాస్యత నైపుణ్యాలను మెరుగుపరచడం కోసం పిల్లల కథలను రూపొందించడానికి Transformer మోడల్స్‌ను ఉపయోగించారు. అప్పటి నుండి, అతను విస్తృత సమాజం కోసం విద్యా సామగ్రి మరియు సాధనాలపై దృష్టి పెట్టారు. -[**Matthew Carrigan**](https://huggingface.co/Rocketknight1) is a Machine Learning Engineer at Hugging Face. He lives in Dublin, Ireland and previously worked as an ML engineer at Parse.ly and before that as a post-doctoral researcher at Trinity College Dublin. He does not believe we're going to get to AGI by scaling existing architectures, but has high hopes for robot immortality regardless. +[**Matthew Carrigan**](https://huggingface.co/Rocketknight1) Hugging Face లో మెషిన్ లెర్నింగ్ ఇంజనీర్. అతను ఐర్లాండ్‌లోని డబ్లిన్‌లో నివసిస్తున్నారు మరియు గతంలో Parse.ly లో ML ఇంజనీర్‌గా మరియు అంతకు ముందు ట్రినిటీ కాలేజ్ డబ్లిన్‌లో పోస్ట్-డాక్టోరల్ పరిశోధకుడిగా పనిచేశారు. ప్రస్తుత ఆర్కిటెక్చర్లను స్కేల్ చేయడం ద్వారా మనం AGI ని సాధిస్తామని అతను నమ్మరు, కానీ రోబోట్ అమరత్వంపై ఆయనకు గొప్ప ఆశలు ఉన్నాయి. -[**Lysandre Debut**](https://huggingface.co/lysandre) is a Machine Learning Engineer at Hugging Face and has been working on the 🤗 Transformers library since the very early development stages. His aim is to make NLP accessible for everyone by developing tools with a very simple API. +[**Lysandre Debut**](https://huggingface.co/lysandre) Hugging Face లో మెషిన్ లెర్నింగ్ ఇంజనీర్ మరియు అతను 🤗 Transformers లైబ్రరీ అభివృద్ధి యొక్క ప్రారంభ దశల నుండి పనిచేస్తున్నారు. అతని లక్ష్యం చాలా సులభమైన API తో సాధనాలను అభివృద్ధి చేయడం ద్వారా NLP ని ప్రతిఒక్కరికీ అందుబాటులోకి తీసుకురావడం. -[**Sylvain Gugger**](https://huggingface.co/sgugger) is a Research Engineer at Hugging Face and one of the core maintainers of the 🤗 Transformers library. Previously he was a Research Scientist at fast.ai, and he co-wrote _[Deep Learning for Coders with fastai and PyTorch](https://learning.oreilly.com/library/view/deep-learning-for/9781492045519/)_ with Jeremy Howard. The main focus of his research is on making deep learning more accessible, by designing and improving techniques that allow models to train fast on limited resources. +[**Sylvain Gugger**](https://huggingface.co/sgugger) Hugging Face లో రీసెర్చ్ ఇంజనీర్ మరియు 🤗 Transformers లైబ్రరీ యొక్క ప్రధాన నిర్వహణదారులలో ఒకరు. గతంలో అతను fast.ai లో రీసెర్చ్ సైంటిస్ట్, మరియు అతను జెరెమీ హోవార్డ్‌తో కలిసి Deep Learning for Coders with fastai and PyTorch పుస్తకాన్ని సహ-రచించారు. పరిమిత వనరులతో మోడల్స్ వేగంగా శిక్షణ పొందడానికి వీలు కల్పించే టెక్నిక్‌లను రూపొందించడం మరియు మెరుగుపరచడం ద్వారా డీప్ లెర్నింగ్‌ను మరింత అందుబాటులోకి తీసుకురావడం అతని పరిశోధన యొక్క ముఖ్య ఉద్దేశ్యం. -[**Dawood Khan**](https://huggingface.co/dawoodkhan82) is a Machine Learning Engineer at Hugging Face. He's from NYC and graduated from New York University studying Computer Science. After working as an iOS Engineer for a few years, Dawood quit to start Gradio with his fellow co-founders. Gradio was eventually acquired by Hugging Face. +[**Dawood Khan**](https://huggingface.co/dawoodkhan82) Hugging Face లో మెషిన్ లెర్నింగ్ ఇంజనీర్. అతను NYC కి చెందినవాడు మరియు న్యూయార్క్ యూనివర్సిటీలో కంప్యూటర్ సైన్స్ చదివి పట్టభద్రుడయ్యాడు. కొన్ని సంవత్సరాలు ఐఓఎస్ ఇంజనీర్‌గా పనిచేసిన తరువాత, దావూద్ తన సహ-వ్యవస్థాపకులతో కలిసి Gradio ని ప్రారంభించడానికి ఉద్యోగాన్ని విడిచిపెట్టాడు. చివరికి Gradio ని Hugging Face కొనుగోలు చేసింది. -[**Merve Noyan**](https://huggingface.co/merve) is a developer advocate at Hugging Face, working on developing tools and building content around them to democratize machine learning for everyone. +[**Merve Noyan**](https://huggingface.co/merve) Hugging Face లో డెవలపర్ అడ్వకేట్, ప్రతిఒక్కరికీ మెషిన్ లెర్నింగ్‌ను ప్రజాస్వామ్యీకరించడానికి సాధనాలను అభివృద్ధి చేయడం మరియు వాటి చుట్టూ కంటెంట్‌ను నిర్మించడంపై పనిచేస్తున్నారు. -[**Lucile Saulnier**](https://huggingface.co/SaulLu) is a machine learning engineer at Hugging Face, developing and supporting the use of open source tools. She is also actively involved in many research projects in the field of Natural Language Processing such as collaborative training and BigScience. +[**Lucile Saulnier**](https://huggingface.co/SaulLu) Hugging Face లో మెషిన్ లెర్నింగ్ ఇంజనీర్, ఓపెన్ సోర్స్ సాధనాల వాడకాన్ని అభివృద్ధి చేయడం మరియు మద్దతు ఇవ్వడం. ఆమె సహకార శిక్షణ మరియు BigScience వంటి నాచురల్ లాంగ్వేజ్ ప్రాసెసింగ్ రంగంలో అనేక పరిశోధన ప్రాజెక్టులలో చురుకుగా పాల్గొంటున్నారు. -[**Lewis Tunstall**](https://huggingface.co/lewtun) is a machine learning engineer at Hugging Face, focused on developing open-source tools and making them accessible to the wider community. He is also a co-author of the O'Reilly book [Natural Language Processing with Transformers](https://www.oreilly.com/library/view/natural-language-processing/9781098136789/). +[**Lewis Tunstall**](https://huggingface.co/lewtun) Hugging Face లో మెషిన్ లెర్నింగ్ ఇంజనీర్, ఓపెన్-సోర్స్ సాధనాలను అభివృద్ధి చేయడం మరియు వాటిని విస్తృత സമൂഹానికి అందుబాటులోకి తీసుకురావడంపై దృష్టి పెట్టారు. అతను ఓ'రైల్లీ వారి [Natural Language Processing with Transformers](https://www.oreilly.com/library/view/natural-language-processing/9781098136789/)పుస్తక సహ-రచయిత కూడా. -[**Leandro von Werra**](https://huggingface.co/lvwerra) is a machine learning engineer in the open-source team at Hugging Face and also a co-author of the O'Reilly book [Natural Language Processing with Transformers](https://www.oreilly.com/library/view/natural-language-processing/9781098136789/). He has several years of industry experience bringing NLP projects to production by working across the whole machine learning stack.. +[**Leandro von Werra**](https://huggingface.co/lvwerra) Hugging Face లోని ఓపెన్-సోర్స్ బృందంలో మెషిన్ లెర్నింగ్ ఇంజనీర్ మరియు ఓ'రైల్లీ వారి [Natural Language Processing with Transformers](https://www.oreilly.com/library/view/natural-language-processing/9781098136789/) పుస్తక సహ-రచయిత కూడా. అతను మొత్తం మెషిన్ లెర్నింగ్ స్టాక్‌లో పనిచేయడం ద్వారా NLP ప్రాజెక్టులను ఉత్పత్తికి తీసుకురావడంలో చాలా సంవత్సరాల పరిశ్రమ అనుభవాన్ని కలిగి ఉన్నాడు. -## FAQ[[faq]] +## తరచుగా అడిగే ప్రశ్నలు (FAQ)[[faq]] -Here are some answers to frequently asked questions: +తరచుగా అడిగే ప్రశ్నలకు ఇక్కడ కొన్ని సమాధానాలు ఉన్నాయి: -- **Does taking this course lead to a certification?** -Currently we do not have any certification for this course. However, we are working on a certification program for the Hugging Face ecosystem -- stay tuned! +- **ఈ కోర్సు పూర్తి చేయడం ద్వారా సర్టిఫికేషన్ లభిస్తుందా?** + ప్రస్తుతానికి ఈ కోర్సుకు ఎలాంటి సర్టిఫికేషన్ లేదు. అయితే, మేము Hugging Face ఎకోసిస్టమ్ కోసం ఒక సర్టిఫికేషన్ కార్యక్రమంపై పనిచేస్తున్నాము -- వేచి ఉండండి! -- **How much time should I spend on this course?** -Each chapter in this course is designed to be completed in 1 week, with approximately 6-8 hours of work per week. However, you can take as much time as you need to complete the course. +- **ఈ కోర్సుపై నేను ఎంత సమయం కేటాయించాలి?** + ఈ కోర్సులోని ప్రతి అధ్యాయం వారానికి సుమారు 6-8 గంటల పనితో, 1 వారంలో పూర్తి చేసేలా రూపొందించబడింది. అయితే, కోర్సును పూర్తి చేయడానికి మీకు అవసరమైనంత సమయం తీసుకోవచ్చు. -- **Where can I ask a question if I have one?** -If you have a question about any section of the course, just click on the "*Ask a question*" banner at the top of the page to be automatically redirected to the right section of the [Hugging Face forums](https://discuss.huggingface.co/): +- **నాకు ఏదైనా ప్రశ్న ఉంటే, ఎక్కడ అడగాలి?** + కోర్సులోని ఏదైనా విభాగానికి సంబంధించి మీకు ప్రశ్న ఉంటే, పేజీ పైభాగంలో ఉన్న "Ask a question" (ప్రశ్న అడగండి) బ్యానర్‌పై క్లిక్ చేయండి, అప్పుడు మీరు [Hugging Face forums](https://discuss.huggingface.co/) లోని సరైన విభాగానికి ఆటోమేటిక్‌గా మళ్ళించబడతారు: Link to the Hugging Face forums -Note that a list of [project ideas](https://discuss.huggingface.co/c/course/course-event/25) is also available on the forums if you wish to practice more once you have completed the course. +కోర్సు పూర్తి చేసిన తర్వాత మీరు మరింత ప్రాక్టీస్ చేయాలనుకుంటే, ఫోరమ్‌లలో [ప్రాజెక్ట్ ఐడియాల](https://discuss.huggingface.co/c/course/course-event/25) జాబితా కూడా అందుబాటులో ఉందని గమనించండి. -- **Where can I get the code for the course?** -For each section, click on the banner at the top of the page to run the code in either Google Colab or Amazon SageMaker Studio Lab: +- **ఈ కోర్సు కోసం కోడ్‌ను ఎలా పొందాలి?** + ప్రతి విభాగం కోసం, Google Colab లేదా Amazon SageMaker Studio Lab లో కోడ్‌ను రన్ చేయడానికి పేజీ పైభాగంలో ఉన్న బ్యానర్‌పై క్లిక్ చేయండి: Link to the Hugging Face course notebooks -The Jupyter notebooks containing all the code from the course are hosted on the [`huggingface/notebooks`](https://github.com/huggingface/notebooks) repo. If you wish to generate them locally, check out the instructions in the [`course`](https://github.com/huggingface/course#-jupyter-notebooks) repo on GitHub. - +కోర్సులోని మొత్తం కోడ్‌ను కలిగి ఉన్న Jupyter నోట్‌బుక్‌లు [`huggingface/notebooks`](https://github.com/huggingface/notebooks) రిపోలో హోస్ట్ చేయబడ్డాయి. మీరు వాటిని స్థానికంగా (locally) రూపొందించాలనుకుంటే, GitHub లోని [`course`](https://github.com/huggingface/course#-jupyter-notebooks) రిపోలోని సూచనలను చూడండి. - **How can I contribute to the course?** -There are many ways to contribute to the course! If you find a typo or a bug, please open an issue on the [`course`](https://github.com/huggingface/course) repo. If you would like to help translate the course into your native language, check out the instructions [here](https://github.com/huggingface/course#translating-the-course-into-your-language). + There are many ways to contribute to the course! If you find a typo or a bug, please open an issue on the [`course`](https://github.com/huggingface/course) repo. If you would like to help translate the course into your native language, check out the instructions [here](https://github.com/huggingface/course#translating-the-course-into-your-language). -- ** What were the choices made for each translation?** -Each translation has a glossary and `TRANSLATING.txt` file that details the choices that were made for machine learning jargon etc. You can find an example for German [here](https://github.com/huggingface/course/blob/main/chapters/de/TRANSLATING.txt). +- **నేను కోర్సుకు ఎలా సహకరించగలను?** + కోర్సుకు సహకరించడానికి చాలా మార్గాలు ఉన్నాయి! మీరు ఏదైనా అక్షర దోషం (typo) లేదా బగ్ కనుగొంటే, దయచేసి [`course`](https://github.com/huggingface/course) రిపోలో ఒక ఇష్యూను ఓపెన్ చేయండి. మీరు కోర్సును మీ మాతృభాషలోకి అనువదించడానికి సహాయం చేయాలనుకుంటే, [ఇక్కడ](https://github.com/huggingface/course#translating-the-course-into-your-language) సూచనలను చూడండి. +**ప్రతి అనువాదం కోసం తీసుకున్న నిర్ణయాలు ఏమిటి?** +ప్రతి అనువాదం కోసం, మేము అనువాదంలో తీసుకున్న నిర్ణయాలను వివరించే ఒక `TRANSLATING.txt` ఫైల్‌ను కలిగి ఉన్నాము. ఈ ఫైల్‌లో మేము యంత్ర అభ్యాసం పదజాలం మరియు ఇతర సాంకేతిక పదజాలం కోసం చేసిన ఎంపికలను వివరించాము. ఉదాహరణకు, జర్మన్ కోసం [ఇక్కడ](https://github.com/huggingface/course/blob/main/chapters/de/TRANSLATING.txt) చూడండి. -- **Can I reuse this course?** -Of course! The course is released under the permissive [Apache 2 license](https://www.apache.org/licenses/LICENSE-2.0.html). This means that you must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use. If you would like to cite the course, please use the following BibTeX: +- **నేను ఈ కోర్సును తిరిగి ఉపయోగించుకోవచ్చా?** + తప్పకుండా! ఈ కోర్సు అనుమతి గల Apache 2 license క్రింద విడుదల చేయబడింది. దీని అర్థం మీరు తగిన క్రెడిట్ ఇవ్వాలి, లైసెన్సుకు లింక్ అందించాలి, మరియు ఏవైనా మార్పులు చేసినట్లయితే సూచించాలి. మీరు దీనిని ఏ సహేతుకమైన పద్ధతిలోనైనా చేయవచ్చు, కానీ లైసెన్సర్ మిమ్మల్ని లేదా మీ వినియోగాన్ని ఆమోదించినట్లు సూచించే ఏ విధంగానూ చేయకూడదు. మీరు కోర్సును ఉదహరించాలనుకుంటే, దయచేసి ఈ క్రింది BibTeX ను ఉపయోగించండి: ``` @misc{huggingfacecourse, @@ -116,45 +115,49 @@ Of course! The course is released under the permissive [Apache 2 license](https: } ``` -## Languages and translations[[languages-and-translations]] - -Thanks to our wonderful community, the course is available in many languages beyond English 🔥! Check out the table below to see which languages are available and who contributed to the translations: - -| Language | Authors | -|:------------------------------------------------------------------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| [French](https://huggingface.co/course/fr/chapter1/1) | [@lbourdois](https://github.com/lbourdois), [@ChainYo](https://github.com/ChainYo), [@melaniedrevet](https://github.com/melaniedrevet), [@abdouaziz](https://github.com/abdouaziz) | -| [Vietnamese](https://huggingface.co/course/vi/chapter1/1) | [@honghanhh](https://github.com/honghanhh) | -| [Chinese (simplified)](https://huggingface.co/course/zh-CN/chapter1/1) | [@zhlhyx](https://github.com/zhlhyx), [petrichor1122](https://github.com/petrichor1122), [@yaoqih](https://github.com/yaoqih) | -| [Bengali](https://huggingface.co/course/bn/chapter1/1) (WIP) | [@avishek-018](https://github.com/avishek-018), [@eNipu](https://github.com/eNipu) | -| [German](https://huggingface.co/course/de/chapter1/1) (WIP) | [@JesperDramsch](https://github.com/JesperDramsch), [@MarcusFra](https://github.com/MarcusFra), [@fabridamicelli](https://github.com/fabridamicelli) | -| [Spanish](https://huggingface.co/course/es/chapter1/1) (WIP) | [@camartinezbu](https://github.com/camartinezbu), [@munozariasjm](https://github.com/munozariasjm), [@fordaz](https://github.com/fordaz) | -| [Persian](https://huggingface.co/course/fa/chapter1/1) (WIP) | [@jowharshamshiri](https://github.com/jowharshamshiri), [@schoobani](https://github.com/schoobani) | -| [Gujarati](https://huggingface.co/course/gu/chapter1/1) (WIP) | [@pandyaved98](https://github.com/pandyaved98) | -| [Hebrew](https://huggingface.co/course/he/chapter1/1) (WIP) | [@omer-dor](https://github.com/omer-dor) | -| [Hindi](https://huggingface.co/course/hi/chapter1/1) (WIP) | [@pandyaved98](https://github.com/pandyaved98) | -| [Bahasa Indonesia](https://huggingface.co/course/id/chapter1/1) (WIP) | [@gstdl](https://github.com/gstdl) | -| [Italian](https://huggingface.co/course/it/chapter1/1) (WIP) | [@CaterinaBi](https://github.com/CaterinaBi), [@ClonedOne](https://github.com/ClonedOne), [@Nolanogenn](https://github.com/Nolanogenn), [@EdAbati](https://github.com/EdAbati), [@gdacciaro](https://github.com/gdacciaro) | -| [Japanese](https://huggingface.co/course/ja/chapter1/1) (WIP) | [@hiromu166](https://github.com/@hiromu166), [@younesbelkada](https://github.com/@younesbelkada), [@HiromuHota](https://github.com/@HiromuHota) | -| [Korean](https://huggingface.co/course/ko/chapter1/1) (WIP) | [@Doohae](https://github.com/Doohae), [@wonhyeongseo](https://github.com/wonhyeongseo), [@dlfrnaos19](https://github.com/dlfrnaos19) | -| [Portuguese](https://huggingface.co/course/pt/chapter1/1) (WIP) | [@johnnv1](https://github.com/johnnv1), [@victorescosta](https://github.com/victorescosta), [@LincolnVS](https://github.com/LincolnVS) | -| [Russian](https://huggingface.co/course/ru/chapter1/1) (WIP) | [@pdumin](https://github.com/pdumin), [@svv73](https://github.com/svv73) | -| [Thai](https://huggingface.co/course/th/chapter1/1) (WIP) | [@peeraponw](https://github.com/peeraponw), [@a-krirk](https://github.com/a-krirk), [@jomariya23156](https://github.com/jomariya23156), [@ckingkan](https://github.com/ckingkan) | -| [Turkish](https://huggingface.co/course/tr/chapter1/1) (WIP) | [@tanersekmen](https://github.com/tanersekmen), [@mertbozkir](https://github.com/mertbozkir), [@ftarlaci](https://github.com/ftarlaci), [@akkasayaz](https://github.com/akkasayaz) | -| [Chinese (traditional)](https://huggingface.co/course/zh-TW/chapter1/1) (WIP) | [@davidpeng86](https://github.com/davidpeng86) | - -For some languages, the [course YouTube videos](https://youtube.com/playlist?list=PLo2EIpI_JMQvWfQndUesu0nPBAtZ9gP1o) have subtitles in the language. You can enable them by first clicking the _CC_ button in the bottom right corner of the video. Then, under the settings icon ⚙️, you can select the language you want by selecting the _Subtitles/CC_ option. +## భాషలు మరియు అనువాదాలు[[languages-and-translations]] + +మా అద్భుతమైన కమ్యూనిటీకి ధన్యవాదాలు, ఈ కోర్సు ఇంగ్లీష్‌తో పాటు అనేక ఇతర భాషలలో కూడా అందుబాటులో ఉంది 🔥! ఏయే భాషలు అందుబాటులో ఉన్నాయో మరియు అనువాదాలకు ఎవరు సహకరించారో చూడటానికి దిగువ పట్టికను చూడండి: + +| భాష | రచయితలు | +| :--------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [French](https://huggingface.co/course/fr/chapter1/1) | [@lbourdois](https://github.com/lbourdois), [@ChainYo](https://github.com/ChainYo), [@melaniedrevet](https://github.com/melaniedrevet), [@abdouaziz](https://github.com/abdouaziz) | +| [Vietnamese](https://huggingface.co/course/vi/chapter1/1) | [@honghanhh](https://github.com/honghanhh) | +| [Chinese (simplified)](https://huggingface.co/course/zh-CN/chapter1/1) | [@zhlhyx](https://github.com/zhlhyx), [petrichor1122](https://github.com/petrichor1122), [@yaoqih](https://github.com/yaoqih) | +| [Bengali](https://huggingface.co/course/bn/chapter1/1) (పని జరుగుతోంది) | [@avishek-018](https://github.com/avishek-018), [@eNipu](https://github.com/eNipu) | +| [German](https://huggingface.co/course/de/chapter1/1) (పని జరుగుతోంది) | [@JesperDramsch](https://github.com/JesperDramsch), [@MarcusFra](https://github.com/MarcusFra), [@fabridamicelli](https://github.com/fabridamicelli) | +| [Spanish](https://huggingface.co/course/es/chapter1/1) (పని జరుగుతోంది) | [@camartinezbu](https://github.com/camartinezbu), [@munozariasjm](https://github.com/munozariasjm), [@fordaz](https://github.com/fordaz) | +| [Persian](https://huggingface.co/course/fa/chapter1/1) (పని జరుగుతోంది) | [@jowharshamshiri](https://github.com/jowharshamshiri), [@schoobani](https://github.com/schoobani) | +| [Gujarati](https://huggingface.co/course/gu/chapter1/1) (పని జరుగుతోంది) | [@pandyaved98](https://github.com/pandyaved98) | +| [Hebrew](https://huggingface.co/course/he/chapter1/1) (పని జరుగుతోంది) | [@omer-dor](https://github.com/omer-dor) | +| [Hindi](https://huggingface.co/course/hi/chapter1/1) (పని జరుగుతోంది) | [@pandyaved98](https://github.com/pandyaved98) | +| [Bahasa Indonesia](https://huggingface.co/course/id/chapter1/1) (పని జరుగుతోంది) | [@gstdl](https://github.com/gstdl) | +| [Italian](https://huggingface.co/course/it/chapter1/1) (పని జరుగుతోంది) | [@CaterinaBi](https://github.com/CaterinaBi), [@ClonedOne](https://github.com/ClonedOne), [@Nolanogenn](https://github.com/Nolanogenn), [@EdAbati](https://github.com/EdAbati), [@gdacciaro](https://github.com/gdacciaro) | +| [Japanese](https://huggingface.co/course/ja/chapter1/1) (పని జరుగుతోంది) | [@hiromu166](https://github.com/@hiromu166), [@younesbelkada](https://github.com/@younesbelkada), [@HiromuHota](https://github.com/@HiromuHota) | +| [Korean](https://huggingface.co/course/ko/chapter1/1) (పని జరుగుతోంది) | [@Doohae](https://github.com/Doohae), [@wonhyeongseo](https://github.com/wonhyeongseo), [@dlfrnaos19](https://github.com/dlfrnaos19) | +| [Portuguese](https://huggingface.co/course/pt/chapter1/1) (పని జరుగుతోంది) | [@johnnv1](https://github.com/johnnv1), [@victorescosta](https://github.com/victorescosta), [@LincolnVS](https://github.com/LincolnVS) | +| [Russian](https://huggingface.co/course/ru/chapter1/1) (పని జరుగుతోంది) | [@pdumin](https://github.com/pdumin), [@svv73](https://github.com/svv73) | +| [Thai](https://huggingface.co/course/th/chapter1/1) (పని జరుగుతోంది) | [@peeraponw](https://github.com/peeraponw), [@a-krirk](https://github.com/a-krirk), [@jomariya23156](https://github.com/jomariya23156), [@ckingkan](https://github.com/ckingkan) | +| [Turkish](https://huggingface.co/course/tr/chapter1/1) (పని జరుగుతోంది) | [@tanersekmen](https://github.com/tanersekmen), [@mertbozkir](https://github.com/mertbozkir), [@ftarlaci](https://github.com/ftarlaci), [@akkasayaz](https://github.com/akkasayaz) | +| [Chinese (traditional)](https://huggingface.co/course/zh-TW/chapter1/1) (పని జరుగుతోంది) | [@davidpeng86](https://github.com/davidpeng86) | + +కొన్ని భాషల కోసం, [కోర్సు YouTube వీడియోలలో] (https://youtube.com/playlist?list=PLo2EIpI_JMQvWfQndUesu0nPBAtZ9gP1o) ఆ భాషలో సబ్-టైటిల్స్ ఉన్నాయి. వీడియో యొక్క కుడి దిగువ మూలలో ఉన్న CC బటన్‌పై ముందుగా క్లిక్ చేయడం ద్వారా మీరు వాటిని ప్రారంభించవచ్చు. ఆ తర్వాత, సెట్టింగ్స్ ఐకాన్ ⚙️ క్రింద, Subtitles/CC ఎంపికను ఎంచుకోవడం ద్వారా మీకు కావలసిన భాషను ఎంచుకోవచ్చు. Activating subtitles for the Hugging Face course YouTube videos -Don't see your language in the above table or you'd like to contribute to an existing translation? You can help us translate the course by following the instructions here. + పైన పట్టికలో మీ భాష కనిపించలేదా లేదా మీరు ఇప్పటికే ఉన్న అనువాదానికి + సహకరించాలనుకుంటున్నారా? ఇక్కడ ఉన్న సూచనలను{" "} + + ఇక్కడ + + అనుసరించడం ద్వారా మీరు కోర్సును అనువదించడానికి మాకు సహాయం చేయవచ్చు. -## Let's go 🚀 - -Are you ready to roll? In this chapter, you will learn: +## ప్రారంభిద్దాం 🚀 -* How to use the `pipeline()` function to solve NLP tasks such as text generation and classification -* About the Transformer architecture -* How to distinguish between encoder, decoder, and encoder-decoder architectures and use cases +మీరు సిద్ధంగా ఉన్నారా? ఈ అధ్యాయంలో, మీరు నేర్చుకుంటారు: +- టెక్స్ట్ జనరేషన్ మరియు వర్గీకరణ వంటి NLP పనులను పరిష్కరించడానికి `pipeline()` ఫంక్షన్‌ను ఎలా ఉపయోగించాలో. +- Transformer నిర్మాణం గురించి. +- ఎన్‌కోడర్, డీకోడర్, మరియు ఎన్‌కోడర్-డీకోడర్ ఆర్కిటెక్చర్ల మధ్య తేడాను మరియు వాటి వినియోగ సందర్భాలను ఎలా గుర్తించాలో. diff --git a/chapters/te/chapter1/10.mdx b/chapters/te/chapter1/10.mdx index b5d646a3c..173671679 100644 --- a/chapters/te/chapter1/10.mdx +++ b/chapters/te/chapter1/10.mdx @@ -1,66 +1,71 @@ -# Summary[[summary]] +# సారాంశం[[summary]] - + -In this chapter, you've been introduced to the fundamentals of Transformer models, Large Language Models (LLMs), and how they're revolutionizing AI and beyond. +ఈ అధ్యాయంలో, మీరు Transformer నమూనాలు, Large Language Models (LLMs) యొక్క ప్రాథమిక అంశాలకు పరిచయం చేయబడ్డారు, మరియు అవి AI మరియు అంతకు మించి ఎలా విప్లవాత్మకంగా మారుస్తున్నాయో తెలుసుకున్నారు. -## Key concepts covered +## చర్చించిన ముఖ్యమైన అంశాలు -### Natural Language Processing and LLMs +### Natural Language Processing మరియు LLMs -We explored what NLP is and how Large Language Models have transformed the field. You learned that: -- NLP encompasses a wide range of tasks from classification to generation -- LLMs are powerful models trained on massive amounts of text data -- These models can perform multiple tasks within a single architecture -- Despite their capabilities, LLMs have limitations including hallucinations and bias +NLP అంటే ఏమిటి మరియు Large Language Models ఈ రంగాన్ని ఎలా మార్చాయో మేము అన్వేషించాము. మీరు నేర్చుకున్నవి: -### Transformer capabilities +- NLP వర్గీకరణ నుండి జనరేషన్ వరకు విస్తృత శ్రేణి పనులను కలిగి ఉంటుంది +- LLMs అనేవి భారీ మొత్తంలో టెక్స్ట్ డేటాపై శిక్షణ పొందిన శక్తివంతమైన నమూనాలు +- ఈ నమూనాలు ఒకే ఆర్కిటెక్చర్‌లో బహుళ పనులను చేయగలవు +- వాటి సామర్థ్యాలు ఉన్నప్పటికీ, LLMs కు భ్రాంతులు మరియు పక్షపాతం వంటి పరిమితులు ఉన్నాయి -You saw how the `pipeline()` function from 🤗 Transformers makes it easy to use pre-trained models for various tasks: -- Text classification, token classification, and question answering -- Text generation and summarization -- Translation and other sequence-to-sequence tasks -- Speech recognition and image classification +### Transformer సామర్థ్యాలు -### Transformer architecture +🤗 Transformers నుండి `pipeline()` ఫంక్షన్ వివిధ పనుల కోసం ముందుగా శిక్షణ పొందిన నమూనాలను ఉపయోగించడాన్ని ఎలా సులభతరం చేస్తుందో మీరు చూశారు: -We discussed how Transformer models work at a high level, including: -- The importance of the attention mechanism -- How transfer learning enables models to adapt to specific tasks -- The three main architectural variants: encoder-only, decoder-only, and encoder-decoder +- టెక్స్ట్ వర్గీకరణ, టోకెన్ వర్గీకరణ, మరియు ప్రశ్న సమాధానం +- టెక్స్ట్ జనరేషన్ మరియు సారాంశం +- అనువాదం మరియు ఇతర సీక్వెన్స్-టు-సీక్వెన్స్ పనులు +- ప్రసంగ గుర్తింపు మరియు చిత్ర వర్గీకరణ -### Model architectures and their applications -A key aspect of this chapter was understanding which architecture to use for different tasks: +### Transformer ఆర్కిటెక్చర్ -| Model | Examples | Tasks | -|-----------------|--------------------------------------------|----------------------------------------------------------------------------------| -| Encoder-only | BERT, DistilBERT, ModernBERT | Sentence classification, named entity recognition, extractive question answering | -| Decoder-only | GPT, LLaMA, Gemma, SmolLM | Text generation, conversational AI, creative writing | -| Encoder-decoder | BART, T5, Marian, mBART | Summarization, translation, generative question answering | +Transformer నమూనాలు ఉన్నత స్థాయిలో ఎలా పనిచేస్తాయో మేము చర్చించాము, వీటితో సహా: -### Modern LLM developments -You also learned about recent developments in the field: -- How LLMs have grown in size and capability over time -- The concept of scaling laws and how they guide model development -- Specialized attention mechanisms that help models process longer sequences -- The two-phase training approach of pretraining and instruction tuning +- అటెన్షన్ మెకానిజం యొక్క ప్రాముఖ్యత +- ట్రాన్స్‌ఫర్ లెర్నింగ్ నమూనాలను నిర్దిష్ట పనులకు అనుగుణంగా మార్చడానికి ఎలా వీలు కల్పిస్తుంది +- మూడు ప్రధాన ఆర్కిటెక్చరల్ వేరియంట్‌లు: ఎన్‌కోడర్-మాత్రమే, డీకోడర్-మాత్రమే, మరియు ఎన్‌కోడర్-డీకోడర్ -### Practical applications -Throughout the chapter, you've seen how these models can be applied to real-world problems: -- Using the Hugging Face Hub to find and use pre-trained models -- Leveraging the Inference API to test models directly in your browser -- Understanding which models are best suited for specific tasks +### మోడల్ ఆర్కిటెక్చర్‌లు మరియు వాటి అనువర్తనాలు -## Looking ahead +ఈ అధ్యాయంలోని ఒక ముఖ్యమైన అంశం ఏమిటంటే, వివిధ పనుల కోసం ఏ ఆర్కిటెక్చర్‌ను ఉపయోగించాలో అర్థం చేసుకోవడం: -Now that you have a solid understanding of what Transformer models are and how they work at a high level, you're ready to dive deeper into how to use them effectively. In the next chapters, you'll learn how to: +| మోడల్ | ఉదాహరణలు | పనులు | +| ----------------- | ---------------------------- | ----------------------------------------------------------------------------- | +| ఎన్‌కోడర్-మాత్రమే | BERT, DistilBERT, ModernBERT | వాక్య వర్గీకరణ, నేమ్డ్ ఎంటిటీ రికగ్నిషన్, ఎక్స్‌ట్రాక్టివ్ క్వశ్చన్ ఆన్సరింగ్ | +| డీకోడర్-మాత్రమే | GPT, LLaMA, Gemma, SmolLM | టెక్స్ట్ జనరేషన్, సంభాషణ AI, సృజనాత్మక రచన | +| ఎన్‌కోడర్-డీకోడర్ | BART, T5, Marian, mBART | సారాంశం, అనువాదం, జెనరేటివ్ క్వశ్చన్ ఆన్సరింగ్ | -- Use the Transformers library to load and fine-tune models -- Process different types of data for model input -- Adapt pre-trained models to your specific tasks -- Deploy models for practical applications +### ఆధునిక LLM అభివృద్ధిలు -The foundation you've built in this chapter will serve you well as you explore more advanced topics and techniques in the coming sections. +ఈ రంగంలో ఇటీవలి పరిణామాల గురించి కూడా మీరు తెలుసుకున్నారు: + +- కాలక్రమేణా LLMs పరిమాణంలో మరియు సామర్థ్యంలో ఎలా పెరిగాయి +- స్కేలింగ్ చట్టాల భావన మరియు అవి మోడల్ అభివృద్ధికి ఎలా మార్గనిర్దేశం చేస్తాయి +- పొడవైన సీక్వెన్స్‌లను ప్రాసెస్ చేయడానికి మోడళ్లకు సహాయపడే ప్రత్యేక అటెన్షన్ మెకానిజమ్స్ +- ప్రీట్రైనింగ్ మరియు ఇన్‌స్ట్రక్షన్ ట్యూనింగ్ యొక్క రెండు-దశల శిక్షణ విధానం + +### ఆచరణాత్మక అనువర్తనాలు + +అధ్యాయం అంతటా, ఈ నమూనాలను వాస్తవ-ప్రపంచ సమస్యలకు ఎలా వర్తింపజేయవచ్చో మీరు చూశారు: + +- ముందుగా శిక్షణ పొందిన నమూనాలను కనుగొని ఉపయోగించడానికి Hugging Face Hub ను ఉపయోగించడం +- మీ బ్రౌజర్‌లో నేరుగా నమూనాలను పరీక్షించడానికి Inference API ని ఉపయోగించడం +- నిర్దిష్ట పనులకు ఏ నమూనాలు ఉత్తమంగా సరిపోతాయో అర్థం చేసుకోవడం + +## భవిష్యత్తు ప్రణాళిక + +Transformer నమూనాలు అంటే ఏమిటి మరియు అవి ఉన్నత స్థాయిలో ఎలా పనిచేస్తాయో ఇప్పుడు మీకు దృఢమైన అవగాహన ఉంది కాబట్టి, వాటిని సమర్థవంతంగా ఎలా ఉపయోగించాలో లోతుగా పరిశోధించడానికి మీరు సిద్ధంగా ఉన్నారు. తదుపరి అధ్యాయాలలో, మీరు ఎలా చేయాలో నేర్చుకుంటారు: + +- నమూనాలను లోడ్ చేయడానికి మరియు ఫైన్-ట్యూన్ చేయడానికి Transformers లైబ్రరీని ఉపయోగించడం +- మోడల్ ఇన్‌పుట్ కోసం వివిధ రకాల డేటాను ప్రాసెస్ చేయడం +- మీ నిర్దిష్ట పనులకు ముందుగా శిక్షణ పొందిన నమూనాలను అనుకూలీకరించడం +- ఆచరణాత్మక అనువర్తనాల కోసం నమూనాలను అమలు చేయడం + +ఈ అధ్యాయంలో మీరు నిర్మించుకున్న పునాది, రాబోయే విభాగాలలో మీరు మరింత ఆధునిక అంశాలు మరియు పద్ధతులను అన్వేషించేటప్పుడు మీకు బాగా ఉపయోగపడుతుంది. diff --git a/chapters/te/chapter1/11.mdx b/chapters/te/chapter1/11.mdx index dddddf271..2f5d7ba12 100644 --- a/chapters/te/chapter1/11.mdx +++ b/chapters/te/chapter1/11.mdx @@ -1,21 +1,20 @@ -# Exam Time! +# పరీక్షా సమయం! -It's time to put your knowledge to the test! We've prepared a short quiz for you to test your understanding of the concepts covered in this chapter. +మీ జ్ఞానాన్ని పరీక్షించుకునే సమయం ఆసన్నమైంది! ఈ అధ్యాయంలో చర్చించిన అంశాలపై మీ అవగాహనను పరీక్షించడానికి మేము మీ కోసం ఒక చిన్న క్విజ్‌ను సిద్ధం చేసాము. -To take the quiz, you will need to follow these steps: +క్విజ్ తీసుకోవడానికి, మీరు ఈ దశలను అనుసరించాలి: -1. Sign in to your Hugging Face account. -2. Answer the questions in the quiz. -3. Submit your answers. +1. మీ Hugging Face ఖాతాకు సైన్ ఇన్ చేయండి. +2. క్విజ్‌లోని ప్రశ్నలకు సమాధానం ఇవ్వండి. +3. మీ సమాధానాలను సమర్పించండి. +## మల్టిపుల్ ఛాయిస్ క్విజ్ -## Multiple Choice Quiz - -In this quiz, you will be asked to select the correct answer from a list of options. We'll test you on the fundamentals of supervised finetuning. +ఈ క్విజ్‌లో, మీరు ఎంపికల జాబితా నుండి సరైన సమాధానాన్ని ఎంచుకోవాలి. పర్యవేక్షించబడిన ఫైన్‌ట్యూనింగ్ యొక్క ప్రాథమిక అంశాలపై మేము మిమ్మల్ని పరీక్షిస్తాము. diff --git a/chapters/te/chapter1/2.mdx b/chapters/te/chapter1/2.mdx index 13fa4eef2..fa7996c5d 100644 --- a/chapters/te/chapter1/2.mdx +++ b/chapters/te/chapter1/2.mdx @@ -1,55 +1,56 @@ -# Natural Language Processing and Large Language Models[[natural-language-processing-and-large-language-models]] +# Natural Language Processing (NLP) మరియు Large Language Models (LLMs)[[natural-language-processing-and-large-language-models]] - + -Before jumping into Transformer models, let's do a quick overview of what natural language processing is, how large language models have transformed the field, and why we care about it. +Transformer మోడల్స్‌లోకి వెళ్లే ముందు, Natural Language Processing అంటే ఏమిటి, Large Language Models ఈ రంగాన్ని ఎలా మార్చాయి మరియు మనం దాని గురించి ఎందుకు శ్రద్ధ వహించాలి అనే దానిపై త్వరగా ఒక అవలోకనం చేద్దాం. -## What is NLP?[[what-is-nlp]] +## NLP అంటే ఏమిటి?[[what-is-nlp]] -NLP is a field of linguistics and machine learning focused on understanding everything related to human language. The aim of NLP tasks is not only to understand single words individually, but to be able to understand the context of those words. +NLP అనేది మానవ భాషకు సంబంధించిన ప్రతిదాన్ని అర్థం చేసుకోవడంపై దృష్టి సారించే భాషాశాస్త్రం మరియు మెషిన్ లెర్నింగ్ రంగం. NLP పనుల లక్ష్యం కేవలం ఒక్కొక్క పదాన్ని వ్యక్తిగతంగా అర్థం చేసుకోవడం మాత్రమే కాదు, ఆ పదాల సందర్భాన్ని అర్థం చేసుకోగలగడం. -The following is a list of common NLP tasks, with some examples of each: +సాధారణ NLP పనుల జాబితా క్రింద ఇవ్వబడింది, ప్రతిదానికి కొన్ని ఉదాహరణలతో: -- **Classifying whole sentences**: Getting the sentiment of a review, detecting if an email is spam, determining if a sentence is grammatically correct or whether two sentences are logically related or not -- **Classifying each word in a sentence**: Identifying the grammatical components of a sentence (noun, verb, adjective), or the named entities (person, location, organization) -- **Generating text content**: Completing a prompt with auto-generated text, filling in the blanks in a text with masked words -- **Extracting an answer from a text**: Given a question and a context, extracting the answer to the question based on the information provided in the context -- **Generating a new sentence from an input text**: Translating a text into another language, summarizing a text +- **మొత్తం వాక్యాలను వర్గీకరించడం**: ఒక సమీక్ష యొక్క భావనను పొందడం, ఒక ఇమెయిల్ స్పామా కాదా అని గుర్తించడం, ఒక వాక్యం వ్యాకరణపరంగా సరైనదా లేదా రెండు వాక్యాలు తార్కికంగా సంబంధం కలిగి ఉన్నాయా లేదా అని నిర్ణయించడం. +- **ఒక వాక్యంలో ప్రతి పదాన్ని వర్గీకరించడం**: ఒక వాక్యం యొక్క వ్యాకరణ భాగాలను (నామవాచకం, క్రియ, విశేషణం) లేదా పేరున్న ఎంటిటీలను (వ్యక్తి, స్థలం, సంస్థ) గుర్తించడం +- **వచన కంటెంట్‌ను రూపొందించడం**: స్వయంచాలకంగా సృష్టించబడిన వచనంతో ఒక ప్రాంప్ట్‌ను పూర్తి చేయడం, మాస్క్ చేయబడిన పదాలతో ఒక వచనంలో ఖాళీలను పూరించడం. +- **ఒక వచనం నుండి సమాధానాన్ని సేకరించడం**: ఒక ప్రశ్న మరియు సందర్భం ఇచ్చినప్పుడు, సందర్భంలో అందించబడిన సమాచారం ఆధారంగా ప్రశ్నకు సమాధానాన్ని సేకరించడం. +- **ఇన్‌పుట్ వచనం నుండి కొత్త వాక్యాన్ని రూపొందించడం**: ఒక వచనాన్ని మరొక భాషలోకి అనువదించడం, ఒక వచనాన్ని సంగ్రహించడం. -NLP isn't limited to written text though. It also tackles complex challenges in speech recognition and computer vision, such as generating a transcript of an audio sample or a description of an image. +NLP కేవలం వ్రాతపూర్వక వచనానికి మాత్రమే పరిమితం కాదు. ఇది ప్రసంగ గుర్తింపు మరియు కంప్యూటర్ విజన్‌లో సంక్లిష్ట సవాళ్లను కూడా పరిష్కరిస్తుంది, ఉదాహరణకు ఆడియో నమూనా యొక్క ట్రాన్స్‌క్రిప్ట్ లేదా చిత్రం యొక్క వివరణను రూపొందించడం వంటివి. -## The Rise of Large Language Models (LLMs)[[rise-of-llms]] +## Large Language Models (LLMs) పెరుగుదల[[rise-of-llms]] -In recent years, the field of NLP has been revolutionized by Large Language Models (LLMs). These models, which include architectures like GPT (Generative Pre-trained Transformer) and [Llama](https://huggingface.co/meta-llama), have transformed what's possible in language processing. +ఇటీవలి సంవత్సరాలలో, NLP రంగం Large Language Models (LLMs) ద్వారా విప్లవాత్మకంగా మారింది. GPT (Generative Pre-trained Transformer) మరియు [Llama](https://huggingface.co/meta-llama), వంటి ఆర్కిటెక్చర్లను కలిగి ఉన్న ఈ మోడల్స్, భాషా ప్రాసెసింగ్‌లో సాధ్యమయ్యే వాటిని మార్చాయి. -A large language model (LLM) is an AI model trained on massive amounts of text data that can understand and generate human-like text, recognize patterns in language, and perform a wide variety of language tasks without task-specific training. They represent a significant advancement in the field of natural language processing (NLP). +ఒక Large Language Model (LLM) అనేది భారీ మొత్తంలో వచన డేటాపై శిక్షణ పొందిన ఒక AI మోడల్, ఇది మానవ-వంటి వచనాన్ని అర్థం చేసుకోగలదు మరియు ఉత్పత్తి చేయగలదు, భాషలో నమూనాలను గుర్తించగలదు మరియు టాస్క్-నిర్దిష్ట శిక్షణ లేకుండా విస్తృత శ్రేణి భాషా పనులను చేయగలదు. అవి Natural Language Processing (NLP) రంగంలో గణనీయమైన పురోగతిని సూచిస్తాయి. -LLMs are characterized by: -- **Scale**: They contain millions, billions, or even hundreds of billions of parameters -- **General capabilities**: They can perform multiple tasks without task-specific training -- **In-context learning**: They can learn from examples provided in the prompt -- **Emergent abilities**: As these models grow in size, they demonstrate capabilities that weren't explicitly programmed or anticipated +LLMలు వీటి ద్వారా వర్గీకరించబడతాయి: -The advent of LLMs has shifted the paradigm from building specialized models for specific NLP tasks to using a single, large model that can be prompted or fine-tuned to address a wide range of language tasks. This has made sophisticated language processing more accessible while also introducing new challenges in areas like efficiency, ethics, and deployment. +- **ప్రమాణం**: ఇవి లక్షల, బిలియన్ల లేదా సెంట్స్ బిలియన్ల పరామితులను కలిగి ఉంటాయి +- **సామాన్య సామర్థ్యాలు**: ఇవి టాస్క్-నిర్దిష్ట శిక్షణ లేకుండా అనేక పనులను నిర్వహించగలవు +- **ఇన్-కాంటెక్స్ట్ లెర్నింగ్**: ఇవి ప్రాంప్ట్‌లో అందించిన ఉదాహరణల నుండి నేర్చుకోవచ్చు +- **ఉద్భవించే సామర్థ్యాలు**: ఈ మోడల్స్ పరిమాణంలో పెరిగేకొద్దీ, అవి స్పష్టంగా ప్రోగ్రామ్ చేయబడని లేదా ఊహించని సామర్థ్యాలను ప్రదర్శిస్తాయి -However, LLMs also have important limitations: -- **Hallucinations**: They can generate incorrect information confidently -- **Lack of true understanding**: They lack true understanding of the world and operate purely on statistical patterns -- **Bias**: They may reproduce biases present in their training data or inputs. -- **Context windows**: They have limited context windows (though this is improving) -- **Computational resources**: They require significant computational resources +LLMల ఉద్భవం, ప్రత్యేక NLP పనుల కోసం ప్రత్యేక మోడల్స్‌ను నిర్మించడంనుంచి, విస్తృత శ్రేణా భాషా పనులను పరిష్కరించడానికి ప్రాంప్ట్ చేయబడిన లేదా ఫైన్-ట్యూన్ చేయబడిన ఒక పెద్ద మోడల్‌ను ఉపయోగించడం వరకు మార్పు తీసుకువచ్చింది. ఇది సాంకేతిక భాషా ప్రాసెసింగ్‌ను మరింత అందుబాటులోకి తెచ్చింది, కానీ సమర్థత, నైతికత మరియు అమలు వంటి కొత్త సవాళ్లను కూడా పరిచయం చేసింది. -## Why is language processing challenging?[[why-is-it-challenging]] +## LLMలు మరియు వాటి పరిమితులు[[llms-and-their-limitations]] -Computers don't process information in the same way as humans. For example, when we read the sentence "I am hungry," we can easily understand its meaning. Similarly, given two sentences such as "I am hungry" and "I am sad," we're able to easily determine how similar they are. For machine learning (ML) models, such tasks are more difficult. The text needs to be processed in a way that enables the model to learn from it. And because language is complex, we need to think carefully about how this processing must be done. There has been a lot of research done on how to represent text, and we will look at some methods in the next chapter. +LLMలు కూడా ముఖ్యమైన పరిమితులను కలిగి ఉంటాయి: -Even with the advances in LLMs, many fundamental challenges remain. These include understanding ambiguity, cultural context, sarcasm, and humor. LLMs address these challenges through massive training on diverse datasets, but still often fall short of human-level understanding in many complex scenarios. +- **హాల్యూసినేషన్స్**: అవి తప్పు సమాచారాన్ని నమ్మకంగా ఉత్పత్తి చేయగలవు +- **నిజమైన అర్థం లేకపోవడం**: అవి ప్రపంచాన్ని నిజంగా అర్థం చేసుకోలేవు మరియు కేవలం గణాంక నమూనాలపై పనిచేస్తాయి +- **పక్షపాతం**: అవి శిక్షణ డేటా లేదా ఇన్‌పుట్‌లో ఉన్న పక్షపాతాన్ని పునరావృతించవచ్చు +- **కాంటెక్స్ట్ విండోలు**: అవి పరిమిత సందర్భ విండోలను కలిగి ఉంటాయి (అయితే ఇది మెరుగుపడుతోంది) +- **కంప్యూటేషనల్ వనరులు**: అవి గణనీయమైన కంప్యూటేషనల్ వనరులను అవసరం + +## భాషా ప్రాసెసింగ్ ఎందుకు సవాలుగా ఉంది?[[why-is-it-challenging]] + +కంప్యూటర్లు మానవులు ప్రాసెస్ చేసే విధంగా సమాచారాన్ని ప్రాసెస్ చేయవు. ఉదాహరణకు, మనం "I am hungry" అనే వాక్యాన్ని చదివినప్పుడు, మనం దాని అర్థాన్ని సులభంగా అర్థం చేసుకోగలం. అదేవిధంగా, "I am hungry" మరియు "I am sad" వంటి రెండు వాక్యాలు ఇచ్చినప్పుడు, అవి ఎంత సారూప్యంగా ఉన్నాయో మనం సులభంగా నిర్ణయించగలం. మెషిన్ లెర్నింగ్ (ML) మోడల్స్‌కు, అటువంటి పనులు మరింత కష్టం. మోడల్ దాని నుండి నేర్చుకోవడానికి వీలుగా వచనాన్ని ప్రాసెస్ చేయాలి. మరియు భాష సంక్లిష్టంగా ఉన్నందున, ఈ ప్రాసెసింగ్ ఎలా చేయబడాలి అనే దాని గురించి మనం జాగ్రత్తగా ఆలోచించాలి. వచనాన్ని ఎలా సూచించాలో చాలా పరిశోధనలు జరిగాయి, మరియు తదుపరి అధ్యాయంలో కొన్ని పద్ధతులను చూద్దాం. + +LLMలలో పురోగతి ఉన్నప్పటికీ, అనేక ప్రాథమిక సవాళ్లు అలాగే ఉన్నాయి. వీటిలో అస్పష్టత, సాంస్కృతిక సందర్భం, వ్యంగ్యం మరియు హాస్యం అర్థం చేసుకోవడం ఉన్నాయి. LLMలు విభిన్న డేటాసెట్‌లపై భారీ శిక్షణ ద్వారా ఈ సవాళ్లను పరిష్కరిస్తాయి, అయితే అనేక సంక్లిష్ట దృశ్యాలలో మానవ-స్థాయి అవగాహనకు తరచుగా తక్కువగా ఉంటాయి. diff --git a/chapters/te/chapter1/3.mdx b/chapters/te/chapter1/3.mdx index df13888ec..28f4e3755 100644 --- a/chapters/te/chapter1/3.mdx +++ b/chapters/te/chapter1/3.mdx @@ -1,41 +1,52 @@ -# Transformers, what can they do?[[transformers-what-can-they-do]] +# ట్రాన్స్‌ఫార్మర్‌లు, అవి ఏమి చేయగలవు?[[transformers-what-can-they-do]] - - -In this section, we will look at what Transformer models can do and use our first tool from the 🤗 Transformers library: the `pipeline()` function. + { + label: "Google Colab", + value: + "https://colab.research.google.com/github/huggingface/notebooks/blob/master/course/en/chapter1/section3.ipynb", + }, + { + label: "Aws Studio", + value: + "https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/course/en/chapter1/section3.ipynb", + }, + ]} +/> + +ఈ విభాగంలో, Transformer మోడల్స్ ఏమి చేయగలవో చూద్దాం మరియు 🤗 Transformers లైబ్రరీ నుండి మా మొదటి సాధనం: `pipeline()` ఫంక్షన్‌ను ఉపయోగిద్దాం. -👀 See that Open in Colab button on the top right? Click on it to open a Google Colab notebook with all the code samples of this section. This button will be present in any section containing code examples. +👀 కుడివైపు పైభాగంలో ఉన్న Open in Colab బటన్ చూడండి? దానిపై క్లిక్ చేసి, ఈ విభాగానికి సంబంధించిన అన్ని కోడ్ నమూనాలతో ఉన్న Google Colab నోట్‌బుక్‌ను తెరవండి. కోడ్ ఉదాహరణలు ఉన్న ఏ విభాగంలోనైనా ఈ బటన్ ఉంటుంది. + +మీరు ఉదాహరణలను స్థానికంగా అమలు చేయాలనుకుంటే, మేము సెటప్ ను చూడమని సిఫార్సు చేస్తాము. -If you want to run the examples locally, we recommend taking a look at the setup. -## Transformers are everywhere![[transformers-are-everywhere]] +## ట్రాన్స్‌ఫార్మర్‌లు ప్రతిచోటా ఉన్నాయి![[transformers-are-everywhere]] -Transformer models are used to solve all kinds of tasks across different modalities, including natural language processing (NLP), computer vision, audio processing, and more. Here are some of the companies and organizations using Hugging Face and Transformer models, who also contribute back to the community by sharing their models: +Transformer మోడల్స్ సహజ భాషా ప్రాసెసింగ్ (NLP), కంప్యూటర్ విజన్, ఆడియో ప్రాసెసింగ్ మరియు మరిన్ని వంటి వివిధ రంగాలలో అన్ని రకాల పనులను పరిష్కరించడానికి ఉపయోగిస్తారు. ఇక్కడ కొన్ని కంపెనీలు మరియు సంస్థలు ఉన్నాయి, ఇవి Hugging Face మరియు Transformer మోడల్స్ ను ఉపయోగిస్తున్నాయి, మరియు వారి మోడల్స్‌ను పంచుకోవడం ద్వారా సమాజానికి తిరిగి తోడ్పడతాయి: Companies using Hugging Face -The [🤗 Transformers library](https://github.com/huggingface/transformers) provides the functionality to create and use those shared models. The [Model Hub](https://huggingface.co/models) contains millions of pretrained models that anyone can download and use. You can also upload your own models to the Hub! +[🤗 Transformers లైబ్రరీ](https://github.com/huggingface/transformers) ఆ పంచుకున్న మోడల్స్‌ను సృష్టించడానికి మరియు ఉపయోగించడానికి ఫంక్షనాలిటీని అందిస్తుంది. [మోడల్ హబ్](https://huggingface.co/models) లో మిలియన్ల కొద్దీ ముందుగా శిక్షణ పొందిన మోడల్స్ ఉన్నాయి, వాటిని ఎవరైనా డౌన్‌లోడ్ చేసి ఉపయోగించవచ్చు. మీరు మీ స్వంత మోడల్స్‌ను కూడా హబ్‌కు అప్‌లోడ్ చేయవచ్చు! -⚠️ The Hugging Face Hub is not limited to Transformer models. Anyone can share any kind of models or datasets they want! Create a huggingface.co account to benefit from all available features! +⚠️ Hugging Face హబ్ కేవలం Transformer మోడల్స్ కి మాత్రమే పరిమితం కాదు. ఎవరైనా ఏ రకమైన మోడల్స్ లేదా డేటాసెట్స్‌ను అయినా పంచుకోవచ్చు! అందుబాటులో ఉన్న అన్ని ఫీచర్ల నుండి ప్రయోజనం పొందడానికి huggingface.co ఖాతాను సృష్టించుకోండి! -Before diving into how Transformer models work under the hood, let's look at a few examples of how they can be used to solve some interesting NLP problems. +Transformer మోడల్స్ తెర వెనుక ఎలా పనిచేస్తాయో లోతుగా పరిశీలించే ముందు, కొన్ని ఆసక్తికరమైన NLP సమస్యలను పరిష్కరించడానికి అవి ఎలా ఉపయోగించబడతాయో కొన్ని ఉదాహరణలు చూద్దాం. -## Working with pipelines[[working-with-pipelines]] +## పైప్‌లైన్‌లతో పని చేయడం[[working-with-pipelines]] -The most basic object in the 🤗 Transformers library is the `pipeline()` function. It connects a model with its necessary preprocessing and postprocessing steps, allowing us to directly input any text and get an intelligible answer: +🤗 Transformers లైబ్రరీలోని అత్యంత ప్రాథమిక వస్తువు `pipeline()` ఫంక్షన్. ఇది ఒక మోడల్‌ను దాని అవసరమైన ప్రిప్రాసెసింగ్ మరియు పోస్ట్ ప్రాసెసింగ్ దశలతో కలుపుతుంది, తద్వారా మనం నేరుగా ఏదైనా టెక్స్ట్‌ను ఇన్పుట్ చేసి అర్థవంతమైన సమాధానాన్ని పొందవచ్చు: ```python from transformers import pipeline @@ -48,7 +59,7 @@ classifier("I've been waiting for a HuggingFace course my whole life.") [{'label': 'POSITIVE', 'score': 0.9598047137260437}] ``` -We can even pass several sentences! +మనం అనేక వాక్యాలను కూడా పంపవచ్చు! ```python classifier( @@ -61,56 +72,56 @@ classifier( {'label': 'NEGATIVE', 'score': 0.9994558095932007}] ``` -By default, this pipeline selects a particular pretrained model that has been fine-tuned for sentiment analysis in English. The model is downloaded and cached when you create the `classifier` object. If you rerun the command, the cached model will be used instead and there is no need to download the model again. +డిఫాల్ట్‌గా, ఈ పైప్‌లైన్ ఇంగ్లీష్‌లో సెంటిమెంట్ విశ్లేషణ కోసం ఫైన్-ట్యూన్ చేయబడిన ఒక నిర్దిష్ట ప్రీ-ట్రైన్డ్ మోడల్‌ను ఎంచుకుంటుంది. మీరు `classifier` ఆబ్జెక్ట్‌ను సృష్టించినప్పుడు మోడల్ డౌన్‌లోడ్ చేయబడి కాష్ చేయబడుతుంది. మీరు ఆదేశాన్ని మళ్లీ అమలు చేస్తే, కాష్ చేయబడిన మోడల్ ఉపయోగించబడుతుంది మరియు మోడల్‌ను మళ్లీ డౌన్‌లోడ్ చేయాల్సిన అవసరం లేదు. -There are three main steps involved when you pass some text to a pipeline: +మీరు కొన్ని టెక్స్ట్‌ను పైప్‌లైన్‌కు పంపినప్పుడు మూడు ప్రధాన దశలు ఉంటాయి: -1. The text is preprocessed into a format the model can understand. -2. The preprocessed inputs are passed to the model. -3. The predictions of the model are post-processed, so you can make sense of them. +1. మోడల్ అర్థం చేసుకోగల ఫార్మాట్‌లోకి టెక్స్ట్ ప్రిప్రాసెస్ చేయబడుతుంది. +2. ప్రిప్రాసెస్ చేయబడిన ఇన్‌పుట్‌లు మోడల్‌కు పంపబడతాయి. +3. మోడల్ యొక్క అంచనాలు పోస్ట్-ప్రాసెస్ చేయబడతాయి, తద్వారా మీరు వాటిని అర్థం చేసుకోవచ్చు. -## Available pipelines for different modalities +## వివిధ మాధ్యమాల కోసం అందుబాటులో ఉన్న పైప్‌లైన్‌లు -The `pipeline()` function supports multiple modalities, allowing you to work with text, images, audio, and even multimodal tasks. In this course we'll focus on text tasks, but it's useful to understand the transformer architecture's potential, so we'll briefly outline it. +`pipeline()` ఫంక్షన్ బహుళ మాధ్యమాలను సపోర్ట్ చేస్తుంది, టెక్స్ట్, చిత్రాలు, ఆడియో మరియు మల్టీమోడల్ పనులతో కూడా పని చేయడానికి మిమ్మల్ని అనుమతిస్తుంది. ఈ కోర్సులో మనం టెక్స్ట్ పనులపై దృష్టి పెడతాము, కానీ ట్రాన్స్‌ఫార్మర్ ఆర్కిటెక్చర్ యొక్క సామర్థ్యాన్ని అర్థం చేసుకోవడం ఉపయోగకరం, కాబట్టి మనం దానిని క్లుప్తంగా వివరిస్తాము. -Here's an overview of what's available: +ఇక్కడ అందుబాటులో ఉన్న వాటి యొక్క స్థూలదృష్టి ఉంది: -For a full and updated list of pipelines, see the [🤗 Transformers documentation](https://huggingface.co/docs/hub/en/models-tasks). +పైప్‌లైన్‌ల పూర్తి మరియు నవీకరించబడిన జాబితా కోసం, [🤗 Transformers డాక్యుమెంటేషన్](https://huggingface.co/docs/hub/en/models-tasks) ను చూడండి. -### Text pipelines +### టెక్స్ట్ పైప్‌లైన్‌లు -- `text-generation`: Generate text from a prompt -- `text-classification`: Classify text into predefined categories -- `summarization`: Create a shorter version of a text while preserving key information -- `translation`: Translate text from one language to another -- `zero-shot-classification`: Classify text without prior training on specific labels -- `feature-extraction`: Extract vector representations of text +- `text-generation`: ఒక ప్రాంప్ట్ నుండి టెక్స్ట్‌ను రూపొందించడం +- `text-classification`: టెక్స్ట్‌ను ముందుగా నిర్వచించిన వర్గాలలోకి వర్గీకరించడం +- `summarization`: ముఖ్యమైన సమాచారాన్ని కాపాడుకుంటూ టెక్స్ట్ యొక్క చిన్న వెర్షన్‌ను సృష్టించడం +- `translation`: ఒక భాష నుండి మరొక భాషకు టెక్స్ట్‌ను అనువదించడం +- `zero-shot-classification`: నిర్దిష్ట లేబుల్స్‌పై ముందస్తు శిక్షణ లేకుండా టెక్స్ట్‌ను వర్గీకరించడం +- `feature-extraction`: టెక్స్ట్ యొక్క వెక్టర్ ప్రాతినిధ్యాలను సంగ్రహించడం -### Image pipelines +### చిత్ర పైప్‌లైన్‌లు -- `image-to-text`: Generate text descriptions of images -- `image-classification`: Identify objects in an image -- `object-detection`: Locate and identify objects in images +- `image-to-text`: చిత్రాల యొక్క టెక్స్ట్ వివరణలను రూపొందించడం +- `image-classification`: ఒక చిత్రంలోని వస్తువులను గుర్తించడం +- `object-detection`: చిత్రాలలో వస్తువులను గుర్తించి వాటి స్థానాన్ని కనుగొనడం -### Audio pipelines +### ఆడియో పైప్‌లైన్‌లు -- `automatic-speech-recognition`: Convert speech to text -- `audio-classification`: Classify audio into categories -- `text-to-speech`: Convert text to spoken audio +- `automatic-speech-recognition`: ప్రసంగాన్ని టెక్స్ట్‌గా మార్చడం +- `audio-classification`: ఆడియోను వర్గాలలోకి వర్గీకరించడం +- `text-to-speech`: టెక్స్ట్‌ను మాట్లాడే ఆడియోగా మార్చడం -### Multimodal pipelines +### మల్టీమోడల్ పైప్‌లైన్‌లు -- `image-text-to-text`: Respond to an image based on a text prompt +- `image-text-to-text`: ఒక టెక్స్ట్ ప్రాంప్ట్ ఆధారంగా చిత్రానికి ప్రతిస్పందించడం -Let's explore some of these pipelines in more detail! +ఈ పైప్‌లైన్‌లలో కొన్నింటిని మరింత వివరంగా అన్వేషిద్దాం! -## Zero-shot classification[[zero-shot-classification]] +## జీరో-షాట్ క్లాసిఫికేషన్[[zero-shot-classification]] -We'll start by tackling a more challenging task where we need to classify texts that haven't been labelled. This is a common scenario in real-world projects because annotating text is usually time-consuming and requires domain expertise. For this use case, the `zero-shot-classification` pipeline is very powerful: it allows you to specify which labels to use for the classification, so you don't have to rely on the labels of the pretrained model. You've already seen how the model can classify a sentence as positive or negative using those two labels — but it can also classify the text using any other set of labels you like. +లేబుల్ చేయని టెక్స్ట్‌లను వర్గీకరించాల్సిన మరింత సవాలుతో కూడిన పనితో ప్రారంభిద్దాం. ఇది వాస్తవ ప్రపంచ ప్రాజెక్టులలో ఒక సాధారణ దృశ్యం ఎందుకంటే టెక్స్ట్‌ను వ్యాఖ్యానించడం సాధారణంగా సమయం తీసుకుంటుంది మరియు డొమైన్ నైపుణ్యం అవసరం. ఈ వినియోగ సందర్భం కోసం, `zero-shot-classification` పైప్‌లైన్ చాలా శక్తివంతమైనది: ఇది వర్గీకరణ కోసం ఏ లేబుల్స్ ఉపయోగించాలో నిర్దేశించడానికి మిమ్మల్ని అనుమతిస్తుంది, కాబట్టి మీరు ముందుగా శిక్షణ పొందిన మోడల్ యొక్క లేబుల్స్‌పై ఆధారపడాల్సిన అవసరం లేదు. మోడల్ ఆ రెండు లేబుల్స్ ఉపయోగించి ఒక వాక్యాన్ని పాజిటివ్ లేదా నెగటివ్‌గా ఎలా వర్గీకరించగలదో మీరు ఇప్పటికే చూశారు — కానీ ఇది మీకు నచ్చిన ఏ ఇతర లేబుల్స్ సెట్‌ను ఉపయోగించి కూడా టెక్స్ట్‌ను వర్గీకరించగలదు. ```python from transformers import pipeline @@ -128,18 +139,17 @@ classifier( 'scores': [0.8445963859558105, 0.111976258456707, 0.043427448719739914]} ``` -This pipeline is called _zero-shot_ because you don't need to fine-tune the model on your data to use it. It can directly return probability scores for any list of labels you want! +ఈ పైప్‌లైన్‌ను _జీరో-షాట్_ అని అంటారు ఎందుకంటే దాన్ని ఉపయోగించడానికి మీరు మీ డేటాపై మోడల్‌ను ఫైన్-ట్యూన్ చేయాల్సిన అవసరం లేదు. ఇది మీకు కావలసిన లేబుల్స్ జాబితా కోసం నేరుగా సంభావ్యత స్కోర్‌లను తిరిగి ఇవ్వగలదు! -✏️ **Try it out!** Play around with your own sequences and labels and see how the model behaves. +✏️ **ప్రయత్నించి చూడండి!** మీ స్వంత సీక్వెన్సులు మరియు లేబుల్స్‌తో ఆడుకోండి మరియు మోడల్ ఎలా ప్రవర్తిస్తుందో చూడండి. +## టెక్స్ట్ జనరేషన్[[text-generation]] -## Text generation[[text-generation]] - -Now let's see how to use a pipeline to generate some text. The main idea here is that you provide a prompt and the model will auto-complete it by generating the remaining text. This is similar to the predictive text feature that is found on many phones. Text generation involves randomness, so it's normal if you don't get the same results as shown below. +ఇప్పుడు కొన్ని టెక్స్ట్‌ను రూపొందించడానికి పైప్‌లైన్‌ను ఎలా ఉపయోగించాలో చూద్దాం. ఇక్కడ ప్రధాన ఆలోచన ఏమిటంటే మీరు ఒక ప్రాంప్ట్ అందిస్తారు మరియు మోడల్ మిగిలిన టెక్స్ట్‌ను రూపొందించడం ద్వారా దానిని స్వయంచాలకంగా పూర్తి చేస్తుంది. ఇది అనేక ఫోన్‌లలో కనిపించే ప్రిడిక్టివ్ టెక్స్ట్ ఫీచర్‌కు సమానంగా ఉంటుంది. టెక్స్ట్ జనరేషన్ యాదృచ్ఛికతను కలిగి ఉంటుంది, కాబట్టి క్రింద చూపిన ఫలితాలు మీకు లభించకపోవడం సాధారణం. ```python from transformers import pipeline @@ -156,19 +166,19 @@ generator("In this course, we will teach you how to") 'HTTP'}] ``` -You can control how many different sequences are generated with the argument `num_return_sequences` and the total length of the output text with the argument `max_length`. +మీరు `num_return_sequences` ఆర్గ్యుమెంట్‌తో ఎన్ని వేర్వేరు సీక్వెన్సులను రూపొందించాలో మరియు `max_length` ఆర్గ్యుమెంట్‌తో అవుట్‌పుట్ టెక్స్ట్ యొక్క మొత్తం పొడవును నియంత్రించవచ్చు. -✏️ **Try it out!** Use the `num_return_sequences` and `max_length` arguments to generate two sentences of 15 words each. +✏️ **ప్రయత్నించి చూడండి!** `num_return_sequences` మరియు `max_length` ఆర్గ్యుమెంట్‌లను ఉపయోగించి 15 పదాల పొడవు గల రెండు వాక్యాలను రూపొందించండి. -## Using any model from the Hub in a pipeline[[using-any-model-from-the-hub-in-a-pipeline]] +## హబ్ నుండి ఏ మోడల్‌నైనా పైప్‌లైన్‌లో ఉపయోగించడం[[using-any-model-from-the-hub-in-a-pipeline]] -The previous examples used the default model for the task at hand, but you can also choose a particular model from the Hub to use in a pipeline for a specific task — say, text generation. Go to the [Model Hub](https://huggingface.co/models) and click on the corresponding tag on the left to display only the supported models for that task. You should get to a page like [this one](https://huggingface.co/models?pipeline_tag=text-generation). +మునుపటి ఉదాహరణలు పని కోసం డిఫాల్ట్ మోడల్‌ను ఉపయోగించాయి, కానీ మీరు ఒక నిర్దిష్ట పని కోసం పైప్‌లైన్‌లో ఉపయోగించడానికి హబ్ నుండి ఒక నిర్దిష్ట మోడల్‌ను కూడా ఎంచుకోవచ్చు — ఉదాహరణకు, టెక్స్ట్ జనరేషన్. [మోడల్ హబ్](https://huggingface.co/models) కు వెళ్లి, ఆ పని కోసం మద్దతు ఉన్న మోడల్స్‌ను మాత్రమే ప్రదర్శించడానికి ఎడమవైపున ఉన్న సంబంధిత ట్యాగ్‌పై క్లిక్ చేయండి. మీరు [ఈ పేజీ](https://huggingface.co/models?pipeline_tag=text-generation)のようなページにたどり着くはずです. -Let's try the [`HuggingFaceTB/SmolLM2-360M`](https://huggingface.co/HuggingFaceTB/SmolLM2-360M) model! Here's how to load it in the same pipeline as before: +[`HuggingFaceTB/SmolLM2-360M`](https://huggingface.co/HuggingFaceTB/SmolLM2-360M) మోడల్‌ను ప్రయత్నిద్దాం! మునుపటి పైప్‌లైన్‌లో దాన్ని ఎలా లోడ్ చేయాలో ఇక్కడ ఉంది: ```python from transformers import pipeline @@ -189,25 +199,25 @@ generator( 'time and real'}] ``` -You can refine your search for a model by clicking on the language tags, and pick a model that will generate text in another language. The Model Hub even contains checkpoints for multilingual models that support several languages. +మీరు భాషా ట్యాగ్‌లపై క్లిక్ చేయడం ద్వారా మోడల్ కోసం మీ శోధనను మెరుగుపరచవచ్చు మరియు మరొక భాషలో టెక్స్ట్‌ను రూపొందించే మోడల్‌ను ఎంచుకోవచ్చు. మోడల్ హబ్ అనేక భాషలకు మద్దతు ఇచ్చే బహుభాషా మోడల్స్ కోసం చెక్‌పాయింట్లను కూడా కలిగి ఉంది. -Once you select a model by clicking on it, you'll see that there is a widget enabling you to try it directly online. This way you can quickly test the model's capabilities before downloading it. +మీరు దానిపై క్లిక్ చేయడం ద్వారా ఒక మోడల్‌ను ఎంచుకున్న తర్వాత, దాన్ని నేరుగా ఆన్‌లైన్‌లో ప్రయత్నించడానికి ఒక విడ్జెట్ ఉందని మీరు చూస్తారు. ఈ విధంగా మీరు మోడల్‌ను డౌన్‌లోడ్ చేయడానికి ముందు దాని సామర్థ్యాలను త్వరగా పరీక్షించవచ్చు. -✏️ **Try it out!** Use the filters to find a text generation model for another language. Feel free to play with the widget and use it in a pipeline! +✏️ **ప్రయత్నించి చూడండి!** మరొక భాష కోసం టెక్స్ట్ జనరేషన్ మోడల్‌ను కనుగొనడానికి ఫిల్టర్‌లను ఉపయోగించండి. విడ్జెట్‌తో ఆడుకోవడానికి సంకోచించకండి మరియు దానిని పైప్‌లైన్‌లో ఉపయోగించండి! -### Inference Providers[[inference-providers]] +### ఇన్ఫరెన్స్ ప్రొవైడర్లు[[inference-providers]] -All the models can be tested directly through your browser using the Inference Providers, which is available on the Hugging Face [website](https://huggingface.co/docs/inference-providers/en/index). You can play with the model directly on this page by inputting custom text and watching the model process the input data. +అన్ని మోడల్స్‌ను Hugging Face [వెబ్‌సైట్](https://huggingface.co/docs/inference-providers/en/index) లో అందుబాటులో ఉన్న ఇన్ఫరెన్స్ ప్రొవైడర్ల ద్వారా మీ బ్రౌజర్ ద్వారా నేరుగా పరీక్షించవచ్చు. మీరు కస్టమ్ టెక్స్ట్‌ను ఇన్‌పుట్ చేసి మరియు మోడల్ ఇన్‌పుట్ డేటాను ప్రాసెస్ చేయడాన్ని చూడటం ద్వారా ఈ పేజీలో నేరుగా మోడల్‌తో ఆడవచ్చు. -Inference Providers that powers the widget is also available as a paid product, which comes in handy if you need it for your workflows. See the [pricing page](https://huggingface.co/docs/inference-providers/en/pricing) for more details. +విడ్జెట్‌ను శక్తివంతం చేసే ఇన్ఫరెన్స్ ప్రొవైడర్లు చెల్లింపు ఉత్పత్తిగా కూడా అందుబాటులో ఉన్నాయి, ఇది మీ వర్క్‌ఫ్లోల కోసం అవసరమైతే ఉపయోగపడుతుంది. మరిన్ని వివరాల కోసం [ధరల పేజీ](https://huggingface.co/docs/inference-providers/en/pricing)ని చూడండి. -## Mask filling[[mask-filling]] +## మాస్క్ ఫిల్లింగ్[[mask-filling]] -The next pipeline you'll try is `fill-mask`. The idea of this task is to fill in the blanks in a given text: +మీరు ప్రయత్నించే తదుపరి పైప్‌లైన్ `fill-mask`. ఈ పని యొక్క ఆలోచన ఇచ్చిన టెక్స్ట్‌లోని ఖాళీలను పూరించడం: ```python from transformers import pipeline @@ -227,17 +237,17 @@ unmasker("This course will teach you all about models.", top_k=2) 'token_str': ' computational'}] ``` -The `top_k` argument controls how many possibilities you want to be displayed. Note that here the model fills in the special `` word, which is often referred to as a *mask token*. Other mask-filling models might have different mask tokens, so it's always good to verify the proper mask word when exploring other models. One way to check it is by looking at the mask word used in the widget. +`top_k` ఆర్గ్యుమెంట్ మీరు ఎన్ని అవకాశాలను ప్రదర్శించాలనుకుంటున్నారో నియంత్రిస్తుంది. ఇక్కడ మోడల్ ప్రత్యేక `` పదాన్ని నింపుతుందని గమనించండి, దీనిని తరచుగా _మాస్క్ టోకెన్_ అని అంటారు. ఇతర మాస్క్-ఫిల్లింగ్ మోడల్స్ వేర్వేరు మాస్క్ టోకెన్‌లను కలిగి ఉండవచ్చు, కాబట్టి ఇతర మోడల్స్‌ను అన్వేషించేటప్పుడు సరైన మాస్క్ పదాన్ని ధృవీకరించడం ఎల్లప్పుడూ మంచిది. దానిని తనిఖీ చేయడానికి ఒక మార్గం విడ్జెట్‌లో ఉపయోగించిన మాస్క్ పదాన్ని చూడటం. -✏️ **Try it out!** Search for the `bert-base-cased` model on the Hub and identify its mask word in the Inference API widget. What does this model predict for the sentence in our `pipeline` example above? +✏️ **ప్రయత్నించి చూడండి!** హబ్‌లో `bert-base-cased` మోడల్ కోసం శోధించి మరియు ఇన్ఫరెన్స్ API విడ్జెట్‌లో దాని మాస్క్ పదాన్ని గుర్తించండి. మా `pipeline` ఉదాహరణలోని వాక్యానికి ఈ మోడల్ ఏమి అంచనా వేస్తుంది? -## Named entity recognition[[named-entity-recognition]] +## నేమ్డ్ ఎంటిటీ రికగ్నిషన్[[named-entity-recognition]] -Named entity recognition (NER) is a task where the model has to find which parts of the input text correspond to entities such as persons, locations, or organizations. Let's look at an example: +నేమ్డ్ ఎంటిటీ రికగ్నిషన్ (NER) అనేది ఒక పని, ఇక్కడ మోడల్ ఇన్‌పుట్ టెక్స్ట్‌లోని ఏ భాగాలు వ్యక్తులు, ప్రదేశాలు లేదా సంస్థల వంటి ఎంటిటీలకు సంబంధించినవో కనుగొనాలి. ఒక ఉదాహరణ చూద్దాం: ```python from transformers import pipeline @@ -247,25 +257,25 @@ ner("My name is Sylvain and I work at Hugging Face in Brooklyn.") ``` ```python out -[{'entity_group': 'PER', 'score': 0.99816, 'word': 'Sylvain', 'start': 11, 'end': 18}, - {'entity_group': 'ORG', 'score': 0.97960, 'word': 'Hugging Face', 'start': 33, 'end': 45}, +[{'entity_group': 'PER', 'score': 0.99816, 'word': 'Sylvain', 'start': 11, 'end': 18}, + {'entity_group': 'ORG', 'score': 0.97960, 'word': 'Hugging Face', 'start': 33, 'end': 45}, {'entity_group': 'LOC', 'score': 0.99321, 'word': 'Brooklyn', 'start': 49, 'end': 57} ] ``` -Here the model correctly identified that Sylvain is a person (PER), Hugging Face an organization (ORG), and Brooklyn a location (LOC). +ఇక్కడ మోడల్ సిల్వైన్ ఒక వ్యక్తి (PER), Hugging Face ఒక సంస్థ (ORG), మరియు బ్రూక్లిన్ ఒక ప్రదేశం (LOC) అని సరిగ్గా గుర్తించింది. -We pass the option `grouped_entities=True` in the pipeline creation function to tell the pipeline to regroup together the parts of the sentence that correspond to the same entity: here the model correctly grouped "Hugging" and "Face" as a single organization, even though the name consists of multiple words. In fact, as we will see in the next chapter, the preprocessing even splits some words into smaller parts. For instance, `Sylvain` is split into four pieces: `S`, `##yl`, `##va`, and `##in`. In the post-processing step, the pipeline successfully regrouped those pieces. +వాక్యంలోని ఒకే ఎంటిటీకి సంబంధించిన భాగాలను తిరిగి సమూహపరచమని పైప్‌లైన్‌కు చెప్పడానికి మేము పైప్‌లైన్ సృష్టి ఫంక్షన్‌లో `grouped_entities=True` ఎంపికను పాస్ చేస్తాము: ఇక్కడ మోడల్ "Hugging" మరియు "Face" ను ఒకే సంస్థగా సరిగ్గా సమూహపరిచింది, పేరు అనేక పదాలతో ఉన్నప్పటికీ. నిజానికి, మనం తదుపరి అధ్యాయంలో చూస్తాము, ప్రిప్రాసెసింగ్ కొన్ని పదాలను చిన్న భాగాలుగా కూడా విభజిస్తుంది. ఉదాహరణకు, `Sylvain` ను నాలుగు ముక్కలుగా విభజించారు: `S`, `##yl`, `##va`, మరియు `##in`. పోస్ట్-ప్రాసెసింగ్ దశలో, పైప్‌లైన్ ఆ ముక్కలను విజయవంతంగా తిరిగి సమూహపరిచింది. -✏️ **Try it out!** Search the Model Hub for a model able to do part-of-speech tagging (usually abbreviated as POS) in English. What does this model predict for the sentence in the example above? +✏️ **ప్రయత్నించి చూడండి!** ఇంగ్లీషులో పార్ట్-ఆఫ్-స్పీచ్ ట్యాగింగ్ (సాధారణంగా POS అని సంక్షిప్తం) చేయగల మోడల్ కోసం మోడల్ హబ్‌ను శోధించండి. పై ఉదాహరణలోని వాక్యానికి ఈ మోడల్ ఏమి అంచనా వేస్తుంది? -## Question answering[[question-answering]] +## ప్రశ్న సమాధానం[[question-answering]] -The `question-answering` pipeline answers questions using information from a given context: +`question-answering` పైప్‌లైన్ ఇచ్చిన సందర్భం నుండి సమాచారాన్ని ఉపయోగించి ప్రశ్నలకు సమాధానమిస్తుంది: ```python from transformers import pipeline @@ -281,11 +291,11 @@ question_answerer( {'score': 0.6385916471481323, 'start': 33, 'end': 45, 'answer': 'Hugging Face'} ``` -Note that this pipeline works by extracting information from the provided context; it does not generate the answer. +ఈ పైప్‌లైన్ అందించిన సందర్భం నుండి సమాచారాన్ని సంగ్రహించడం ద్వారా పనిచేస్తుందని గమనించండి; ఇది సమాధానాన్ని రూపొందించదు. -## Summarization[[summarization]] +## సారాంశీకరణ[[summarization]] -Summarization is the task of reducing a text into a shorter text while keeping all (or most) of the important aspects referenced in the text. Here's an example: +సారాంశీకరణ అనేది టెక్స్ట్‌లో ప్రస్తావించిన అన్ని (లేదా చాలా) ముఖ్యమైన అంశాలను ఉంచుతూ టెక్స్ట్‌ను చిన్న టెక్స్ట్‌గా తగ్గించడం. ఇక్కడ ఒక ఉదాహరణ ఉంది: ```python from transformers import pipeline @@ -293,23 +303,23 @@ from transformers import pipeline summarizer = pipeline("summarization") summarizer( """ - America has changed dramatically during recent years. Not only has the number of - graduates in traditional engineering disciplines such as mechanical, civil, - electrical, chemical, and aeronautical engineering declined, but in most of - the premier American universities engineering curricula now concentrate on - and encourage largely the study of engineering science. As a result, there - are declining offerings in engineering subjects dealing with infrastructure, - the environment, and related issues, and greater concentration on high - technology subjects, largely supporting increasingly complex scientific - developments. While the latter is important, it should not be at the expense + America has changed dramatically during recent years. Not only has the number of + graduates in traditional engineering disciplines such as mechanical, civil, + electrical, chemical, and aeronautical engineering declined, but in most of + the premier American universities engineering curricula now concentrate on + and encourage largely the study of engineering science. As a result, there + are declining offerings in engineering subjects dealing with infrastructure, + the environment, and related issues, and greater concentration on high + technology subjects, largely supporting increasingly complex scientific + developments. While the latter is important, it should not be at the expense of more traditional engineering. - Rapidly developing economies such as China and India, as well as other - industrial countries in Europe and Asia, continue to encourage and advance - the teaching of engineering. Both China and India, respectively, graduate - six and eight times as many traditional engineers as does the United States. - Other industrial countries at minimum maintain their output, while America - suffers an increasingly serious decline in the number of engineering graduates + Rapidly developing economies such as China and India, as well as other + industrial countries in Europe and Asia, continue to encourage and advance + the teaching of engineering. Both China and India, respectively, graduate + six and eight times as many traditional engineers as does the United States. + Other industrial countries at minimum maintain their output, while America + suffers an increasingly serious decline in the number of engineering graduates and a lack of well-educated engineers. """ ) @@ -325,12 +335,11 @@ summarizer( 'and advance engineering .'}] ``` -Like with text generation, you can specify a `max_length` or a `min_length` for the result. +టెక్స్ట్ జనరేషన్ లాగే, మీరు ఫలితం కోసం `max_length` లేదా `min_length` ను నిర్దేశించవచ్చు. +## అనువాదం[[translation]] -## Translation[[translation]] - -For translation, you can use a default model if you provide a language pair in the task name (such as `"translation_en_to_fr"`), but the easiest way is to pick the model you want to use on the [Model Hub](https://huggingface.co/models). Here we'll try translating from French to English: +అనువాదం కోసం, మీరు టాస్క్ పేరులో ఒక భాషా జతను (ఉదాహరణకు `"translation_en_to_fr"`) అందిస్తే డిఫాల్ట్ మోడల్‌ను ఉపయోగించవచ్చు, కానీ సులభమైన మార్గం మీరు [మోడల్ హబ్](https://huggingface.co/models) లో ఉపయోగించాలనుకుంటున్న మోడల్‌ను ఎంచుకోవడం. ఇక్కడ మేము ఫ్రెంచ్ నుండి ఇంగ్లీష్‌లోకి అనువదించడానికి ప్రయత్నిస్తాము: ```python from transformers import pipeline @@ -343,19 +352,19 @@ translator("Ce cours est produit par Hugging Face.") [{'translation_text': 'This course is produced by Hugging Face.'}] ``` -Like with text generation and summarization, you can specify a `max_length` or a `min_length` for the result. +టెక్స్ట్ జనరేషన్ మరియు సారాంశీకరణ లాగే, మీరు ఫలితం కోసం `max_length` లేదా `min_length` ను నిర్దేశించవచ్చు. -✏️ **Try it out!** Search for translation models in other languages and try to translate the previous sentence into a few different languages. +✏️ **ప్రయత్నించి చూడండి!** ఇతర భాషలలో అనువాద మోడల్స్ కోసం శోధించి, మునుపటి వాక్యాన్ని కొన్ని వేర్వేరు భాషలలోకి అనువదించడానికి ప్రయత్నించండి. -## Image and audio pipelines +## ఇమేజ్ మరియు ఆడియో పైప్‌లైన్‌లు -Beyond text, Transformer models can also work with images and audio. Here are a few examples: +టెక్స్ట్‌తో పాటు, Transformer మోడల్స్ ఇమేజ్‌లు మరియు ఆడియోతో కూడా పనిచేయగలవు. ఇక్కడ కొన్ని ఉదాహరణలు ఉన్నాయి: -### Image classification +### ఇమేజ్ వర్గీకరణ ```python from transformers import pipeline @@ -379,7 +388,7 @@ print(result) {'label': 'tiger cat', 'score': 0.02288915030658245}] ``` -### Automatic speech recognition +### ఆటోమేటిక్ స్పీచ్ రికగ్నిషన్ ```python from transformers import pipeline @@ -397,19 +406,20 @@ print(result) {'text': ' I have a dream that one day this nation will rise up and live out the true meaning of its creed.'} ``` -## Combining data from multiple sources +## బహుళ మూలాల నుండి డేటాను కలపడం + +Transformer మోడల్స్ యొక్క ఒక శక్తివంతమైన అప్లికేషన్ వాటికి బహుళ మూలాల నుండి డేటాను కలపడం మరియు ప్రాసెస్ చేసే సామర్థ్యం. ఇది మీకు అవసరమైనప్పుడు ప్రత్యేకంగా ఉపయోగపడుతుంది: -One powerful application of Transformer models is their ability to combine and process data from multiple sources. This is especially useful when you need to: +1. బహుళ డేటాబేస్‌లు లేదా రిపోజిటరీలలో శోధించడం +2. విభిన్న ఫార్మాట్ల నుండి సమాచారాన్ని ఏకీకృతం చేయడం (టెక్స్ట్, చిత్రాలు, ఆడియో) +3. సంబంధిత సమాచారం యొక్క ఏకీకృత వీక్షణను సృష్టించడం -1. Search across multiple databases or repositories -2. Consolidate information from different formats (text, images, audio) -3. Create a unified view of related information +ఉదాహరణకు, మీరు ఒక సిస్టమ్‌ను నిర్మించవచ్చు: -For example, you could build a system that: -- Searches for information across databases in multiple modalities like text and image. -- Combines results from different sources into a single coherent response. For example, from an audio file and text description. -- Presents the most relevant information from a database of documents and metadata. +- టెక్స్ట్ మరియు ఇమేజ్ వంటి బహుళ మాధ్యమాలలో డేటాబేస్‌లలో సమాచారం కోసం శోధించడం. +- విభిన్న మూలాల నుండి ఫలితాలను ఒకే పొందికైన ప్రతిస్పందనగా కలపడం. ఉదాహరణకు, ఒక ఆడియో ఫైల్ మరియు టెక్స్ట్ వివరణ నుండి. +- పత్రాలు మరియు మెటాడేటా యొక్క డేటాబేస్ నుండి అత్యంత సంబంధిత సమాచారాన్ని ప్రదర్శించడం. -## Conclusion +## ముగింపు -The pipelines shown in this chapter are mostly for demonstrative purposes. They were programmed for specific tasks and cannot perform variations of them. In the next chapter, you'll learn what's inside a `pipeline()` function and how to customize its behavior. +ఈ అధ్యాయంలో చూపిన పైప్‌లైన్‌లు చాలావరకు ప్రదర్శన ప్రయోజనాల కోసం. అవి నిర్దిష్ట పనుల కోసం ప్రోగ్రామ్ చేయబడ్డాయి మరియు వాటి వైవిధ్యాలను నిర్వహించలేవు. తదుపరి అధ్యాయంలో, మీరు `pipeline()` ఫంక్షన్ లోపల ఏమి ఉందో మరియు దాని ప్రవర్తనను ఎలా అనుకూలీకరించాలో నేర్చుకుంటారు. diff --git a/chapters/te/chapter1/4.mdx b/chapters/te/chapter1/4.mdx index 3870b541f..f4f12f2aa 100644 --- a/chapters/te/chapter1/4.mdx +++ b/chapters/te/chapter1/4.mdx @@ -1,191 +1,188 @@ -# How do Transformers work?[[how-do-transformers-work]] +# Transformerలు ఎలా పనిచేస్తాయి?[[how-do-transformers-work]] - + -In this section, we will take a look at the architecture of Transformer models and dive deeper into the concepts of attention, encoder-decoder architecture, and more. +ఈ విభాగంలో, మనం Transformer మోడల్స్ యొక్క ఆర్కిటెక్చర్‌ను పరిశీలిద్దాం మరియు అటెన్షన్, ఎన్‌కోడర్-డీకోడర్ ఆర్కిటెక్చర్ వంటి భావనలను లోతుగా చర్చిద్దాం. -🚀 We're taking things up a notch here. This section is detailed and technical, so don't worry if you don't understand everything right away. We'll come back to these concepts later in the course. +🚀 ఇక్కడ మనం విషయాలను మరింత లోతుగా తెలుసుకుంటున్నాం. ఈ విభాగం వివరంగా మరియు సాంకేతికంగా ఉంటుంది, కాబట్టి మీరు వెంటనే అన్నింటినీ అర్థం చేసుకోకపోయినా చింతించకండి. కోర్సులో తరువాత ఈ భావనల వద్దకు మనం తిరిగి వస్తాము. -## A bit of Transformer history[[a-bit-of-transformer-history]] +## Transformerల చరిత్ర గురించి కొంచెం[[a-bit-of-transformer-history]] -Here are some reference points in the (short) history of Transformer models: +Transformer మోడల్స్ యొక్క (సంక్షిప్త) చరిత్రలో కొన్ని ముఖ్యమైన ఘట్టాలు ఇక్కడ ఉన్నాయి:
A brief chronology of Transformers models.
-The [Transformer architecture](https://arxiv.org/abs/1706.03762) was introduced in June 2017. The focus of the original research was on translation tasks. This was followed by the introduction of several influential models, including: +[Transformer ఆర్కిటెక్చర్](https://arxiv.org/abs/1706.03762) జూన్ 2017లో పరిచయం చేయబడింది. అసలు పరిశోధన యొక్క ముఖ్య ఉద్దేశ్యం అనువాద పనులపై ఉండేది. దీని తర్వాత అనేక ప్రభావవంతమైన మోడల్స్ వచ్చాయి, వాటిలో కొన్ని: -- **June 2018**: [GPT](https://cdn.openai.com/research-covers/language-unsupervised/language_understanding_paper.pdf), the first pretrained Transformer model, used for fine-tuning on various NLP tasks and obtained state-of-the-art results +- **జూన్ 2018**: [GPT](https://cdn.openai.com/research-covers/language-unsupervised/language_understanding_paper.pdf), మొదటి ప్రీ-ట్రైన్డ్ Transformer మోడల్. ఇది వివిధ NLP పనులపై ఫైన్-ట్యూనింగ్ కోసం ఉపయోగించబడింది మరియు అత్యుత్తమ ఫలితాలను సాధించింది. -- **October 2018**: [BERT](https://arxiv.org/abs/1810.04805), another large pretrained model, this one designed to produce better summaries of sentences (more on this in the next chapter!) +- **అక్టోబర్ 2018**: [BERT](https://arxiv.org/abs/1810.04805), మరొక పెద్ద ప్రీ-ట్రైన్డ్ మోడల్. ఇది వాక్యాల యొక్క మెరుగైన సారాంశాలను ఉత్పత్తి చేయడానికి రూపొందించబడింది (దీని గురించి తదుపరి అధ్యాయంలో మరింత!) -- **February 2019**: [GPT-2](https://cdn.openai.com/better-language-models/language_models_are_unsupervised_multitask_learners.pdf), an improved (and bigger) version of GPT that was not immediately publicly released due to ethical concerns +- **ఫిబ్రవరి 2019**: [GPT-2](https://cdn.openai.com/better-language-models/language_models_are_unsupervised_multitask_learners.pdf), GPT యొక్క మెరుగైన (మరియు పెద్ద) వెర్షన్, ఇది నైతిక ఆందోళనల కారణంగా వెంటనే బహిరంగంగా విడుదల కాలేదు. -- **October 2019**: [T5](https://huggingface.co/papers/1910.10683), A multi-task focused implementation of the sequence-to-sequence Transformer architecture. +- **అక్టోబర్ 2019**: [T5](https://huggingface.co/papers/1910.10683), సీక్వెన్స్-టు-సీక్వెన్స్ Transformer ఆర్కిటెక్చర్ యొక్క బహుళ-పని ఆధారిత అమలు. -- **May 2020**, [GPT-3](https://huggingface.co/papers/2005.14165), an even bigger version of GPT-2 that is able to perform well on a variety of tasks without the need for fine-tuning (called _zero-shot learning_) +- **మే 2020**, [GPT-3](https://huggingface.co/papers/2005.14165), GPT-2 యొక్క మరింత పెద్ద వెర్షన్. ఇది ఫైన్-ట్యూనింగ్ అవసరం లేకుండా వివిధ పనులపై బాగా పనిచేయగలదు (_zero-shot learning_ అని పిలుస్తారు). -- **January 2022**: [InstructGPT](https://huggingface.co/papers/2203.02155), a version of GPT-3 that was trained to follow instructions better -This list is far from comprehensive, and is just meant to highlight a few of the different kinds of Transformer models. Broadly, they can be grouped into three categories: +- **జనవరి 2022**: [InstructGPT](https://huggingface.co/papers/2203.02155), సూచనలను మరింత మెరుగ్గా పాటించడానికి శిక్షణ పొందిన GPT-3 యొక్క వెర్షన్. -- **January 2023**: [Llama](https://huggingface.co/papers/2302.13971), a large language model that is able to generate text in a variety of languages. +- **జనవరి 2023**: [Llama](https://huggingface.co/papers/2302.13971), వివిధ భాషలలో టెక్స్ట్‌ను ఉత్పత్తి చేయగల ఒక పెద్ద భాషా నమూనా. -- **March 2023**: [Mistral](https://huggingface.co/papers/2310.06825), a 7-billion-parameter language model that outperforms Llama 2 13B across all evaluated benchmarks, leveraging grouped-query attention for faster inference and sliding window attention to handle sequences of arbitrary length. +- **మార్చి 2023**: [Mistral](https://huggingface.co/papers/2310.06825), 7-బిలియన్-పారామీటర్ల భాషా నమూనా, ఇది అన్ని మూల్యాంకన బెంచ్‌మార్క్‌లలో Llama 2 13B ను అధిగమించింది. వేగవంతమైన ఇన్ఫరెన్స్ కోసం గ్రూప్డ్-క్వరీ అటెన్షన్ మరియు ఏకపక్ష పొడవు గల సీక్వెన్సులను నిర్వహించడానికి స్లైడింగ్ విండో అటెన్షన్‌ను ఉపయోగిస్తుంది. -- **May 2024**: [Gemma 2](https://huggingface.co/papers/2408.00118), a family of lightweight, state-of-the-art open models ranging from 2B to 27B parameters that incorporate interleaved local-global attentions and group-query attention, with smaller models trained using knowledge distillation to deliver performance competitive with models 2-3 times larger. +- **మే 2024**: [Gemma 2](https://huggingface.co/papers/2408.00118), 2B నుండి 27B పారామీటర్ల వరకు ఉండే తేలికపాటి, అత్యాధునిక ఓపెన్ మోడల్స్ యొక్క కుటుంబం. ఇవి ఇంటర్లీవ్డ్ లోకల్-గ్లోబల్ అటెన్షన్స్ మరియు గ్రూప్-క్వరీ అటెన్షన్‌ను కలిగి ఉంటాయి, మరియు 2-3 రెట్లు పెద్ద మోడల్స్‌తో పోటీపడే పనితీరును అందించడానికి నాలెడ్జ్ డిస్టిలేషన్ ఉపయోగించి చిన్న మోడల్స్‌కు శిక్షణ ఇవ్వబడింది. -- **November 2024**: [SmolLM2](https://huggingface.co/papers/2502.02737), a state-of-the-art small language model (135 million to 1.7 billion parameters) that achieves impressive performance despite its compact size, and unlocking new possibilities for mobile and edge devices. +- **నవంబర్ 2024**: [SmolLM2](https://huggingface.co/papers/2502.02737), అత్యాధునిక చిన్న భాషా నమూనా (135 మిలియన్ల నుండి 1.7 బిలియన్ల పారామీటర్లు), ఇది దాని కాంపాక్ట్ సైజు ఉన్నప్పటికీ ఆకట్టుకునే పనితీరును సాధిస్తుంది మరియు మొబైల్ మరియు ఎడ్జ్ పరికరాల కోసం కొత్త అవకాశాలను అన్‌లాక్ చేస్తుంది. -- GPT-like (also called _auto-regressive_ Transformer models) -- BERT-like (also called _auto-encoding_ Transformer models) -- T5-like (also called _sequence-to-sequence_ Transformer models) +ఈ జాబితా పూర్తి కాదు మరియు ఇది కేవలం కొన్ని రకాల Transformer నమూనాలను హైలైట్ చేయడానికి మాత్రమే ఉద్దేశించబడింది. విస్తృతంగా, వీటిని మూడు వర్గాలుగా విభజించవచ్చు: -We will dive into these families in more depth later on. +- GPT-లాంటి (వీటిని _auto-regressive_ Transformer మోడల్స్ అని కూడా అంటారు) +- BERT-లాంటి (వీటిని _auto-encoding_ Transformer మోడల్స్ అని కూడా అంటారు) +- T5-లాంటి (వీటిని _sequence-to-sequence_ Transformer మోడల్స్ అని కూడా అంటారు) -## Transformers are language models[[transformers-are-language-models]] +మనం ఈ కుటుంబాల గురించి తరువాత మరింత లోతుగా చర్చిస్తాము. -All the Transformer models mentioned above (GPT, BERT, T5, etc.) have been trained as *language models*. This means they have been trained on large amounts of raw text in a self-supervised fashion. +## Transformer లు భాషా నమూనాలు[[transformers-are-language-models]] -Self-supervised learning is a type of training in which the objective is automatically computed from the inputs of the model. That means that humans are not needed to label the data! +పైన పేర్కొన్న అన్ని Transformer మోడల్స్ (GPT, BERT, T5, మొదలైనవి) _భాషా నమూనాలుగా_ శిక్షణ పొందాయి. అంటే అవి స్వీయ-పర్యవేక్షిత పద్ధతిలో భారీ మొత్తంలో ముడి టెక్స్ట్‌పై శిక్షణ పొందాయి. -This type of model develops a statistical understanding of the language it has been trained on, but it's less useful for specific practical tasks. Because of this, the general pretrained model then goes through a process called *transfer learning* or *fine-tuning*. During this process, the model is fine-tuned in a supervised way -- that is, using human-annotated labels -- on a given task. +స్వీయ-పర్యవేక్షిత అభ్యాసం (Self-supervised learning) అనేది ఒక రకమైన శిక్షణ, దీనిలో మోడల్ యొక్క ఇన్‌పుట్‌ల నుండి లక్ష్యం స్వయంచాలకంగా లెక్కించబడుతుంది. అంటే డేటాను లేబుల్ చేయడానికి మానవులు అవసరం లేదు! -An example of a task is predicting the next word in a sentence having read the *n* previous words. This is called *causal language modeling* because the output depends on the past and present inputs, but not the future ones. +ఈ రకమైన మోడల్, శిక్షణ పొందిన భాషపై గణాంక అవగాహనను పెంచుకుంటుంది, కానీ ఇది నిర్దిష్ట ఆచరణాత్మక పనులకు అంతగా ఉపయోగపడదు. ఈ కారణంగా, సాధారణ ప్రీ-ట్రైన్డ్ మోడల్ తరువాత _ట్రాన్స్‌ఫర్ లెర్నింగ్_ లేదా _ఫైన్-ట్యూనింగ్_ అనే ప్రక్రియ ద్వారా వెళుతుంది. ఈ ప్రక్రియలో, మోడల్ ఒక నిర్దిష్ట పనిపై పర్యవేక్షిత పద్ధతిలో — అంటే, మానవ-అన్నొటేటెడ్ లేబుల్స్ ఉపయోగించి — ఫైన్-ట్యూన్ చేయబడుతుంది. + +ఒక పనికి ఉదాహరణ, ఒక వాక్యం లోని _n_ మునుపటి పదాలను చదివిన తరువాత తదుపరి పదాన్ని అంచనా వేయడం. దీనిని _కాజువల్ లాంగ్వేజ్ మోడలింగ్_ అని అంటారు, ఎందుకంటే అవుట్‌పుట్ గతం మరియు ప్రస్తుత ఇన్‌పుట్‌లపై ఆధారపడి ఉంటుంది, కానీ భవిష్యత్తు వాటిపై కాదు.
Example of causal language modeling in which the next word from a sentence is predicted.
-Another example is *masked language modeling*, in which the model predicts a masked word in the sentence. +మరొక ఉదాహరణ _Masked language modelling_, దీనిలో మోడల్ వాక్యంలోని మాస్క్ చేయబడిన పదాన్ని అంచనా వేస్తుంది.
Example of masked language modeling in which a masked word from a sentence is predicted.
-## Transformers are big models[[transformers-are-big-models]] +## Transformerలు పెద్ద నమూనాలు[[transformers-are-big-models]] -Apart from a few outliers (like DistilBERT), the general strategy to achieve better performance is by increasing the models' sizes as well as the amount of data they are pretrained on. +కొన్ని మినహాయింపులు (DistilBERT వంటివి) తప్ప, మెరుగైన పనితీరును సాధించడానికి సాధారణ వ్యూహం, మోడల్స్ యొక్క పరిమాణాలను అలాగే అవి ప్రీ-ట్రైనింగ్ చేయబడిన డేటా మొత్తాన్ని పెంచడం.
Number of parameters of recent Transformers models
-Unfortunately, training a model, especially a large one, requires a large amount of data. This becomes very costly in terms of time and compute resources. It even translates to environmental impact, as can be seen in the following graph. +దురదృష్టవశాత్తు, ఒక మోడల్‌ను, ముఖ్యంగా పెద్ద మోడల్‌ను శిక్షణ ఇవ్వడానికి, పెద్ద మొత్తంలో డేటా అవసరం. సమయం మరియు గణన వనరుల పరంగా ఇది చాలా ఖర్చుతో కూడుకున్నది. ఇది పర్యావరణ ప్రభావానికి కూడా దారితీస్తుంది, కింది గ్రాఫ్‌లో చూడవచ్చు.
The carbon footprint of a large language model.
- - -And this is showing a project for a (very big) model led by a team consciously trying to reduce the environmental impact of pretraining. The footprint of running lots of trials to get the best hyperparameters would be even higher. + -Imagine if each time a research team, a student organization, or a company wanted to train a model, it did so from scratch. This would lead to huge, unnecessary global costs! +మరియు ఇది ప్రీ-ట్రైనింగ్ యొక్క పర్యావరణ ప్రభావాన్ని తగ్గించడానికి స్పృహతో ప్రయత్నిస్తున్న ఒక బృందం నేతృత్వంలోని ఒక (చాలా పెద్ద) మోడల్ కోసం ఒక ప్రాజెక్ట్‌ను చూపుతోంది. ఉత్తమ హైపర్‌పారామీటర్‌లను పొందడానికి చాలా ట్రయల్స్ నడపడం యొక్క ఫుట్‌ప్రింట్ ఇంకా ఎక్కువగా ఉంటుంది. -This is why sharing language models is paramount: sharing the trained weights and building on top of already trained weights reduces the overall compute cost and carbon footprint of the community. +ఒక పరిశోధన బృందం, ఒక విద్యార్థి సంస్థ, లేదా ఒక సంస్థ ప్రతిసారీ ఒక మోడల్‌ను శిక్షణ ఇవ్వాలనుకుంటే, అది మొదటి నుండి అలా చేస్తే ఎలా ఉంటుందో ఊహించండి. ఇది భారీ, అనవసరమైన ప్రపంచ వ్యయాలకు దారితీస్తుంది! -By the way, you can evaluate the carbon footprint of your models' training through several tools. For example [ML CO2 Impact](https://mlco2.github.io/impact/) or [Code Carbon]( https://codecarbon.io/) which is integrated in 🤗 Transformers. To learn more about this, you can read this [blog post](https://huggingface.co/blog/carbon-emissions-on-the-hub) which will show you how to generate an `emissions.csv` file with an estimate of the footprint of your training, as well as the [documentation](https://huggingface.co/docs/hub/model-cards-co2) of 🤗 Transformers addressing this topic. +అందుకే భాషా నమూనాలను పంచుకోవడం చాలా ముఖ్యం: శిక్షణ పొందిన వెయిట్స్ పంచుకోవడం మరియు ఇప్పటికే శిక్షణ పొందిన వెయిట్స్ పైన నిర్మించడం ద్వారా కమ్యూనిటీ యొక్క మొత్తం గణన వ్యయాన్ని మరియు కార్బన్ ఫుట్‌ప్రింట్‌ను తగ్గిస్తుంది. +అలాగే, మీరు మీ మోడల్స్ శిక్షణ యొక్క కార్బన్ ఫుట్‌ప్రింట్‌ను అనేక సాధనాల ద్వారా మూల్యాంకనం చేయవచ్చు. ఉదాహరణకు [ML CO2 Impact](https://mlco2.github.io/impact/) లేదా [Code Carbon](https://codecarbon.io/) ఇది 🤗 Transformers లో విలీనం చేయబడింది. దీని గురించి మరింత తెలుసుకోవడానికి, మీరు ఈ [బ్లాగ్ పోస్ట్](https://huggingface.co/blog/carbon-emissions-on-the-hub) చదవచ్చు, ఇది మీ శిక్షణ యొక్క ఫుట్‌ప్రింట్ యొక్క అంచనాతో `emissions.csv` ఫైల్‌ను ఎలా రూపొందించాలో చూపుతుంది, అలాగే ఈ అంశాన్ని పరిష్కరించే 🤗 Transformers యొక్క [డాక్యుమెంటేషన్](https://huggingface.co/docs/hub/model-cards-co2) కూడా చూడవచ్చు. -## Transfer Learning[[transfer-learning]] +## ట్రాన్స్‌ఫర్ లెర్నింగ్[[transfer-learning]] -*Pretraining* is the act of training a model from scratch: the weights are randomly initialized, and the training starts without any prior knowledge. +_Pretraining_ అంటే ఒక మోడల్‌ను మొదటి నుండి శిక్షణ ఇవ్వడం: వెయిట్స్ యాదృచ్ఛికంగా ప్రారంభించబడతాయి మరియు శిక్షణ ఎటువంటి ముందస్తు జ్ఞానం లేకుండా మొదలవుతుంది.
The pretraining of a language model is costly in both time and money.
-This pretraining is usually done on very large amounts of data. Therefore, it requires a very large corpus of data, and training can take up to several weeks. +ఈ ప్రీ-ట్రైనింగ్ సాధారణంగా చాలా పెద్ద మొత్తంలో డేటాపై జరుగుతుంది. అందువల్ల, దీనికి చాలా పెద్ద డేటా కార్పస్ అవసరం, మరియు శిక్షణ పూర్తి కావడానికి చాలా వారాలు పట్టవచ్చు. -*Fine-tuning*, on the other hand, is the training done **after** a model has been pretrained. To perform fine-tuning, you first acquire a pretrained language model, then perform additional training with a dataset specific to your task. Wait -- why not simply train the model for your final use case from the start (**scratch**)? There are a couple of reasons: +_Fine-tuning_ అనేది, ఒక మోడల్ ప్రీ-ట్రైనింగ్ చేయబడిన **తరువాత** జరిగే శిక్షణ. ఫైన్-ట్యూనింగ్ చేయడానికి, మీరు మొదట ఒక ప్రీ-ట్రైన్డ్ భాషా నమూనాను పొందుతారు, ఆపై మీ పనికి సంబంధించిన నిర్దిష్ట డేటాసెట్‌తో అదనపు శిక్షణ ఇస్తారు. ఒక్క నిమిషం -- మీ తుది వినియోగం కోసం మోడల్‌ను మొదటి నుండి (**scratch**) ఎందుకు శిక్షణ ఇవ్వకూడదు? దీనికి కొన్ని కారణాలు ఉన్నాయి: -* The pretrained model was already trained on a dataset that has some similarities with the fine-tuning dataset. The fine-tuning process is thus able to take advantage of knowledge acquired by the initial model during pretraining (for instance, with NLP problems, the pretrained model will have some kind of statistical understanding of the language you are using for your task). -* Since the pretrained model was already trained on lots of data, the fine-tuning requires way less data to get decent results. -* For the same reason, the amount of time and resources needed to get good results are much lower. +- ప్రీ-ట్రైన్డ్ మోడల్ ఇప్పటికే ఫైన్-ట్యూనింగ్ డేటాసెట్‌తో కొన్ని సారూప్యతలను కలిగి ఉన్న డేటాసెట్‌పై శిక్షణ పొందింది. అందువల్ల ఫైన్-ట్యూనింగ్ ప్రక్రియ ప్రీ-ట్రైనింగ్ సమయంలో ప్రారంభ మోడల్ పొందిన జ్ఞానాన్ని ఉపయోగించుకోగలదు (ఉదాహరణకు, NLP సమస్యలతో, ప్రీ-ట్రైన్డ్ మోడల్ మీ పని కోసం మీరు ఉపయోగిస్తున్న భాషపై ఒకరకమైన గణాంక అవగాహనను కలిగి ఉంటుంది). +- ప్రీ-ట్రైన్డ్ మోడల్ ఇప్పటికే చాలా డేటాపై శిక్షణ పొందింది కాబట్టి, ఫైన్-ట్యూనింగ్‌కు మంచి ఫలితాలను పొందడానికి చాలా తక్కువ డేటా అవసరం. +- అదే కారణంతో, మంచి ఫలితాలను పొందడానికి అవసరమైన సమయం మరియు వనరులు చాలా తక్కువ. -For example, one could leverage a pretrained model trained on the English language and then fine-tune it on an arXiv corpus, resulting in a science/research-based model. The fine-tuning will only require a limited amount of data: the knowledge the pretrained model has acquired is "transferred," hence the term *transfer learning*. +ఉదాహరణకు, ఇంగ్లీష్ భాషపై శిక్షణ పొందిన ఒక ప్రీ-ట్రైన్డ్ మోడల్‌ను ఉపయోగించి, ఆ తర్వాత దాన్ని ఒక arXiv కార్పస్‌పై ఫైన్-ట్యూన్ చేయడం ద్వారా ఒక సైన్స్/పరిశోధన ఆధారిత మోడల్‌ను పొందవచ్చు. ఫైన్-ట్యూనింగ్‌కు పరిమిత మొత్తంలో డేటా మాత్రమే అవసరం: ప్రీ-ట్రైన్డ్ మోడల్ పొందిన జ్ఞానం "బదిలీ" చేయబడుతుంది, అందుకే _ట్రాన్స్‌ఫర్ లెర్నింగ్_ అనే పదం వచ్చింది.
The fine-tuning of a language model is cheaper than pretraining in both time and money.
-Fine-tuning a model therefore has lower time, data, financial, and environmental costs. It is also quicker and easier to iterate over different fine-tuning schemes, as the training is less constraining than a full pretraining. +అందువల్ల, ఒక మోడల్‌ను ఫైన్-ట్యూన్ చేయడం తక్కువ సమయం, డేటా, ఆర్థిక, మరియు పర్యావరణ వ్యయాలను కలిగి ఉంటుంది. పూర్తి ప్రీ-ట్రైనింగ్ కంటే శిక్షణ తక్కువ నిర్బంధంగా ఉన్నందున, వివిధ ఫైన్-ట్యూనింగ్ స్కీమ్‌లను పునరావృతం చేయడం కూడా వేగంగా మరియు సులభంగా ఉంటుంది. -This process will also achieve better results than training from scratch (unless you have lots of data), which is why you should always try to leverage a pretrained model -- one as close as possible to the task you have at hand -- and fine-tune it. +ఈ ప్రక్రియ సున్నా నుండి శిక్షణ ఇవ్వడం కంటే మెరుగైన ఫలితాలను సాధిస్తుంది (మీరు చాలా డేటాను కలిగి ఉంటే తప్ప), అందుకే మీరు ఎల్లప్పుడూ ఒక ప్రీ-ట్రైన్డ్ మోడల్‌ను ఉపయోగించుకోవడానికి ప్రయత్నించాలి -- మీ చేతిలో ఉన్న పనికి వీలైనంత దగ్గరగా ఉన్న దాన్ని — మరియు దానిని ఫైన్-ట్యూన్ చేయాలి. -## General Transformer architecture[[general-transformer-architecture]] +## సాధారణ Transformer ఆర్కిటెక్చర్[[general-transformer-architecture]] -In this section, we'll go over the general architecture of the Transformer model. Don't worry if you don't understand some of the concepts; there are detailed sections later covering each of the components. +ఈ విభాగంలో, మనం Transformer మోడల్ యొక్క సాధారణ ఆర్కిటెక్చర్‌ను పరిశీలిద్దాం. మీకు కొన్ని భావనలు అర్థం కాకపోయినా చింతించకండి; ప్రతి భాగాన్ని కవర్ చేసే వివరణాత్మక విభాగాలు తరువాత ఉన్నాయి. -The model is primarily composed of two blocks: +ఈ మోడల్ ప్రధానంగా రెండు బ్లాక్‌లతో కూడి ఉంటుంది: -* **Encoder (left)**: The encoder receives an input and builds a representation of it (its features). This means that the model is optimized to acquire understanding from the input. -* **Decoder (right)**: The decoder uses the encoder's representation (features) along with other inputs to generate a target sequence. This means that the model is optimized for generating outputs. +- **ఎన్‌కోడర్ (ఎడమవైపు)**: ఎన్‌కోడర్ ఒక ఇన్‌పుట్‌ను స్వీకరించి దాని యొక్క ప్రాతినిధ్యాన్ని (దాని ఫీచర్స్) నిర్మిస్తుంది. అంటే ఈ మోడల్ ఇన్‌పుట్ నుండి అవగాహనను పొందడానికి ఆప్టిమైజ్ చేయబడింది. +- **డీకోడర్ (కుడివైపు)**: డీకోడర్, ఎన్‌కోడర్ యొక్క ప్రాతినిధ్యాన్ని (ఫీచర్స్) మరియు ఇతర ఇన్‌పుట్‌లను ఉపయోగించి ఒక లక్ష్య సీక్వెన్స్‌ను ఉత్పత్తి చేస్తుంది. అంటే ఈ మోడల్ అవుట్‌పుట్‌లను ఉత్పత్తి చేయడానికి ఆప్టిమైజ్ చేయబడింది.
Architecture of a Transformers models
-Each of these parts can be used independently, depending on the task: +ఈ భాగాలలో ప్రతి ఒక్కటి పనిని బట్టి స్వతంత్రంగా ఉపయోగించవచ్చు: -* **Encoder-only models**: Good for tasks that require understanding of the input, such as sentence classification and named entity recognition. -* **Decoder-only models**: Good for generative tasks such as text generation. -* **Encoder-decoder models** or **sequence-to-sequence models**: Good for generative tasks that require an input, such as translation or summarization. +- **ఎన్‌కోడర్-మాత్రమే మోడల్స్**: వాక్య వర్గీకరణ మరియు పేరుగల ఎంటిటీ గుర్తింపు వంటి ఇన్‌పుట్ అవగాహన అవసరమయ్యే పనులకు మంచివి. +- **డీకోడర్-మాత్రమే మోడల్స్**: టెక్స్ట్ జనరేషన్ వంటి ఉత్పాదక పనులకు మంచివి. +- **ఎన్‌కోడర్-డీకోడర్ మోడల్స్** లేదా **సీక్వెన్స్-టు-సీక్వెన్స్ మోడల్స్**: అనువాదం లేదా సారాంశీకరణ వంటి ఇన్‌పుట్ అవసరమయ్యే ఉత్పాదక పనులకు మంచివి. -We will dive into those architectures independently in later sections. +మనం ఈ ఆర్కిటెక్చర్లను తరువాత విభాగాలలో స్వతంత్రంగా పరిశీలిస్తాము. -## Attention layers[[attention-layers]] +## అటెన్షన్ లేయర్లు[[attention-layers]] -A key feature of Transformer models is that they are built with special layers called *attention layers*. In fact, the title of the paper introducing the Transformer architecture was ["Attention Is All You Need"](https://arxiv.org/abs/1706.03762)! We will explore the details of attention layers later in the course; for now, all you need to know is that this layer will tell the model to pay specific attention to certain words in the sentence you passed it (and more or less ignore the others) when dealing with the representation of each word. +Transformer మోడల్స్ యొక్క ఒక ముఖ్య లక్షణం ఏమిటంటే, అవి _అటెన్షన్ లేయర్లు_ అనే ప్రత్యేక లేయర్లతో నిర్మించబడ్డాయి. నిజానికి, Transformer ఆర్కిటెక్చర్‌ను పరిచయం చేసిన పేపర్ శీర్షిక ["Attention Is All You Need"](https://arxiv.org/abs/1706.03762)! మనం కోర్సులో తరువాత అటెన్షన్ లేయర్ల వివరాలను అన్వేషిస్తాము; ప్రస్తుతానికి, మీరు తెలుసుకోవలసినది ఏమిటంటే, ఈ లేయర్, మీరు పంపిన వాక్యంలోని ప్రతి పదం యొక్క ప్రాతినిధ్యంతో వ్యవహరించేటప్పుడు, ఆ వాక్యంలోని కొన్ని నిర్దిష్ట పదాలపై ప్రత్యేక శ్రద్ధ పెట్టమని మోడల్‌కు చెబుతుంది (మరియు ఇతరులను ఎక్కువ లేదా తక్కువ విస్మరించమని). -To put this into context, consider the task of translating text from English to French. Given the input "You like this course", a translation model will need to also attend to the adjacent word "You" to get the proper translation for the word "like", because in French the verb "like" is conjugated differently depending on the subject. The rest of the sentence, however, is not useful for the translation of that word. In the same vein, when translating "this" the model will also need to pay attention to the word "course", because "this" translates differently depending on whether the associated noun is masculine or feminine. Again, the other words in the sentence will not matter for the translation of "course". With more complex sentences (and more complex grammar rules), the model would need to pay special attention to words that might appear farther away in the sentence to properly translate each word. +దీనిని సందర్భంలో ఉంచాలంటే, ఇంగ్లీష్ నుండి ఫ్రెంచ్‌కు టెక్స్ట్‌ను అనువదించే పనిని పరిగణించండి. "You like this course" అనే ఇన్‌పుట్ ఇచ్చినప్పుడు, ఒక అనువాద మోడల్ "like" అనే పదం యొక్క సరైన అనువాదాన్ని పొందడానికి ప్రక్కనే ఉన్న "You" అనే పదంపై కూడా శ్రద్ధ పెట్టాలి, ఎందుకంటే ఫ్రెంచ్‌లో "like" అనే క్రియ సబ్జెక్ట్‌ను బట్టి విభిన్నంగా సంయోగం చేయబడుతుంది. అయితే, వాక్యంలోని మిగిలిన భాగం ఆ పదం యొక్క అనువాదానికి ఉపయోగపడదు. అదే విధంగా, "this" ను అనువదించేటప్పుడు మోడల్ "course" అనే పదంపై కూడా శ్రద్ధ పెట్టాలి, ఎందుకంటే దానికి సంబంధించిన నామవాచకం పుంలింగమా లేదా స్త్రీలింగమా అనే దానిపై ఆధారపడి "this" విభిన్నంగా అనువదించబడుతుంది. మళ్లీ, వాక్యంలోని ఇతర పదాలు "course" యొక్క అనువాదానికి పట్టింపు లేదు. మరింత సంక్లిష్టమైన వాక్యాలతో (మరియు మరింత సంక్లిష్టమైన వ్యాకరణ నియమాలతో), ప్రతి పదాన్ని సరిగ్గా అనువదించడానికి మోడల్ వాక్యంలో ఇంకా దూరంగా కనిపించే పదాలపై ప్రత్యేక శ్రద్ధ పెట్టాల్సి ఉంటుంది. -The same concept applies to any task associated with natural language: a word by itself has a meaning, but that meaning is deeply affected by the context, which can be any other word (or words) before or after the word being studied. +సహజ భాషతో సంబంధం ఉన్న ఏ పనికైనా ఇదే భావన వర్తిస్తుంది: ఒక పదానికి దానంతట అదే ఒక అర్థం ఉంటుంది, కానీ ఆ అర్థం సందర్భం ద్వారా తీవ్రంగా ప్రభావితమవుతుంది, ఇది అధ్యయనం చేయబడుతున్న పదం ముందు లేదా తరువాత ఉన్న ఏ ఇతర పదం (లేదా పదాలు) అయినా కావచ్చు. -Now that you have an idea of what attention layers are all about, let's take a closer look at the Transformer architecture. +ఇప్పుడు మీకు అటెన్షన్ లేయర్ల గురించి ఒక ఆలోచన వచ్చింది కాబట్టి, Transformer ఆర్కిటెక్చర్‌ను మరింత నిశితంగా పరిశీలిద్దాం. -## The original architecture[[the-original-architecture]] +## అసలు ఆర్కిటెక్చర్[[the-original-architecture]] -The Transformer architecture was originally designed for translation. During training, the encoder receives inputs (sentences) in a certain language, while the decoder receives the same sentences in the desired target language. In the encoder, the attention layers can use all the words in a sentence (since, as we just saw, the translation of a given word can be dependent on what is after as well as before it in the sentence). The decoder, however, works sequentially and can only pay attention to the words in the sentence that it has already translated (so, only the words before the word currently being generated). For example, when we have predicted the first three words of the translated target, we give them to the decoder which then uses all the inputs of the encoder to try to predict the fourth word. +Transformer ఆర్కిటెక్చర్ వాస్తవానికి అనువాదం కోసం రూపొందించబడింది. శిక్షణ సమయంలో, ఎన్‌కోడర్ ఒక నిర్దిష్ట భాషలో ఇన్‌పుట్‌లను (వాక్యాలను) స్వీకరిస్తుంది, అయితే డీకోడర్ అవే వాక్యాలను కావలసిన లక్ష్య భాషలో స్వీకరిస్తుంది. ఎన్‌కోడర్‌లో, అటెన్షన్ లేయర్లు ఒక వాక్యంలోని అన్ని పదాలను ఉపయోగించగలవు (ఎందుకంటే, మనం ఇప్పుడు చూసినట్లుగా, ఒక నిర్దిష్ట పదం యొక్క అనువాదం వాక్యంలోని దాని తరువాత మరియు ముందు ఉన్న వాటిపై ఆధారపడి ఉండవచ్చు). అయితే, డీకోడర్ వరుసగా పనిచేస్తుంది మరియు అది ఇప్పటికే అనువదించిన వాక్యంలోని పదాలపై మాత్రమే శ్రద్ధ పెట్టగలదు (అందుకే, ప్రస్తుతం ఉత్పత్తి చేయబడుతున్న పదం ముందు ఉన్న పదాలు మాత్రమే). ఉదాహరణకు, మనం అనువదించబడిన లక్ష్యం యొక్క మొదటి మూడు పదాలను అంచనా వేసినప్పుడు, వాటిని డీకోడర్‌కు ఇస్తాము, అది తరువాత నాల్గవ పదాన్ని అంచనా వేయడానికి ఎన్‌కోడర్ యొక్క అన్ని ఇన్‌పుట్‌లను ఉపయోగిస్తుంది. -To speed things up during training (when the model has access to target sentences), the decoder is fed the whole target, but it is not allowed to use future words (if it had access to the word at position 2 when trying to predict the word at position 2, the problem would not be very hard!). For instance, when trying to predict the fourth word, the attention layer will only have access to the words in positions 1 to 3. +శిక్షణ సమయంలో వేగాన్ని పెంచడానికి (మోడల్‌కు లక్ష్య వాక్యాలకు యాక్సెస్ ఉన్నప్పుడు), డీకోడర్‌కు మొత్తం లక్ష్యం ఇవ్వబడుతుంది, కానీ భవిష్యత్తు పదాలను ఉపయోగించడానికి అనుమతించబడదు (స్థానం 2 వద్ద పదాన్ని అంచనా వేయడానికి ప్రయత్నిస్తున్నప్పుడు స్థానం 2 వద్ద పదానికి యాక్సెస్ ఉంటే, సమస్య చాలా కష్టంగా ఉండదు!). ఉదాహరణకు, నాల్గవ పదాన్ని అంచనా వేయడానికి ప్రయత్నిస్తున్నప్పుడు, అటెన్షన్ లేయర్ కేవలం 1 నుండి 3 వరకు ఉన్న స్థానాలలోని పదాలకు మాత్రమే యాక్సెస్ కలిగి ఉంటుంది. -The original Transformer architecture looked like this, with the encoder on the left and the decoder on the right: +అసలు Transformer ఆర్కిటెక్చర్ ఇలా ఉండేది, ఎడమవైపు ఎన్‌కోడర్ మరియు కుడివైపు డీకోడర్‌తో:
Architecture of a Transformers models
-Note that the first attention layer in a decoder block pays attention to all (past) inputs to the decoder, but the second attention layer uses the output of the encoder. It can thus access the whole input sentence to best predict the current word. This is very useful as different languages can have grammatical rules that put the words in different orders, or some context provided later in the sentence may be helpful to determine the best translation of a given word. +డీకోడర్ బ్లాక్‌లోని మొదటి అటెన్షన్ లేయర్ డీకోడర్‌కు అన్ని (గత) ఇన్‌పుట్‌లపై శ్రద్ధ చూపుతుంది, కానీ రెండవ అటెన్షన్ లేయర్ ఎన్‌కోడర్ యొక్క అవుట్‌పుట్‌ను ఉపయోగిస్తుంది. అందువల్ల ఇది ప్రస్తుత పదాన్ని ఉత్తమంగా అంచనా వేయడానికి మొత్తం ఇన్‌పుట్ వాక్యాన్ని యాక్సెస్ చేయగలదు. విభిన్న భాషలు పదాలను విభిన్న క్రమాలలో ఉంచే వ్యాకరణ నియమాలను కలిగి ఉండవచ్చు కాబట్టి లేదా వాక్యంలో తరువాత అందించిన కొన్ని సందర్భాలు ఒక నిర్దిష్ట పదం యొక్క ఉత్తమ అనువాదాన్ని నిర్ధారించడానికి సహాయకరంగా ఉండవచ్చు కాబట్టి ఇది చాలా ఉపయోగకరంగా ఉంటుంది. -The *attention mask* can also be used in the encoder/decoder to prevent the model from paying attention to some special words -- for instance, the special padding word used to make all the inputs the same length when batching together sentences. +_attention mask_ ను ఎన్‌కోడర్/డీకోడర్‌లో కూడా ఉపయోగించవచ్చు, మోడల్ కొన్ని ప్రత్యేక పదాలపై శ్రద్ధ పెట్టకుండా నిరోధించడానికి -- ఉదాహరణకు, వాక్యాలను బ్యాచింగ్ చేసేటప్పుడు అన్ని ఇన్‌పుట్‌లను ఒకే పొడవుకు తీసుకురావడానికి ఉపయోగించే ప్రత్యేక ప్యాడింగ్ పదం. -## Architectures vs. checkpoints[[architecture-vs-checkpoints]] +## ఆర్కిటెక్చర్లు vs. చెక్‌పాయింట్లు[[architecture-vs-checkpoints]] -As we dive into Transformer models in this course, you'll see mentions of *architectures* and *checkpoints* as well as *models*. These terms all have slightly different meanings: +ఈ కోర్సులో మనం Transformer మోడల్స్‌లోకి లోతుగా వెళ్తున్నప్పుడు, మీరు _architectures_ మరియు _checkpoints_ అలాగే _models_ అనే ప్రస్తావనలు చూస్తారు. ఈ పదాలకు అన్నింటికీ కొద్దిగా భిన్నమైన అర్థాలు ఉన్నాయి: -* **Architecture**: This is the skeleton of the model -- the definition of each layer and each operation that happens within the model. -* **Checkpoints**: These are the weights that will be loaded in a given architecture. -* **Model**: This is an umbrella term that isn't as precise as "architecture" or "checkpoint": it can mean both. This course will specify *architecture* or *checkpoint* when it matters to reduce ambiguity. +- **_architectures_**: ఇది మోడల్ యొక్క అస్థిపంజరం -- ప్రతి లేయర్ యొక్క నిర్వచనం మరియు మోడల్ లోపల జరిగే ప్రతి ఆపరేషన్. +- **_checkpoints_**: ఇవి ఒక నిర్దిష్ట ఆర్కిటెక్చర్‌లో లోడ్ చేయబడే వెయిట్స్. +- **_models_**: ఇది ఒక గొడుగు పదం, "ఆర్కిటెక్చర్" లేదా "చెక్‌పాయింట్" అంత కచ్చితమైనది కాదు: ఇది రెండు అర్థాలను సూచించవచ్చు. అస్పష్టతను తగ్గించడానికి ఈ కోర్సు ముఖ్యం అయినప్పుడు _ఆర్కిటెక్చర్_ లేదా _చెక్‌పాయింట్_ అని నిర్దిష్టంగా చెబుతుంది. -For example, BERT is an architecture while `bert-base-cased`, a set of weights trained by the Google team for the first release of BERT, is a checkpoint. However, one can say "the BERT model" and "the `bert-base-cased` model." +ఉదాహరణకు, BERT ఒక ఆర్కిటెక్చర్ అయితే, `bert-base-cased` అనేది BERT యొక్క మొదటి విడుదల కోసం Google బృందం శిక్షణ ఇచ్చిన వెయిట్స్ యొక్క సెట్, ఇది ఒక చెక్‌పాయింట్. అయితే, ఒకరు "BERT మోడల్" మరియు "`bert-base-cased` మోడల్" అని చెప్పవచ్చు. diff --git a/chapters/te/chapter1/5.mdx b/chapters/te/chapter1/5.mdx index 339fe62a4..0754c89ea 100644 --- a/chapters/te/chapter1/5.mdx +++ b/chapters/te/chapter1/5.mdx @@ -1,206 +1,214 @@ -# How 🤗 Transformers solve tasks +# 🤗 Transformerలు పనులను ఎలా పరిష్కరిస్తాయి -In [Transformers, what can they do?](/course/chapter1/3), you learned about natural language processing (NLP), speech and audio, computer vision tasks, and some important applications of them. This page will look closely at how models solve these tasks and explain what's happening under the hood. There are many ways to solve a given task, some models may implement certain techniques or even approach the task from a new angle, but for Transformer models, the general idea is the same. Owing to its flexible architecture, most models are a variant of an encoder, a decoder, or an encoder-decoder structure. +[Transformers, what can they do?](/course/chapter1/3)లో, మీరు సహజ భాషా ప్రాసెసింగ్ (NLP), ప్రసంగం మరియు ఆడియో, కంప్యూటర్ విజన్ పనులు మరియు వాటి కొన్ని ముఖ్యమైన అనువర్తనాల గురించి తెలుసుకున్నారు. ఈ పేజీ మోడల్స్ ఈ పనులను ఎలా పరిష్కరిస్తాయో నిశితంగా పరిశీలిస్తుంది మరియు తెరవెనుక ఏమి జరుగుతుందో వివరిస్తుంది. ఒక నిర్దిష్ట పనిని పరిష్కరించడానికి చాలా మార్గాలు ఉన్నాయి, కొన్ని మోడల్స్ నిర్దిష్ట టెక్నిక్‌లను అమలు చేయవచ్చు లేదా పనిని కొత్త కోణం నుండి కూడా సంప్రదించవచ్చు, కానీ Transformer మోడల్స్ కోసం, సాధారణ ఆలోచన ఒకటే. దాని సౌకర్యవంతమైన ఆర్కిటెక్చర్ కారణంగా, చాలా మోడల్స్ ఒక ఎన్‌కోడర్, ఒక డీకోడర్, లేదా ఒక ఎన్‌కోడర్-డీకోడర్ నిర్మాణం యొక్క వైవిధ్యాలుగా ఉంటాయి. -Before diving into specific architectural variants, it's helpful to understand that most tasks follow a similar pattern: input data is processed through a model, and the output is interpreted for a specific task. The differences lie in how the data is prepared, what model architecture variant is used, and how the output is processed. +నిర్దిష్ట ఆర్కిటెక్చరల్ వైవిధ్యాలలోకి ప్రవేశించే ముందు, చాలా పనులు ఒకే విధమైన పద్ధతిని అనుసరిస్తాయని అర్థం చేసుకోవడం సహాయపడుతుంది: ఇన్‌పుట్ డేటా ఒక మోడల్ ద్వారా ప్రాసెస్ చేయబడుతుంది మరియు అవుట్‌పుట్ ఒక నిర్దిష్ట పని కోసం వ్యాఖ్యానించబడుతుంది. తేడాలు డేటాను ఎలా తయారు చేస్తారు, ఏ మోడల్ ఆర్కిటెక్చర్ వైవిధ్యం ఉపయోగించబడుతుంది మరియు అవుట్‌పుట్ ఎలా ప్రాసెస్ చేయబడుతుంది అనే దానిలో ఉంటాయి. -To explain how tasks are solved, we'll walk through what goes on inside the model to output useful predictions. We'll cover the following models and their corresponding tasks: +పనులు ఎలా పరిష్కరించబడతాయో వివరించడానికి, ఉపయోగకరమైన అంచనాలను అవుట్‌పుట్ చేయడానికి మోడల్ లోపల ఏమి జరుగుతుందో మేము వివరిస్తాము. మేము ఈ క్రింది మోడల్స్ మరియు వాటి సంబంధిత పనులను కవర్ చేస్తాము: -- [Wav2Vec2](https://huggingface.co/docs/transformers/model_doc/wav2vec2) for audio classification and automatic speech recognition (ASR) -- [Vision Transformer (ViT)](https://huggingface.co/docs/transformers/model_doc/vit) and [ConvNeXT](https://huggingface.co/docs/transformers/model_doc/convnext) for image classification -- [DETR](https://huggingface.co/docs/transformers/model_doc/detr) for object detection -- [Mask2Former](https://huggingface.co/docs/transformers/model_doc/mask2former) for image segmentation -- [GLPN](https://huggingface.co/docs/transformers/model_doc/glpn) for depth estimation -- [BERT](https://huggingface.co/docs/transformers/model_doc/bert) for NLP tasks like text classification, token classification and question answering that use an encoder -- [GPT2](https://huggingface.co/docs/transformers/model_doc/gpt2) for NLP tasks like text generation that use a decoder -- [BART](https://huggingface.co/docs/transformers/model_doc/bart) for NLP tasks like summarization and translation that use an encoder-decoder +- [Wav2Vec2](https://huggingface.co/docs/transformers/model_doc/wav2vec2) ఆడియో వర్గీకరణ మరియు ఆటోమేటిక్ స్పీచ్ రికగ్నిషన్ (ASR) కోసం +- [Vision Transformer (ViT)](https://huggingface.co/docs/transformers/model_doc/vit) మరియు [ConvNeXT](https://huggingface.co/docs/transformers/model_doc/convnext) ఇమేజ్ వర్గీకరణ కోసం +- [DETR](https://huggingface.co/docs/transformers/model_doc/detr) వస్తువు గుర్తింపు కోసం +- [Mask2Former](https://huggingface.co/docs/transformers/model_doc/mask2former) ఇమేజ్ సెగ్మెంటేషన్ కోసం +- [GLPN](https://huggingface.co/docs/transformers/model_doc/glpn) డెప్త్ ఎస్టిమేషన్ కోసం +- [BERT](https://huggingface.co/docs/transformers/model_doc/bert) ఎన్‌కోడర్‌ను ఉపయోగించే టెక్స్ట్ వర్గీకరణ, టోకెన్ వర్గీకరణ మరియు ప్రశ్నలకు సమాధానాలు వంటి NLP పనుల కోసం +- [GPT2](https://huggingface.co/docs/transformers/model_doc/gpt2) డీకోడర్‌ను ఉపయోగించే టెక్స్ట్ జనరేషన్ వంటి NLP పనుల కోసం +- [BART](https://huggingface.co/docs/transformers/model_doc/bart) ఎన్‌కోడర్-డీకోడర్‌ను ఉపయోగించే సారాంశం మరియు అనువాదం వంటి NLP పనుల కోసం -Before you go further, it is good to have some basic knowledge of the original Transformer architecture. Knowing how encoders, decoders, and attention work will aid you in understanding how different Transformer models work. Be sure to check out our [the previous section](https://huggingface.co/course/chapter1/4?fw=pt) for more information! +మీరు ముందుకు వెళ్లే ముందు, అసలు Transformer ఆర్కిటెక్చర్ గురించి কিছু ప్రాథమిక పరిజ్ఞానం కలిగి ఉండటం మంచిది. ఎన్‌కోడర్‌లు, డీకోడర్‌లు మరియు అటెన్షన్ ఎలా పనిచేస్తుందో తెలుసుకోవడం వేర్వేరు Transformer మోడల్స్ ఎలా పనిచేస్తాయో అర్థం చేసుకోవడంలో మీకు సహాయపడుతుంది. మరింత సమాచారం కోసం మా [మునుపటి విభాగాన్ని](https://huggingface.co/course/chapter1/4?fw=pt) తప్పకుండా చూడండి! -## Transformer models for language +## భాష కోసం Transformer మోడల్స్ -Language models are at the heart of modern NLP. They're designed to understand and generate human language by learning the statistical patterns and relationships between words or tokens in text. +భాషా నమూనాలు ఆధునిక NLP యొక్క గుండెకాయ. అవి టెక్స్ట్‌లోని పదాలు లేదా టోకెన్‌ల మధ్య గణాంక నమూనాలు మరియు సంబంధాలను నేర్చుకోవడం ద్వారా మానవ భాషను అర్థం చేసుకోవడానికి మరియు ఉత్పత్తి చేయడానికి రూపొందించబడ్డాయి. -The Transformer was initially designed for machine translation, and since then, it has become the default architecture for solving all AI tasks. Some tasks lend themselves to the Transformer's encoder structure, while others are better suited for the decoder. Still, other tasks make use of both the Transformer's encoder-decoder structure. +Transformer మొదట యంత్ర అనువాదం కోసం రూపొందించబడింది, మరియు అప్పటి నుండి, ఇది అన్ని AI పనులను పరిష్కరించడానికి డిఫాల్ట్ ఆర్కిటెక్చర్‌గా మారింది. కొన్ని పనులు Transformer యొక్క ఎన్‌కోడర్ నిర్మాణానికి అనుకూలంగా ఉంటాయి, మరికొన్ని డీకోడర్‌కు బాగా సరిపోతాయి. మరికొన్ని పనులు Transformer యొక్క ఎన్‌కోడర్-డీకోడర్ నిర్మాణాన్ని రెండింటినీ ఉపయోగిస్తాయి. -### How language models work +### భాషా నమూనాలు ఎలా పనిచేస్తాయి -Language models work by being trained to predict the probability of a word given the context of surrounding words. This gives them a foundational understanding of language that can generalize to other tasks. +భాషా నమూనాలు చుట్టుపక్కల పదాల సందర్భాన్ని బట్టి ఒక పదం యొక్క సంభావ్యతను అంచనా వేయడానికి శిక్షణ పొందడం ద్వారా పనిచేస్తాయి. ఇది వాటికి భాషపై ప్రాథమిక అవగాహనను ఇస్తుంది, ఇది ఇతర పనులకు సాధారణీకరించగలదు. -There are two main approaches for training a transformer model: +ఒక Transformer మోడల్‌కు శిక్షణ ఇవ్వడానికి రెండు ప్రధాన విధానాలు ఉన్నాయి: -1. **Masked language modeling (MLM)**: Used by encoder models like BERT, this approach randomly masks some tokens in the input and trains the model to predict the original tokens based on the surrounding context. This allows the model to learn bidirectional context (looking at words both before and after the masked word). +1. **మాస్క్డ్ లాంగ్వేజ్ మోడలింగ్ (MLM)**: BERT వంటి ఎన్‌కోడర్ మోడల్స్ ద్వారా ఉపయోగించబడుతుంది, ఈ విధానం ఇన్‌పుట్‌లో కొన్ని టోకెన్‌లను యాదృచ్ఛికంగా మాస్క్ చేస్తుంది మరియు చుట్టుపక్కల సందర్భం ఆధారంగా అసలు టోకెన్‌లను అంచనా వేయడానికి మోడల్‌కు శిక్షణ ఇస్తుంది. ఇది మోడల్ ద్విదిశాత్మక సందర్భాన్ని (మాస్క్ చేసిన పదం ముందు మరియు తరువాత ఉన్న పదాలను చూడటం) నేర్చుకోవడానికి అనుమతిస్తుంది. -2. **Causal language modeling (CLM)**: Used by decoder models like GPT, this approach predicts the next token based on all previous tokens in the sequence. The model can only use context from the left (previous tokens) to predict the next token. +2. **కాజల్ లాంగ్వేజ్ మోడలింగ్ (CLM)**: GPT వంటి డీకోడర్ మోడల్స్ ద్వారా ఉపయోగించబడుతుంది, ఈ విధానం క్రమంలోని అన్ని మునుపటి టోకెన్‌ల ఆధారంగా తదుపరి టోకెన్‌ను అంచనా వేస్తుంది. మోడల్ తదుపరి టోకెన్‌ను అంచనా వేయడానికి ఎడమ వైపు (మునుపటి టోకెన్‌లు) నుండి మాత్రమే సందర్భాన్ని ఉపయోగించగలదు. -### Types of language models +### భాషా నమూనాల రకాలు -In the Transformers library, language models generally fall into three architectural categories: +Transformers లైబ్రరీలో, భాషా నమూనాలు సాధారణంగా మూడు ఆర్కిటెక్చరల్ వర్గాలలోకి వస్తాయి: -1. **Encoder-only models** (like BERT): These models use a bidirectional approach to understand context from both directions. They're best suited for tasks that require deep understanding of text, such as classification, named entity recognition, and question answering. +1. **ఎన్‌కోడర్-మాత్రమే మోడల్స్** (BERT వంటివి): ఈ మోడల్స్ రెండు దిశల నుండి సందర్భాన్ని అర్థం చేసుకోవడానికి ఒక ద్విదిశాత్మక విధానాన్ని ఉపయోగిస్తాయి. వర్గీకరణ, పేరున్న ఎంటిటీ గుర్తింపు మరియు ప్రశ్నలకు సమాధానాలు వంటి టెక్స్ట్ యొక్క లోతైన అవగాహన అవసరమయ్యే పనులకు ఇవి ఉత్తమంగా సరిపోతాయి. -2. **Decoder-only models** (like GPT, Llama): These models process text from left to right and are particularly good at text generation tasks. They can complete sentences, write essays, or even generate code based on a prompt. +2. **డీకోడర్-మాత్రమే మోడల్స్** (GPT, Llama వంటివి): ఈ మోడల్స్ ఎడమ నుండి కుడికి టెక్స్ట్‌ను ప్రాసెస్ చేస్తాయి మరియు ముఖ్యంగా టెక్స్ట్ జనరేషన్ పనులలో మంచివి. అవి ఒక ప్రాంప్ట్ ఆధారంగా వాక్యాలను పూర్తి చేయగలవు, వ్యాసాలు రాయగలవు లేదా కోడ్‌ను కూడా ఉత్పత్తి చేయగలవు. -3. **Encoder-decoder models** (like T5, BART): These models combine both approaches, using an encoder to understand the input and a decoder to generate output. They excel at sequence-to-sequence tasks like translation, summarization, and question answering. +3. **ఎన్‌కోడర్-డీకోడర్ మోడల్స్** (T5, BART వంటివి): ఈ మోడల్స్ రెండు విధానాలను మిళితం చేస్తాయి, ఇన్‌పుట్‌ను అర్థం చేసుకోవడానికి ఒక ఎన్‌కోడర్‌ను మరియు అవుట్‌పుట్‌ను ఉత్పత్తి చేయడానికి ఒక డీకోడర్‌ను ఉపయోగిస్తాయి. అనువాదం, సారాంశం మరియు ప్రశ్నలకు సమాధానాలు వంటి సీక్వెన్స్-టు-సీక్వెన్స్ పనులలో ఇవి రాణిస్తాయి. + ![transformer-models-for-language](https://huggingface.co/datasets/huggingface-course/documentation-images/resolve/main/en/chapter1/transformers_architecture.png) -![transformer-models-for-language](https://huggingface.co/datasets/huggingface-course/documentation-images/resolve/main/en/chapter1/transformers_architecture.png) +మునుపటి విభాగంలో మనం కవర్ చేసినట్లుగా, భాషా నమూనాలు సాధారణంగా స్వీయ-పర్యవేక్షిత పద్ధతిలో (మానవ ఉల్లేఖనలు లేకుండా) పెద్ద మొత్తంలో టెక్స్ట్ డేటాపై ముందే శిక్షణ పొందుతాయి, ఆపై నిర్దిష్ట పనులపై ఫైన్-ట్యూన్ చేయబడతాయి. ఈ విధానం, ట్రాన్స్‌ఫర్ లెర్నింగ్ అని పిలవబడుతుంది, ఈ మోడల్స్ సాపేక్షంగా తక్కువ మొత్తంలో పని-నిర్దిష్ట డేటాతో అనేక విభిన్న NLP పనులకు అనుగుణంగా ఉండటానికి అనుమతిస్తుంది. -As we covered in the previous section, language models are typically pretrained on large amounts of text data in a self-supervised manner (without human annotations), then fine-tuned on specific tasks. This approach, known as transfer learning, allows these models to adapt to many different NLP tasks with relatively small amounts of task-specific data. - -In the following sections, we'll explore specific model architectures and how they're applied to various tasks across speech, vision, and text domains. +తరువాతి విభాగాలలో, మేము నిర్దిష్ట మోడల్ ఆర్కిటెక్చర్లను మరియు అవి ప్రసంగం, దృష్టి మరియు టెక్స్ట్ డొమైన్‌లలోని వివిధ పనులకు ఎలా వర్తింపజేయబడతాయో అన్వేషిస్తాము. -Understanding which part of the Transformer architecture (encoder, decoder, or both) is best suited for a particular NLP task is key to choosing the right model. Generally, tasks requiring bidirectional context use encoders, tasks generating text use decoders, and tasks converting one sequence to another use encoder-decoders. +ఒక నిర్దిష్ట NLP పనికి ఏ Transformer ఆర్కిటెక్చర్ భాగం (ఎన్‌కోడర్, డీకోడర్, లేదా రెండూ) ఉత్తమంగా సరిపోతుందో అర్థం చేసుకోవడం సరైన మోడల్‌ను ఎంచుకోవడంలో కీలకం. సాధారణంగా, ద్విదిశాత్మక సందర్భం అవసరమయ్యే పనులు ఎన్‌కోడర్‌లను ఉపయోగిస్తాయి, టెక్స్ట్‌ను ఉత్పత్తి చేసే పనులు డీకోడర్‌లను ఉపయోగిస్తాయి మరియు ఒక క్రమాన్ని మరొకదానికి మార్చే పనులు ఎన్‌కోడర్-డీకోడర్‌లను ఉపయోగిస్తాయి. -### Text generation +### టెక్స్ట్ జనరేషన్ -Text generation involves creating coherent and contextually relevant text based on a prompt or input. +టెక్స్ట్ జనరేషన్ అనేది ఒక ప్రాంప్ట్ లేదా ఇన్‌పుట్ ఆధారంగా పొందికైన మరియు సందర్భోచితంగా ఉండే టెక్స్ట్‌ను సృష్టించడం. -[GPT-2](https://huggingface.co/docs/transformers/model_doc/gpt2) is a decoder-only model pretrained on a large amount of text. It can generate convincing (though not always true!) text given a prompt and complete other NLP tasks like question answering despite not being explicitly trained to. +[GPT-2](https://huggingface.co/docs/transformers/model_doc/gpt2) అనేది పెద్ద మొత్తంలో టెక్స్ట్‌పై ముందే శిక్షణ పొందిన డీకోడర్-మాత్రమే మోడల్. ఇది ఒక ప్రాంప్ట్ ఇచ్చినప్పుడు నమ్మదగిన (ఎల్లప్పుడూ నిజం కానప్పటికీ!) టెక్స్ట్‌ను ఉత్పత్తి చేయగలదు మరియు స్పష్టంగా శిక్షణ పొందనప్పటికీ ప్రశ్నలకు సమాధానాలు వంటి ఇతర NLP పనులను పూర్తి చేయగలదు.
- +
+1. GPT-2 పదాలను టోకనైజ్ చేయడానికి మరియు టోకెన్ ఎంబెడ్డింగ్‌ను రూపొందించడానికి [byte +pair encoding (BPE)](https://huggingface.co/docs/transformers/tokenizer_summary#bytepair-encoding-bpe) +ను ఉపయోగిస్తుంది. క్రమంలో ప్రతి టోకెన్ యొక్క స్థానాన్ని సూచించడానికి టోకెన్ ఎంబెడ్డింగ్‌లకు +పొజిషనల్ ఎన్‌కోడింగ్‌లు జోడించబడతాయి. ఇన్‌పుట్ ఎంబెడ్డింగ్‌లు చివరి దాచిన స్థితిని +అవుట్‌పుట్ చేయడానికి బహుళ డీకోడర్ బ్లాక్‌ల ద్వారా పంపబడతాయి. ప్రతి డీకోడర్ బ్లాక్ +లోపల, GPT-2 ఒక *masked self-attention* లేయర్‌ను ఉపయోగిస్తుంది, దీని అర్థం GPT-2 భవిష్యత్ +టోకెన్‌లకు అటెన్షన్ ఇవ్వలేదు. ఇది ఎడమ వైపు ఉన్న టోకెన్‌లకు మాత్రమే అటెన్షన్ ఇవ్వడానికి +అనుమతించబడుతుంది. ఇది BERT యొక్క [`mask`] టోకెన్ నుండి భిన్నంగా ఉంటుంది, ఎందుకంటే +masked self-attention లో, భవిష్యత్ టోకెన్‌ల కోసం స్కోర్‌ను `0` కు సెట్ చేయడానికి +ఒక అటెన్షన్ మాస్క్ ఉపయోగించబడుతుంది. -1. GPT-2 uses [byte pair encoding (BPE)](https://huggingface.co/docs/transformers/tokenizer_summary#bytepair-encoding-bpe) to tokenize words and generate a token embedding. Positional encodings are added to the token embeddings to indicate the position of each token in the sequence. The input embeddings are passed through multiple decoder blocks to output some final hidden state. Within each decoder block, GPT-2 uses a *masked self-attention* layer which means GPT-2 can't attend to future tokens. It is only allowed to attend to tokens on the left. This is different from BERT's [`mask`] token because, in masked self-attention, an attention mask is used to set the score to `0` for future tokens. - -2. The output from the decoder is passed to a language modeling head, which performs a linear transformation to convert the hidden states into logits. The label is the next token in the sequence, which are created by shifting the logits to the right by one. The cross-entropy loss is calculated between the shifted logits and the labels to output the next most likely token. +2. డీకోడర్ నుండి వచ్చే అవుట్‌పుట్‌ను ఒక లాంగ్వేజ్ మోడలింగ్ హెడ్‌కు పంపబడుతుంది, ఇది దాచిన స్థితులను లాజిట్స్‌గా మార్చడానికి ఒక లీనియర్ ట్రాన్స్‌ఫర్మేషన్ చేస్తుంది. లేబుల్ క్రమంలోని తర్వాతి టోకెన్, ఇది లాజిట్స్‌ను కుడివైపు ఒక స్థానం జరపడం ద్వారా సృష్టించబడుతుంది. షిఫ్ట్ చేయబడిన లాజిట్స్ మరియు లేబుల్స్ మధ్య క్రాస్-ఎంట్రోపీ నష్టం లెక్కించబడుతుంది, తద్వారా తదుపరి అత్యంత సంభావ్య టోకెన్‌ను అవుట్‌పుట్ చేయవచ్చు. -GPT-2's pretraining objective is based entirely on [causal language modeling](https://huggingface.co/docs/transformers/glossary#causal-language-modeling), predicting the next word in a sequence. This makes GPT-2 especially good at tasks that involve generating text. +GPT-2 యొక్క ప్రీ-ట్రైనింగ్ లక్ష్యం పూర్తిగా [causal language modeling](https://huggingface.co/docs/transformers/glossary#causal-language-modeling) పై ఆధారపడి ఉంటుంది, ఒక క్రమంలోని తర్వాతి పదాన్ని అంచనా వేయడం. ఇది GPT-2ను ముఖ్యంగా టెక్స్ట్ ఉత్పత్తికి సంబంధించిన పనులలో మంచిదిగా చేస్తుంది. -Ready to try your hand at text generation? Check out our complete [causal language modeling guide](https://huggingface.co/docs/transformers/tasks/language_modeling#causal-language-modeling) to learn how to finetune DistilGPT-2 and use it for inference! +టెక్స్ట్ జనరేషన్‌లో మీ నైపుణ్యాన్ని ప్రయత్నించడానికి సిద్ధంగా ఉన్నారా? DistilGPT-2ను ఫైన్‌ట్యూన్ చేయడం మరియు దానిని ఇన్ఫరెన్స్ కోసం ఉపయోగించడం ఎలాగో తెలుసుకోవడానికి మా పూర్తి [causal language modeling guide](https://huggingface.co/docs/transformers/tasks/language_modeling#causal-language-modeling)ను చూడండి! -For more information about text generation, check out the [text generation strategies](generation_strategies) guide! + టెక్స్ట్ జనరేషన్ గురించి మరింత సమాచారం కోసం, [text generation + strategies](generation_strategies) గైడ్‌ను చూడండి! -### Text classification +### టెక్స్ట్ వర్గీకరణ -Text classification involves assigning predefined categories to text documents, such as sentiment analysis, topic classification, or spam detection. +టెక్స్ట్ వర్గీకరణ అనేది టెక్స్ట్ పత్రాలకు ముందుగా నిర్వచించిన వర్గాలను కేటాయించడం, సెంటిమెంట్ విశ్లేషణ, అంశ వర్గీకరణ, లేదా స్పామ్ గుర్తింపు వంటివి. -[BERT](https://huggingface.co/docs/transformers/model_doc/bert) is an encoder-only model and is the first model to effectively implement deep bidirectionality to learn richer representations of the text by attending to words on both sides. +[BERT](https://huggingface.co/docs/transformers/model_doc/bert) ఒక ఎన్‌కోడర్-మాత్రమే మోడల్ మరియు ఇది రెండు వైపులా ఉన్న పదాలకు అటెన్షన్ ఇవ్వడం ద్వారా టెక్స్ట్ యొక్క గొప్ప ప్రాతినిధ్యాలను నేర్చుకోవడానికి లోతైన ద్విదిశాత్మకతను సమర్థవంతంగా అమలు చేసిన మొదటి మోడల్. -1. BERT uses [WordPiece](https://huggingface.co/docs/transformers/tokenizer_summary#wordpiece) tokenization to generate a token embedding of the text. To tell the difference between a single sentence and a pair of sentences, a special `[SEP]` token is added to differentiate them. A special `[CLS]` token is added to the beginning of every sequence of text. The final output with the `[CLS]` token is used as the input to the classification head for classification tasks. BERT also adds a segment embedding to denote whether a token belongs to the first or second sentence in a pair of sentences. +1. BERT టెక్స్ట్ యొక్క టోకెన్ ఎంబెడ్డింగ్‌ను రూపొందించడానికి [WordPiece](https://huggingface.co/docs/transformers/tokenizer_summary#wordpiece) టోకనైజేషన్‌ను ఉపయోగిస్తుంది. ఒకే వాక్యం మరియు వాక్యాల జత మధ్య తేడాను చెప్పడానికి, వాటిని వేరు చేయడానికి ఒక ప్రత్యేక `[SEP]` టోకెన్ జోడించబడుతుంది. ప్రతి టెక్స్ట్ క్రమం ప్రారంభంలో ఒక ప్రత్యేక `[CLS]` టోకెన్ జోడించబడుతుంది. `[CLS]` టోకెన్‌తో ఉన్న చివరి అవుట్‌పుట్ వర్గీకరణ పనుల కోసం వర్గీకరణ హెడ్‌కు ఇన్‌పుట్‌గా ఉపయోగించబడుతుంది. BERT ఒక టోకెన్ వాక్యాల జతలోని మొదటి లేదా రెండవ వాక్యానికి చెందినదా అని సూచించడానికి ఒక సెగ్మెంట్ ఎంబెడ్డింగ్‌ను కూడా జోడిస్తుంది. -2. BERT is pretrained with two objectives: masked language modeling and next-sentence prediction. In masked language modeling, some percentage of the input tokens are randomly masked, and the model needs to predict these. This solves the issue of bidirectionality, where the model could cheat and see all the words and "predict" the next word. The final hidden states of the predicted mask tokens are passed to a feedforward network with a softmax over the vocabulary to predict the masked word. +2. BERT రెండు లక్ష్యాలతో ముందే శిక్షణ పొందింది: మాస్క్డ్ లాంగ్వేజ్ మోడలింగ్ మరియు నెక్స్ట్-సెంటెన్స్ ప్రిడిక్షన్. మాస్క్డ్ లాంగ్వేజ్ మోడలింగ్‌లో, ఇన్‌పుట్ టోకెన్‌లలో కొంత శాతం యాదృచ్ఛికంగా మాస్క్ చేయబడతాయి, మరియు మోడల్ వీటిని అంచనా వేయాలి. ఇది ద్విదిశాత్మకత సమస్యను పరిష్కరిస్తుంది, ఇక్కడ మోడల్ మోసం చేసి అన్ని పదాలను చూసి తర్వాతి పదాన్ని "అంచనా" వేయగలదు. అంచనా వేయబడిన మాస్క్ టోకెన్‌ల యొక్క చివరి దాచిన స్థితులు మాస్క్ చేయబడిన పదాన్ని అంచనా వేయడానికి ఒక ఫీడ్‌ఫార్వర్డ్ నెట్‌వర్క్‌కు పదజాలంపై సాఫ్ట్‌మాక్స్‌తో పంపబడతాయి. - The second pretraining object is next-sentence prediction. The model must predict whether sentence B follows sentence A. Half of the time sentence B is the next sentence, and the other half of the time, sentence B is a random sentence. The prediction, whether it is the next sentence or not, is passed to a feedforward network with a softmax over the two classes (`IsNext` and `NotNext`). + రెండవ ప్రీ-ట్రైనింగ్ లక్ష్యం నెక్స్ట్-సెంటెన్స్ ప్రిడిక్షన్. మోడల్ వాక్యం B వాక్యం A ను అనుసరిస్తుందా లేదా అని అంచనా వేయాలి. సగం సార్లు వాక్యం B తర్వాతి వాక్యం, మరియు మిగిలిన సగం సార్లు, వాక్యం B ఒక యాదృచ్ఛిక వాక్యం. అంచనా, అది తర్వాతి వాక్యమా కాదా అనేది, రెండు వర్గాలపై (`IsNext` మరియు `NotNext`) సాఫ్ట్‌మాక్స్‌తో ఉన్న ఒక ఫీడ్‌ఫార్వర్డ్ నెట్‌వర్క్‌కు పంపబడుతుంది. -3. The input embeddings are passed through multiple encoder layers to output some final hidden states. +3. ఇన్‌పుట్ ఎంబెడ్డింగ్‌లు చివరి దాచిన స్థితులను అవుట్‌పుట్ చేయడానికి బహుళ ఎన్‌కోడర్ లేయర్‌ల ద్వారా పంపబడతాయి. -To use the pretrained model for text classification, add a sequence classification head on top of the base BERT model. The sequence classification head is a linear layer that accepts the final hidden states and performs a linear transformation to convert them into logits. The cross-entropy loss is calculated between the logits and target to find the most likely label. +టెక్స్ట్ వర్గీకరణ కోసం ముందే శిక్షణ పొందిన మోడల్‌ను ఉపయోగించడానికి, బేస్ BERT మోడల్ పైన ఒక సీక్వెన్స్ వర్గీకరణ హెడ్‌ను జోడించండి. సీక్వెన్స్ వర్గీకరణ హెడ్ అనేది ఒక లీనియర్ లేయర్, ఇది చివరి దాచిన స్థితులను అంగీకరించి మరియు వాటిని లాజిట్స్‌గా మార్చడానికి ఒక లీనియర్ ట్రాన్స్‌ఫర్మేషన్ చేస్తుంది. లాజిట్స్ మరియు టార్గెట్ మధ్య క్రాస్-ఎంట్రోపీ నష్టం లెక్కించబడుతుంది, తద్వారా అత్యంత సంభావ్య లేబుల్‌ను కనుగొనవచ్చు. -Ready to try your hand at text classification? Check out our complete [text classification guide](https://huggingface.co/docs/transformers/tasks/sequence_classification) to learn how to finetune DistilBERT and use it for inference! +టెక్స్ట్ వర్గీకరణలో మీ నైపుణ్యాన్ని ప్రయత్నించడానికి సిద్ధంగా ఉన్నారా? DistilBERTను ఫైన్‌ట్యూన్ చేయడం మరియు దానిని ఇన్ఫరెన్స్ కోసం ఉపయోగించడం ఎలాగో తెలుసుకోవడానికి మా పూర్తి [text classification guide](https://huggingface.co/docs/transformers/tasks/sequence_classification)ను చూడండి! -### Token classification +### టోకెన్ వర్గీకరణ -Token classification involves assigning a label to each token in a sequence, such as in named entity recognition or part-of-speech tagging. +టోకెన్ వర్గీకరణ అనేది ఒక క్రమంలోని ప్రతి టోకెన్‌కు ఒక లేబుల్‌ను కేటాయించడం, పేరున్న ఎంటిటీ గుర్తింపు లేదా పార్ట్-ఆఫ్-స్పీచ్ ట్యాగింగ్ వంటివి. -To use BERT for token classification tasks like named entity recognition (NER), add a token classification head on top of the base BERT model. The token classification head is a linear layer that accepts the final hidden states and performs a linear transformation to convert them into logits. The cross-entropy loss is calculated between the logits and each token to find the most likely label. +పేరున్న ఎంటిటీ గుర్తింపు (NER) వంటి టోకెన్ వర్గీకరణ పనుల కోసం BERTను ఉపయోగించడానికి, బేస్ BERT మోడల్ పైన ఒక టోకెన్ వర్గీకరణ హెడ్‌ను జోడించండి. టోకెన్ వర్గీకరణ హెడ్ అనేది ఒక లీనియర్ లేయర్, ఇది చివరి దాచిన స్థితులను అంగీకరించి మరియు వాటిని లాజిట్స్‌గా మార్చడానికి ఒక లీనియర్ ట్రాన్స్‌ఫర్మేషన్ చేస్తుంది. లాజిట్స్ మరియు ప్రతి టోకెన్ మధ్య క్రాస్-ఎంట్రోపీ నష్టం లెక్కించబడుతుంది, తద్వారా అత్యంత సంభావ్య లేబుల్‌ను కనుగొనవచ్చు. -Ready to try your hand at token classification? Check out our complete [token classification guide](https://huggingface.co/docs/transformers/tasks/token_classification) to learn how to finetune DistilBERT and use it for inference! +టోకెన్ వర్గీకరణలో మీ నైపుణ్యాన్ని ప్రయత్నించడానికి సిద్ధంగా ఉన్నారా? DistilBERTను ఫైన్‌ట్యూన్ చేయడం మరియు దానిని ఇన్ఫరెన్స్ కోసం ఉపయోగించడం ఎలాగో తెలుసుకోవడానికి మా పూర్తి [token classification guide](https://huggingface.co/docs/transformers/tasks/token_classification)ను చూడండి! -### Question answering +### ప్రశ్నలకు సమాధానాలు -Question answering involves finding the answer to a question within a given context or passage. +ప్రశ్నలకు సమాధానాలు అనేది ఇచ్చిన సందర్భం లేదా పేరాలో ఒక ప్రశ్నకు సమాధానాన్ని కనుగొనడం. -To use BERT for question answering, add a span classification head on top of the base BERT model. This linear layer accepts the final hidden states and performs a linear transformation to compute the `span` start and end logits corresponding to the answer. The cross-entropy loss is calculated between the logits and the label position to find the most likely span of text corresponding to the answer. +ప్రశ్నలకు సమాధానాల కోసం BERTను ఉపయోగించడానికి, బేస్ BERT మోడల్ పైన ఒక స్పాన్ వర్గీకరణ హెడ్‌ను జోడించండి. ఈ లీనియర్ లేయర్ చివరి దాచిన స్థితులను అంగీకరించి మరియు సమాధానానికి సంబంధించిన `span` ప్రారంభ మరియు ముగింపు లాజిట్స్‌ను లెక్కించడానికి ఒక లీనియర్ ట్రాన్స్‌ఫర్మేషన్ చేస్తుంది. లాజిట్స్ మరియు లేబుల్ పొజిషన్ మధ్య క్రాస్-ఎంట్రోపీ నష్టం లెక్కించబడుతుంది, తద్వారా సమాధానానికి సంబంధించిన అత్యంత సంభావ్య టెక్స్ట్ స్పాన్‌ను కనుగొనవచ్చు. -Ready to try your hand at question answering? Check out our complete [question answering guide](https://huggingface.co/docs/transformers/tasks/question_answering) to learn how to finetune DistilBERT and use it for inference! +ప్రశ్నలకు సమాధానాలలో మీ నైపుణ్యాన్ని ప్రయత్నించడానికి సిద్ధంగా ఉన్నారా? DistilBERTను ఫైన్‌ట్యూన్ చేయడం మరియు దానిని ఇన్ఫరెన్స్ కోసం ఉపయోగించడం ఎలాగో తెలుసుకోవడానికి మా పూర్తి [question answering guide](https://huggingface.co/docs/transformers/tasks/question_answering)ను చూడండి! -💡 Notice how easy it is to use BERT for different tasks once it's been pretrained. You only need to add a specific head to the pretrained model to manipulate the hidden states into your desired output! +💡 BERT ముందే శిక్షణ పొందిన తర్వాత వివిధ పనుల కోసం ఉపయోగించడం ఎంత సులభమో గమనించండి. మీ దాచిన స్థితులను మీ కావలసిన అవుట్‌పుట్‌గా మార్చడానికి ముందే శిక్షణ పొందిన మోడల్‌కు ఒక నిర్దిష్ట హెడ్‌ను జోడించడం మాత్రమే మీకు అవసరం! -### Summarization +### సారాంశం -Summarization involves condensing a longer text into a shorter version while preserving its key information and meaning. +సారాంశం అనేది దాని కీలక సమాచారం మరియు అర్థాన్ని కాపాడుకుంటూ ఒక పొడవైన టెక్స్ట్‌ను చిన్న వెర్షన్‌గా కుదించడం. -Encoder-decoder models like [BART](https://huggingface.co/docs/transformers/model_doc/bart) and [T5](model_doc/t5) are designed for the sequence-to-sequence pattern of a summarization task. We'll explain how BART works in this section, and then you can try finetuning T5 at the end. +[BART](https://huggingface.co/docs/transformers/model_doc/bart) మరియు [T5](model_doc/t5) వంటి ఎన్‌కోడర్-డీకోడర్ మోడల్స్ ఒక సారాంశం పని యొక్క సీక్వెన్స్-టు-సీక్వెన్స్ నమూనా కోసం రూపొందించబడ్డాయి. మేము ఈ విభాగంలో BART ఎలా పనిచేస్తుందో వివరిస్తాము, ఆపై మీరు చివరిలో T5ను ఫైన్‌ట్యూన్ చేయడానికి ప్రయత్నించవచ్చు.
- +
-1. BART's encoder architecture is very similar to BERT and accepts a token and positional embedding of the text. BART is pretrained by corrupting the input and then reconstructing it with the decoder. Unlike other encoders with specific corruption strategies, BART can apply any type of corruption. The *text infilling* corruption strategy works the best though. In text infilling, a number of text spans are replaced with a **single** [`mask`] token. This is important because the model has to predict the masked tokens, and it teaches the model to predict the number of missing tokens. The input embeddings and masked spans are passed through the encoder to output some final hidden states, but unlike BERT, BART doesn't add a final feedforward network at the end to predict a word. +1. BART యొక్క ఎన్‌కోడర్ ఆర్కిటెక్చర్ BERTకు చాలా సారూప్యంగా ఉంటుంది మరియు టెక్స్ట్ యొక్క టోకెన్ మరియు పొజిషనల్ ఎంబెడ్డింగ్‌ను అంగీకరిస్తుంది. BART ఇన్‌పుట్‌ను పాడు చేసి ఆపై దానిని డీకోడర్‌తో పునర్నిర్మించడం ద్వారా ముందే శిక్షణ పొందింది. నిర్దిష్ట కరప్షన్ వ్యూహాలు ఉన్న ఇతర ఎన్‌కోడర్‌ల వలె కాకుండా, BART ఏ రకమైన కరప్షన్‌ను అయినా వర్తింపజేయగలదు. _text infilling_ కరప్షన్ వ్యూహం ఉత్తమంగా పనిచేస్తుంది. టెక్స్ట్ ఇన్ఫిలింగ్‌లో, అనేక టెక్స్ట్ స్పాన్‌లు ఒక **సింగిల్** [`mask`] టోకెన్‌తో భర్తీ చేయబడతాయి. ఇది ముఖ్యం ఎందుకంటే మోడల్ మాస్క్ చేసిన టోకెన్‌లను అంచనా వేయాలి, మరియు ఇది మోడల్‌కు తప్పిపోయిన టోకెన్‌ల సంఖ్యను అంచనా వేయడం నేర్పుతుంది. ఇన్‌పుట్ ఎంబెడ్డింగ్‌లు మరియు మాస్క్ చేసిన స్పాన్‌లు ఎన్‌కోడర్ ద్వారా పంపబడి చివరి దాచిన స్థితులను అవుట్‌పుట్ చేస్తాయి, కానీ BERT వలె కాకుండా, BART ఒక పదాన్ని అంచనా వేయడానికి చివరిలో ఒక ఫైనల్ ఫీడ్‌ఫార్వర్డ్ నెట్‌వర్క్‌ను జోడించదు. -2. The encoder's output is passed to the decoder, which must predict the masked tokens and any uncorrupted tokens from the encoder's output. This gives additional context to help the decoder restore the original text. The output from the decoder is passed to a language modeling head, which performs a linear transformation to convert the hidden states into logits. The cross-entropy loss is calculated between the logits and the label, which is just the token shifted to the right. +2. ఎన్‌కోడర్ యొక్క అవుట్‌పుట్ డీకోడర్‌కు పంపబడుతుంది, ఇది మాస్క్ చేసిన టోకెన్‌లను మరియు ఎన్‌కోడర్ యొక్క అవుట్‌పుట్ నుండి ఏదైనా పాడవని టోకెన్‌లను అంచనా వేయాలి. ఇది డీకోడర్‌కు అసలు టెక్స్ట్‌ను పునరుద్ధరించడానికి అదనపు సందర్భాన్ని ఇస్తుంది. డీకోడర్ నుండి వచ్చే అవుట్‌పుట్‌ను ఒక లాంగ్వేజ్ మోడలింగ్ హెడ్‌కు పంపబడుతుంది, ఇది దాచిన స్థితులను లాజిట్స్‌గా మార్చడానికి ఒక లీనియర్ ట్రాన్స్‌ఫర్మేషన్ చేస్తుంది. లాజిట్స్ మరియు లేబుల్ మధ్య క్రాస్-ఎంట్రోపీ నష్టం లెక్కించబడుతుంది, ఇది కేవలం కుడివైపు షిఫ్ట్ చేయబడిన టోకెన్. -Ready to try your hand at summarization? Check out our complete [summarization guide](https://huggingface.co/docs/transformers/tasks/summarization) to learn how to finetune T5 and use it for inference! +సారాంశంలో మీ నైపుణ్యాన్ని ప్రయత్నించడానికి సిద్ధంగా ఉన్నారా? T5ను ఫైన్‌ట్యూన్ చేయడం మరియు దానిని ఇన్ఫరెన్స్ కోసం ఉపయోగించడం ఎలాగో తెలుసుకోవడానికి మా పూర్తి [summarization guide](https://huggingface.co/docs/transformers/tasks/summarization)ను చూడండి! -For more information about text generation, check out the [text generation strategies](https://huggingface.co/docs/transformers/generation_strategies) guide! +టెక్స్ట్ జనరేషన్ గురించి మరింత సమాచారం కోసం, [text generation strategies](https://huggingface.co/docs/transformers/generation_strategies) గైడ్‌ను చూడండి! -### Translation +### అనువాదం -Translation involves converting text from one language to another while preserving its meaning. Translation is another example of a sequence-to-sequence task, which means you can use an encoder-decoder model like [BART](https://huggingface.co/docs/transformers/model_doc/bart) or [T5](model_doc/t5) to do it. We'll explain how BART works in this section, and then you can try finetuning T5 at the end. +అనువాదం అనేది ఒక భాష నుండి మరొక భాషకు టెక్స్ట్‌ను దాని అర్థాన్ని కాపాడుకుంటూ మార్చడం. అనువాదం కూడా ఒక సీక్వెన్స్-టు-సీక్వెన్స్ పనికి ఉదాహరణ, అంటే మీరు దీన్ని చేయడానికి [BART](https://huggingface.co/docs/transformers/model_doc/bart) లేదా [T5](model_doc/t5) వంటి ఎన్‌కోడర్-డీకోడర్ మోడల్‌ను ఉపయోగించవచ్చు. మేము ఈ విభాగంలో BART ఎలా పనిచేస్తుందో వివరిస్తాము, ఆపై మీరు చివరిలో T5ను ఫైన్‌ట్యూన్ చేయడానికి ప్రయత్నించవచ్చు. -BART adapts to translation by adding a separate randomly initialized encoder to map a source language to an input that can be decoded into the target language. This new encoder's embeddings are passed to the pretrained encoder instead of the original word embeddings. The source encoder is trained by updating the source encoder, positional embeddings, and input embeddings with the cross-entropy loss from the model output. The model parameters are frozen in this first step, and all the model parameters are trained together in the second step. -BART has since been followed up by a multilingual version, mBART, intended for translation and pretrained on many different languages. +BART ఒక మూల భాషను లక్ష్య భాషలోకి డీకోడ్ చేయగల ఇన్‌పుట్‌గా మ్యాప్ చేయడానికి ఒక ప్రత్యేక యాదృచ్ఛికంగా ప్రారంభించబడిన ఎన్‌కోడర్‌ను జోడించడం ద్వారా అనువాదానికి అనుగుణంగా ఉంటుంది. ఈ కొత్త ఎన్‌కోడర్ యొక్క ఎంబెడ్డింగ్‌లు అసలు వర్డ్ ఎంబెడ్డింగ్‌లకు బదులుగా ముందే శిక్షణ పొందిన ఎన్‌కోడర్‌కు పంపబడతాయి. మూల ఎన్‌కోడర్ మోడల్ అవుట్‌పుట్ నుండి క్రాస్-ఎంట్రోపీ నష్టంతో మూల ఎన్‌కోడర్, పొజిషనల్ ఎంబెడ్డింగ్‌లు మరియు ఇన్‌పుట్ ఎంబెడ్డింగ్‌లను నవీకరించడం ద్వారా శిక్షణ పొందుతుంది. మోడల్ పారామితులు ఈ మొదటి దశలో ఫ్రీజ్ చేయబడతాయి, మరియు అన్ని మోడల్ పారామితులు రెండవ దశలో కలిసి శిక్షణ పొందుతాయి. +BART తరువాత అనేక విభిన్న భాషలపై ముందే శిక్షణ పొందిన అనువాదం కోసం ఉద్దేశించిన బహుభాషా వెర్షన్, mBART, ను అనుసరించింది. -Ready to try your hand at translation? Check out our complete [translation guide](https://huggingface.co/docs/transformers/tasks/translation) to learn how to finetune T5 and use it for inference! +అనువాదంలో మీ నైపుణ్యాన్ని ప్రయత్నించడానికి సిద్ధంగా ఉన్నారా? T5ను ఫైన్‌ట్యూన్ చేయడం మరియు దానిని ఇన్ఫరెన్స్ కోసం ఉపయోగించడం ఎలాగో తెలుసుకోవడానికి మా పూర్తి [translation guide](https://huggingface.co/docs/transformers/tasks/translation)ను చూడండి! -As you've seen throughout this guide, many models follow similar patterns despite addressing different tasks. Understanding these common patterns can help you quickly grasp how new models work and how to adapt existing models to your specific needs. +ఈ గైడ్ అంతటా మీరు చూసినట్లుగా, అనేక మోడల్స్ వేర్వేరు పనులను పరిష్కరించినప్పటికీ ఇలాంటి నమూనాలను అనుసరిస్తాయి. ఈ సాధారణ నమూనాలను అర్థం చేసుకోవడం కొత్త మోడల్స్ ఎలా పనిచేస్తాయో మరియు మీ నిర్దిష్ట అవసరాలకు అనుగుణంగా ఉన్న మోడల్స్‌ను ఎలా మార్చుకోవాలో త్వరగా గ్రహించడంలో మీకు సహాయపడుతుంది. -## Modalities beyond text +## టెక్స్ట్ దాటిన మోడాలిటీలు -Transformers are not limited to text. They can also be applied to other modalities like speech and audio, images, and video. Of course, on this course we will focus on text, but we can briefly introduce the other modalities. +Transformers టెక్స్ట్‌కు పరిమితం కాదు. అవి ప్రసంగం మరియు ఆడియో, చిత్రాలు మరియు వీడియో వంటి ఇతర మోడాలిటీలకు కూడా వర్తింపజేయబడతాయి. వాస్తవానికి, ఈ కోర్సులో మనం టెక్స్ట్‌పై దృష్టి పెడతాము, కానీ మనం ఇతర మోడాలిటీలను క్లుప్తంగా పరిచయం చేయవచ్చు. -### Speech and audio +### ప్రసంగం మరియు ఆడియో -Let's start by exploring how Transformer models handle speech and audio data, which presents unique challenges compared to text or images. +టెక్స్ట్ లేదా చిత్రాలతో పోలిస్తే ప్రత్యేకమైన సవాళ్లను ఎదుర్కొనే ప్రసంగం మరియు ఆడియో డేటాను Transformer మోడల్స్ ఎలా నిర్వహిస్తాయో అన్వేషించడం ద్వారా ప్రారంభిద్దాం. -[Whisper](https://huggingface.co/docs/transformers/main/en/model_doc/whisper) is a encoder-decoder (sequence-to-sequence) transformer pretrained on 680,000 hours of labeled audio data. This amount of pretraining data enables zero-shot performance on audio tasks in English and many other languages. The decoder allows Whisper to map the encoders learned speech representations to useful outputs, such as text, without additional fine-tuning. Whisper just works out of the box. +[Whisper](https://huggingface.co/docs/transformers/main/en/model_doc/whisper) అనేది 680,000 గంటల లేబుల్ చేయబడిన ఆడియో డేటాపై ముందే శిక్షణ పొందిన ఒక ఎన్‌కోడర్-డీకోడర్ (సీక్వెన్స్-టు-సీక్వెన్స్) ట్రాన్స్‌ఫార్మర్. ఈ మొత్తం ప్రీ-ట్రైనింగ్ డేటా ఇంగ్లీష్ మరియు అనేక ఇతర భాషలలో ఆడియో పనులపై జీరో-షాట్ పనితీరును సాధ్యం చేస్తుంది. డీకోడర్ Whisperకు దాని నేర్చుకున్న ప్రసంగ ప్రాతినిధ్యాలను టెక్స్ట్ వంటి ఉపయోగకరమైన అవుట్‌పుట్‌లకు, అదనపు ఫైన్-ట్యూనింగ్ లేకుండా మ్యాప్ చేయడానికి అనుమతిస్తుంది. Whisper బాక్స్ నుండి నేరుగా పనిచేస్తుంది.
- +
-Diagram is from [Whisper paper](https://huggingface.co/papers/2212.04356). +ఈ రేఖాచిత్రం [Whisper పేపర్](https://huggingface.co/papers/2212.04356) నుండి తీసుకోబడింది. -This model has two main components: +ఈ మోడల్‌లో రెండు ప్రధాన భాగాలు ఉన్నాయి: -1. An **encoder** processes the input audio. The raw audio is first converted into a log-Mel spectrogram. This spectrogram is then passed through a Transformer encoder network. +1. ఒక **ఎన్‌కోడర్** ఇన్‌పుట్ ఆడియోను ప్రాసెస్ చేస్తుంది. ముడి ఆడియో మొదట ఒక లాగ్-మెల్ స్పెక్ట్రోగ్రామ్‌గా మార్చబడుతుంది. ఈ స్పెక్ట్రోగ్రామ్ ఆపై ఒక Transformer ఎన్‌కోడర్ నెట్‌వర్క్ ద్వారా పంపబడుతుంది. -2. A **decoder** takes the encoded audio representation and autoregressively predicts the corresponding text tokens. It's a standard Transformer decoder trained to predict the next text token given the previous tokens and the encoder output. Special tokens are used at the beginning of the decoder input to steer the model towards specific tasks like transcription, translation, or language identification. +2. ఒక **డీకోడర్** ఎన్‌కోడ్ చేయబడిన ఆడియో ప్రాతినిధ్యాన్ని తీసుకుని మరియు అనుగుణమైన టెక్స్ట్ టోకెన్‌లను ఆటోరిగ్రెసివ్‌గా అంచనా వేస్తుంది. ఇది ఒక ప్రామాణిక Transformer డీకోడర్, ఇది మునుపటి టోకెన్‌లు మరియు ఎన్‌కోడర్ అవుట్‌పుట్ ఆధారంగా తదుపరి టెక్స్ట్ టోకెన్‌ను అంచనా వేయడానికి శిక్షణ పొందింది. డీకోడర్ ఇన్‌పుట్ ప్రారంభంలో ప్రత్యేక టోకెన్‌లు ట్రాన్స్‌క్రిప్షన్, అనువాదం, లేదా భాషా గుర్తింపు వంటి నిర్దిష్ట పనుల వైపు మోడల్‌ను నడిపించడానికి ఉపయోగించబడతాయి. -Whisper was pretrained on a massive and diverse dataset of 680,000 hours of labeled audio data collected from the web. This large-scale, weakly supervised pretraining is the key to its strong zero-shot performance across many languages and tasks. +Whisper వెబ్ నుండి సేకరించిన 680,000 గంటల లేబుల్ చేయబడిన ఆడియో డేటా యొక్క భారీ మరియు విభిన్న డేటాసెట్‌పై ముందే శిక్షణ పొందింది. ఈ భారీ-స్థాయి, బలహీనంగా పర్యవేక్షించబడిన ప్రీ-ట్రైనింగ్ దాని బలమైన జీరో-షాట్ పనితీరుకు అనేక భాషలు మరియు పనులలో కీలకం. -Now that Whisper is pretrained, you can use it directly for zero-shot inference or finetune it on your data for improved performance on specific tasks like automatic speech recognition or speech translation! +ఇప్పుడు Whisper ముందే శిక్షణ పొందింది, మీరు దానిని జీరో-షాట్ ఇన్ఫరెన్స్ కోసం నేరుగా ఉపయోగించవచ్చు లేదా ఆటోమేటిక్ స్పీచ్ రికగ్నిషన్ లేదా స్పీచ్ ట్రాన్స్‌లేషన్ వంటి నిర్దిష్ట పనులపై మెరుగైన పనితీరు కోసం మీ డేటాపై ఫైన్‌ట్యూన్ చేయవచ్చు! -The key innovation in Whisper is its training on an unprecedented scale of diverse, weakly supervised audio data from the internet. This allows it to generalize remarkably well to different languages, accents, and tasks without task-specific finetuning. +Whisperలోని కీలకమైన ఆవిష్కరణ దాని శిక్షణ, ఇది ఇంటర్నెట్ నుండి అపూర్వమైన స్థాయిలో విభిన్న, బలహీనంగా పర్యవేక్షించబడిన ఆడియో డేటాపై జరిగింది. ఇది పని-నిర్దిష్ట ఫైన్‌ట్యూనింగ్ లేకుండా విభిన్న భాషలు, యాసలు మరియు పనులకు అసాధారణంగా బాగా సాధారణీకరించడానికి అనుమతిస్తుంది. -### Automatic speech recognition +### ఆటోమేటిక్ స్పీచ్ రికగ్నిషన్ -To use the pretrained model for automatic speech recognition, you leverage its full encoder-decoder structure. The encoder processes the audio input, and the decoder autoregressively generates the transcript token by token. When fine-tuning, the model is typically trained using a standard sequence-to-sequence loss (like cross-entropy) to predict the correct text tokens based on the audio input. +ఆటోమేటిక్ స్పీచ్ రికగ్నిషన్ కోసం ముందే శిక్షణ పొందిన మోడల్‌ను ఉపయోగించడానికి, మీరు దాని పూర్తి ఎన్‌కోడర్-డీకోడర్ నిర్మాణాన్ని ఉపయోగించుకుంటారు. ఎన్‌కోడర్ ఆడియో ఇన్‌పుట్‌ను ప్రాసెస్ చేస్తుంది, మరియు డీకోడర్ ట్రాన్స్‌క్రిప్ట్‌ను టోకెన్ ద్వారా టోకెన్ ఆటోరిగ్రెసివ్‌గా ఉత్పత్తి చేస్తుంది. ఫైన్-ట్యూనింగ్ చేసేటప్పుడు, ఆడియో ఇన్‌పుట్ ఆధారంగా సరైన టెక్స్ట్ టోకెన్‌లను అంచనా వేయడానికి మోడల్ సాధారణంగా ఒక ప్రామాణిక సీక్వెన్స్-టు-సీక్వెన్స్ నష్టాన్ని (క్రాస్-ఎంట్రోపీ వంటివి) ఉపయోగించి శిక్షణ పొందుతుంది. -The easiest way to use a fine-tuned model for inference is within a `pipeline`. +ఇన్ఫరెన్స్ కోసం ఫైన్-ట్యూన్ చేసిన మోడల్‌ను ఉపయోగించడానికి సులభమైన మార్గం `pipeline` లోపల. ```python from transformers import pipeline @@ -212,52 +220,51 @@ transcriber("https://huggingface.co/datasets/Narsil/asr_dummy/resolve/main/mlk.f # Output: {'text': ' I have a dream that one day this nation will rise up and live out the true meaning of its creed.'} ``` -Ready to try your hand at automatic speech recognition? Check out our complete [automatic speech recognition guide](https://huggingface.co/docs/transformers/tasks/asr) to learn how to finetune Whisper and use it for inference! +ఆటోమేటిక్ స్పీచ్ రికగ్నిషన్‌లో మీ నైపుణ్యాన్ని ప్రయత్నించడానికి సిద్ధంగా ఉన్నారా? Whisperను ఫైన్‌ట్యూన్ చేయడం మరియు దానిని ఇన్ఫరెన్స్ కోసం ఉపయోగించడం ఎలాగో తెలుసుకోవడానికి మా పూర్తి [automatic speech recognition guide](https://huggingface.co/docs/transformers/tasks/asr)ను చూడండి! -### Computer vision +### కంప్యూటర్ విజన్ -Now let's move on to computer vision tasks, which deal with understanding and interpreting visual information from images or videos. +ఇప్పుడు మనం కంప్యూటర్ విజన్ పనులకు వెళ్దాం, ఇవి చిత్రాలు లేదా వీడియోల నుండి దృశ్య సమాచారాన్ని అర్థం చేసుకోవడం మరియు వ్యాఖ్యానించడంతో వ్యవహరిస్తాయి. -There are two ways to approach computer vision tasks: +కంప్యూటర్ విజన్ పనులను సంప్రదించడానికి రెండు మార్గాలు ఉన్నాయి: -1. Split an image into a sequence of patches and process them in parallel with a Transformer. -2. Use a modern CNN, like [ConvNeXT](https://huggingface.co/docs/transformers/model_doc/convnext), which relies on convolutional layers but adopts modern network designs. +1. ఒక చిత్రాన్ని ప్యాచ్‌ల క్రమంగా విభజించి మరియు వాటిని ఒక Transformerతో సమాంతరంగా ప్రాసెస్ చేయండి. +2. [ConvNeXT](https://huggingface.co/docs/transformers/model_doc/convnext) వంటి ఆధునిక CNNను ఉపయోగించండి, ఇది కన్వల్యూషనల్ లేయర్‌లపై ఆధారపడుతుంది కానీ ఆధునిక నెట్‌వర్క్ డిజైన్‌లను అనుసరిస్తుంది. -A third approach mixes Transformers with convolutions (for example, [Convolutional Vision Transformer](https://huggingface.co/docs/transformers/model_doc/cvt) or [LeViT](https://huggingface.co/docs/transformers/model_doc/levit)). We won't discuss those because they just combine the two approaches we examine here. +మూడవ విధానం Transformersను కన్వల్యూషన్‌లతో మిళితం చేస్తుంది (ఉదాహరణకు, [Convolutional Vision Transformer](https://huggingface.co/docs/transformers/model_doc/cvt) లేదా [LeViT](https://huggingface.co/docs/transformers/model_doc/levit)). మనం వాటిని చర్చించము ఎందుకంటే అవి ఇక్కడ మనం పరిశీలించే రెండు విధానాలను మిళితం చేస్తాయి. -ViT and ConvNeXT are commonly used for image classification, but for other vision tasks like object detection, segmentation, and depth estimation, we'll look at DETR, Mask2Former and GLPN, respectively; these models are better suited for those tasks. +ViT మరియు ConvNeXT సాధారణంగా ఇమేజ్ వర్గీకరణ కోసం ఉపయోగించబడతాయి, కానీ వస్తువు గుర్తింపు, సెగ్మెంటేషన్, మరియు డెప్త్ ఎస్టిమేషన్ వంటి ఇతర దృష్టి పనుల కోసం, మనం వరుసగా DETR, Mask2Former మరియు GLPNలను పరిశీలిస్తాము; ఈ మోడల్స్ ఆ పనులకు బాగా సరిపోతాయి. -### Image classification +### ఇమేజ్ వర్గీకరణ -Image classification is one of the fundamental computer vision tasks. Let's see how different model architectures approach this problem. +ఇమేజ్ వర్గీకరణ అనేది ప్రాథమిక కంప్యూటర్ విజన్ పనులలో ఒకటి. వివిధ మోడల్ ఆర్కిటెక్చర్లు ఈ సమస్యను ఎలా సంప్రదిస్తాయో చూద్దాం. -ViT and ConvNeXT can both be used for image classification; the main difference is that ViT uses an attention mechanism while ConvNeXT uses convolutions. +ViT మరియు ConvNeXT రెండూ ఇమేజ్ వర్గీకరణ కోసం ఉపయోగించబడతాయి; ప్రధాన వ్యత్యాసం ఏమిటంటే ViT ఒక అటెన్షన్ మెకానిజంను ఉపయోగిస్తుంది, అయితే ConvNeXT కన్వల్యూషన్‌లను ఉపయోగిస్తుంది. -[ViT](https://huggingface.co/docs/transformers/model_doc/vit) replaces convolutions entirely with a pure Transformer architecture. If you're familiar with the original Transformer, then you're already most of the way toward understanding ViT. +[ViT](https://huggingface.co/docs/transformers/model_doc/vit) కన్వల్యూషన్‌లను పూర్తిగా ఒక స్వచ్ఛమైన Transformer ఆర్కిటెక్చర్‌తో భర్తీ చేస్తుంది. మీరు అసలు Transformerతో పరిచయం ఉంటే, మీరు ఇప్పటికే ViTను అర్థం చేసుకోవడానికి చాలా దూరం వచ్చారు.
- +
-The main change ViT introduced was in how images are fed to a Transformer: - -1. An image is split into square non-overlapping patches, each of which gets turned into a vector or *patch embedding*. The patch embeddings are generated from a convolutional 2D layer which creates the proper input dimensions (which for a base Transformer is 768 values for each patch embedding). If you had a 224x224 pixel image, you could split it into 196 16x16 image patches. Just like how text is tokenized into words, an image is "tokenized" into a sequence of patches. +ViT ప్రవేశపెట్టిన ప్రధాన మార్పు చిత్రాలు ఒక Transformerకు ఎలా ఇవ్వబడతాయి అనే దానిలో ఉంది: -2. A *learnable embedding* - a special `[CLS]` token - is added to the beginning of the patch embeddings just like BERT. The final hidden state of the `[CLS]` token is used as the input to the attached classification head; other outputs are ignored. This token helps the model learn how to encode a representation of the image. +1. ఒక చిత్రం చదరపు అతివ్యాప్తి లేని ప్యాచ్‌లుగా విభజించబడుతుంది, ప్రతి ఒక్కటి ఒక వెక్టర్ లేదా *ప్యాచ్ ఎంబెడ్డింగ్‌*గా మార్చబడుతుంది. ప్యాచ్ ఎంబెడ్డింగ్‌లు ఒక కన్వల్యూషనల్ 2D లేయర్ నుండి రూపొందించబడతాయి, ఇది సరైన ఇన్‌పుట్ డైమెన్షన్‌లను సృష్టిస్తుంది (ఇది బేస్ Transformer కోసం ప్రతి ప్యాచ్ ఎంబెడ్డింగ్‌కు 768 విలువలు). మీరు ఒక 224x224 పిక్సెల్ చిత్రం కలిగి ఉంటే, మీరు దానిని 196 16x16 ఇమేజ్ ప్యాచ్‌లుగా విభజించవచ్చు. టెక్స్ట్ పదాలుగా టోకనైజ్ చేయబడినట్లే, ఒక చిత్రం ప్యాచ్‌ల క్రమంగా "టోకనైజ్" చేయబడుతుంది. -3. The last thing to add to the patch and learnable embeddings are the *position embeddings* because the model doesn't know how the image patches are ordered. The position embeddings are also learnable and have the same size as the patch embeddings. Finally, all of the embeddings are passed to the Transformer encoder. +2. ఒక _లెర్నబుల్ ఎంబెడ్డింగ్_ - ఒక ప్రత్యేక `[CLS]` టోకెన్ - BERT వలె ప్యాచ్ ఎంబెడ్డింగ్‌ల ప్రారంభంలో జోడించబడుతుంది. `[CLS]` టోకెన్ యొక్క చివరి దాచిన స్థితి జతచేయబడిన వర్గీకరణ హెడ్‌కు ఇన్‌పుట్‌గా ఉపయోగించబడుతుంది; ఇతర అవుట్‌పుట్‌లు విస్మరించబడతాయి. ఈ టోకెన్ మోడల్‌కు చిత్రం యొక్క ప్రాతినిధ్యాన్ని ఎలా ఎన్‌కోడ్ చేయాలో నేర్చుకోవడంలో సహాయపడుతుంది. -4. The output, specifically only the output with the `[CLS]` token, is passed to a multilayer perceptron head (MLP). ViT's pretraining objective is simply classification. Like other classification heads, the MLP head converts the output into logits over the class labels and calculates the cross-entropy loss to find the most likely class. +3. ప్యాచ్ మరియు లెర్నబుల్ ఎంబెడ్డింగ్‌లకు జోడించాల్సిన చివరి విషయం _పొజిషన్ ఎంబెడ్డింగ్‌లు_ ఎందుకంటే మోడల్‌కు ఇమేజ్ ప్యాచ్‌లు ఎలా ఆర్డర్ చేయబడ్డాయో తెలియదు. పొజిషన్ ఎంబెడ్డింగ్‌లు కూడా లెర్నబుల్ మరియు ప్యాచ్ ఎంబెడ్డింగ్‌ల వలె అదే పరిమాణాన్ని కలిగి ఉంటాయి. చివరగా, అన్ని ఎంబెడ్డింగ్‌లు Transformer ఎన్‌కోడర్‌కు పంపబడతాయి. -Ready to try your hand at image classification? Check out our complete [image classification guide](https://huggingface.co/docs/transformers/tasks/image_classification) to learn how to fine-tune ViT and use it for inference! +4. అవుట్‌పుట్, ప్రత్యేకంగా `[CLS]` టోకెన్‌తో ఉన్న అవుట్‌పుట్ మాత్రమే, ఒక మల్టీలేయర్ పెర్సెప్ట్రాన్ హెడ్ (MLP)కు పంపబడుతుంది. ViT యొక్క ప్రీ-ట్రైనింగ్ లక్ష్యం కేవలం వర్గీకరణ. ఇతర వర్గీకరణ హెడ్‌ల వలె, MLP హెడ్ అవుట్‌పుట్‌ను తరగతి లేబుల్స్‌పై లాజిట్స్‌గా మార్చి మరియు అత్యంత సంభావ్య తరగతిని కనుగొనడానికి క్రాస్-ఎంట్రోపీ నష్టాన్ని లెక్కిస్తుంది. +ఇమేజ్ వర్గీకరణలో మీ నైపుణ్యాన్ని ప్రయత్నించడానికి సిద్ధంగా ఉన్నారా? ViTను ఫైన్-ట్యూన్ చేయడం మరియు దానిని ఇన్ఫరెన్స్ కోసం ఉపయోగించడం ఎలాగో తెలుసుకోవడానికి మా పూర్తి [image classification guide](https://huggingface.co/docs/transformers/tasks/image_classification)ను చూడండి! -Notice the parallel between ViT and BERT: both use a special token ([CLS]) to capture the overall representation, both add position information to their embeddings, and both use a Transformer encoder to process the sequence of tokens/patches. +ViT మరియు BERT మధ్య సమాంతరాన్ని గమనించండి: రెండూ మొత్తం ప్రాతినిధ్యాన్ని సంగ్రహించడానికి ఒక ప్రత్యేక టోకెన్ ([CLS])ను ఉపయోగిస్తాయి, రెండూ వాటి ఎంబెడ్డింగ్‌లకు స్థాన సమాచారాన్ని జోడిస్తాయి, మరియు రెండూ టోకెన్‌లు/ప్యాచ్‌ల క్రమాన్ని ప్రాసెస్ చేయడానికి ఒక Transformer ఎన్‌కోడర్‌ను ఉపయోగిస్తాయి. diff --git a/chapters/te/chapter1/6.mdx b/chapters/te/chapter1/6.mdx index e540c8624..d9939b20b 100644 --- a/chapters/te/chapter1/6.mdx +++ b/chapters/te/chapter1/6.mdx @@ -1,134 +1,130 @@ - + -# Transformer Architectures[[transformer-architectures]] +# ట్రాన్స్‌ఫార్మర్ ఆర్కిటెక్చర్లు[[transformer-architectures]] -In the previous sections, we introduced the general Transformer architecture and explored how these models can solve various tasks. Now, let's take a closer look at the three main architectural variants of Transformer models and understand when to use each one. Then, we looked at how those architectures are applied to different language tasks. - -In this section, we're going to dive deeper into the three main architectural variants of Transformer models and understand when to use each one. +మునుపటి విభాగాలలో, మేము సాధారణ Transformer ఆర్కిటెక్చర్‌ను పరిచయం చేసాము మరియు ఈ నమూనాలు వివిధ పనులను ఎలా పరిష్కరించగలవో అన్వేషించాము. ఇప్పుడు, Transformer నమూనాల యొక్క మూడు ప్రధాన నిర్మాణ వైవిధ్యాలను నిశితంగా పరిశీలిద్దాం మరియు ప్రతి ఒక్కటి ఎప్పుడు ఉపయోగించాలో అర్థం చేసుకుందాం. ఆపై, ఆ నిర్మాణాలు వేర్వేరు భాషా పనులకు ఎలా వర్తింపజేయబడతాయో చూశాము. +ఈ విభాగంలో, మేము Transformer నమూనాల యొక్క మూడు ప్రధాన నిర్మాణ వైవిధ్యాలను లోతుగా పరిశీలించబోతున్నాము మరియు ప్రతి ఒక్కటి ఎప్పుడు ఉపయోగించాలో అర్థం చేసుకుంటాము. -Remember that most Transformer models use one of three architectures: encoder-only, decoder-only, or encoder-decoder (sequence-to-sequence). Understanding these differences will help you choose the right model for your specific task. +చాలా Transformer నమూనాలు మూడు నిర్మాణాలలో ఒకదాన్ని ఉపయోగిస్తాయని గుర్తుంచుకోండి: ఎన్‌కోడర్-మాత్రమే, డీకోడర్-మాత్రమే లేదా ఎన్‌కోడర్-డీకోడర్ (సీక్వెన్స్-టు-సీక్వెన్స్). ఈ తేడాలను అర్థం చేసుకోవడం మీ నిర్దిష్ట పనికి సరైన నమూనాను ఎంచుకోవడంలో మీకు సహాయపడుతుంది. -## Encoder models[[encoder-models]] +## ఎన్‌కోడర్ నమూనాలు[[encoder-models]] -Encoder models use only the encoder of a Transformer model. At each stage, the attention layers can access all the words in the initial sentence. These models are often characterized as having "bi-directional" attention, and are often called *auto-encoding models*. +ఎన్‌కోడర్ నమూనాలు Transformer నమూనా యొక్క ఎన్‌కోడర్‌ను మాత్రమే ఉపయోగిస్తాయి. ప్రతి దశలో, శ్రద్ధా పొరలు ప్రారంభ వాక్యంలోని అన్ని పదాలను యాక్సెస్ చేయగలవు. ఈ నమూనాలు తరచుగా "ద్విదిశాత్మక" శ్రద్ధను కలిగి ఉన్నాయని వర్గీకరించబడతాయి మరియు తరచుగా ఆటో-ఎన్‌కోడింగ్ నమూనాలు అని పిలువబడతాయి. -The pretraining of these models usually revolves around somehow corrupting a given sentence (for instance, by masking random words in it) and tasking the model with finding or reconstructing the initial sentence. +ఈ నమూనాల యొక్క ప్రీ-ట్రైనింగ్ సాధారణంగా ఇచ్చిన వాక్యాన్ని ఏదో ఒక విధంగా పాడు చేయడం (ఉదాహరణకు, యాదృచ్ఛిక పదాలను మాస్క్ చేయడం ద్వారా) మరియు ప్రారంభ వాక్యాన్ని కనుగొనడం లేదా పునర్నిర్మించడం నమూనా యొక్క పని. -Encoder models are best suited for tasks requiring an understanding of the full sentence, such as sentence classification, named entity recognition (and more generally word classification), and extractive question answering. +వాక్య వర్గీకరణ, పేరున్న ఎంటిటీ గుర్తింపు (మరియు సాధారణంగా పద వర్గీకరణ), మరియు సంగ్రాహక ప్రశ్న-సమాధానం వంటి పూర్తి వాక్యం యొక్క అవగాహన అవసరమయ్యే పనులకు ఎన్‌కోడర్ నమూనాలు ఉత్తమంగా సరిపోతాయి. -As we saw in [How 🤗 Transformers solve tasks](/chapter1/5), encoder models like BERT excel at understanding text because they can look at the entire context in both directions. This makes them perfect for tasks where comprehension of the whole input is important. +[How 🤗 Transformers solve tasks](/chapter1/5), లో మనం చూసినట్లుగా, BERT వంటి ఎన్‌కోడర్ నమూనాలు టెక్స్ట్‌ను అర్థం చేసుకోవడంలో రాణిస్తాయి ఎందుకంటే అవి రెండు దిశలలోని మొత్తం సందర్భాన్ని చూడగలవు. ఇది మొత్తం ఇన్‌పుట్ యొక్క గ్రహణశక్తి ముఖ్యమైన పనులకు వాటిని పరిపూర్ణంగా చేస్తుంది. -Representatives of this family of models include: +ఈ నమూనాల కుటుంబం యొక్క ప్రతినిధులు: - [BERT](https://huggingface.co/docs/transformers/model_doc/bert) - [DistilBERT](https://huggingface.co/docs/transformers/model_doc/distilbert) - [ModernBERT](https://huggingface.co/docs/transformers/en/model_doc/modernbert) -## Decoder models[[decoder-models]] +## డీకోడర్ నమూనాలు[[decoder-models]] -Decoder models use only the decoder of a Transformer model. At each stage, for a given word the attention layers can only access the words positioned before it in the sentence. These models are often called *auto-regressive models*. +డీకోడర్ నమూనాలు Transformer నమూనా యొక్క డీకోడర్‌ను మాత్రమే ఉపయోగిస్తాయి. ప్రతి దశలో, ఇచ్చిన పదం కోసం శ్రద్ధా పొరలు వాక్యంలో దాని ముందు ఉన్న పదాలను మాత్రమే యాక్సెస్ చేయగలవు. ఈ నమూనాలను తరచుగా ఆటో-రిగ్రెసివ్ నమూనాలు అని పిలుస్తారు. -The pretraining of decoder models usually revolves around predicting the next word in the sentence. +డీకోడర్ నమూనాల యొక్క ప్రీ-ట్రైనింగ్ సాధారణంగా వాక్యంలోని తదుపరి పదాన్ని అంచనా వేయడం చుట్టూ తిరుగుతుంది. -These models are best suited for tasks involving text generation. +ఈ నమూనాలు టెక్స్ట్ జనరేషన్ వంటి పనులకు ఉత్తమంగా సరిపోతాయి. -Decoder models like GPT are designed to generate text by predicting one token at a time. As we explored in [How 🤗 Transformers solve tasks](/chapter1/5), they can only see previous tokens, which makes them excellent for creative text generation but less ideal for tasks requiring bidirectional understanding. +GPT వంటి డీకోడర్ నమూనాలు ఒక సమయంలో ఒక టోకెన్‌ను అంచనా వేయడం ద్వారా టెక్స్ట్‌ను ఉత్పత్తి చేయడానికి రూపొందించబడ్డాయి. [How 🤗 Transformers solve tasks](/chapter1/5) లో మనం అన్వేషించినట్లుగా, అవి మునుపటి టోకెన్‌లను మాత్రమే చూడగలవు, ఇది సృజనాత్మక టెక్స్ట్ జనరేషన్‌కు వాటిని అద్భుతంగా చేస్తుంది కానీ ద్విదిశాత్మక అవగాహన అవసరమయ్యే పనులకు అంత ఆదర్శవంతంగా ఉండదు. -Representatives of this family of models include: +ఈ నమూనాల కుటుంబం యొక్క ప్రతినిధులు: - [Hugging Face SmolLM Series](https://huggingface.co/HuggingFaceTB/SmolLM2-1.7B-Instruct) - [Meta's Llama Series](https://huggingface.co/docs/transformers/en/model_doc/llama4) - [Google's Gemma Series](https://huggingface.co/docs/transformers/main/en/model_doc/gemma3) - [DeepSeek's V3](https://huggingface.co/deepseek-ai/DeepSeek-V3) -### Modern Large Language Models (LLMs) +### ఆధునిక లార్జ్ లాంగ్వేజ్ మోడల్స్ (LLMలు) -Most modern Large Language Models (LLMs) use the decoder-only architecture. These models have grown dramatically in size and capabilities over the past few years, with some of the largest models containing hundreds of billions of parameters. +చాలా ఆధునిక Large Language Models (LLMలు) డీకోడర్-మాత్రమే నిర్మాణాన్ని ఉపయోగిస్తాయి. ఈ నమూనాలు గత కొన్ని సంవత్సరాలుగా పరిమాణం మరియు సామర్థ్యాలలో నాటకీయంగా పెరిగాయి, అతిపెద్ద నమూనాలలో కొన్ని వందల బిలియన్ల పారామితులు ఉన్నాయి. -Modern LLMs are typically trained in two phases: -1. **Pretraining**: The model learns to predict the next token on vast amounts of text data -2. **Instruction tuning**: The model is fine-tuned to follow instructions and generate helpful responses +ఆధునిక LLMలు సాధారణంగా రెండు దశలలో శిక్షణ పొందుతాయి: -This approach has led to models that can understand and generate human-like text across a wide range of topics and tasks. +1. **ప్రీ-ట్రైనింగ్**: నమూనా విస్తారమైన టెక్స్ట్ డేటాపై తదుపరి టోకెన్‌ను అంచనా వేయడం నేర్చుకుంటుంది +2. **ఇన్‌స్ట్రక్షన్ ట్యూనింగ్**: నమూనా సూచనలను అనుసరించడానికి మరియు సహాయకరమైన ప్రతిస్పందనలను ఉత్పత్తి చేయడానికి ఫైన్-ట్యూన్ చేయబడుతుంది -#### Key capabilities of modern LLMs +ఈ విధానం అనేక రకాల అంశాలు మరియు పనులలో మానవ-లాంటి టెక్స్ట్‌ను అర్థం చేసుకుని, ఉత్పత్తి చేయగల నమూనాలకు దారితీసింది. -Modern decoder-based LLMs have demonstrated impressive capabilities: +#### ఆధునిక LLMల యొక్క ముఖ్య సామర్థ్యాలు -| Capability | Description | Example | -|------------|-------------|---------| -| Text generation | Creating coherent and contextually relevant text | Writing essays, stories, or emails | -| Summarization | Condensing long documents into shorter versions | Creating executive summaries of reports | -| Translation | Converting text between languages | Translating English to Spanish | -| Question answering | Providing answers to factual questions | "What is the capital of France?" | -| Code generation | Writing or completing code snippets | Creating a function based on a description | -| Reasoning | Working through problems step by step | Solving math problems or logical puzzles | -| Few-shot learning | Learning from a few examples in the prompt | Classifying text after seeing just 2-3 examples | +ఆధునిక డీకోడర్-ఆధారిత LLMలు ఆకట్టుకునే సామర్థ్యాలను ప్రదర్శించాయి: -You can experiment with decoder-based LLMs directly in your browser via model repo pages on the Hub. Here's an an example with the classic [GPT-2](https://huggingface.co/openai-community/gpt2) (OpenAI's finest open source model!): +| సామర్థ్యం | వివరణ | ఉదాహరణ | +| -------------------- | --------------------------------------------------- | -------------------------------------------------------- | +| టెక్స్ట్ జనరేషన్ | పొందికైన మరియు సందర్భోచితమైన టెక్స్ట్‌ను సృష్టించడం | వ్యాసాలు, కథలు లేదా ఈమెయిల్‌లు రాయడం | +| సారాంశీకరణ | పొడవైన పత్రాలను చిన్న వెర్షన్‌లుగా కుదించడం | నివేదికల కార్యనిర్వాహక సారాంశాలను సృష్టించడం | +| అనువాదం | భాషల మధ్య టెక్స్ట్‌ను మార్చడం | ఇంగ్లీష్‌ను స్పానిష్‌లోకి అనువదించడం | +| ప్రశ్న-సమాధానం | వాస్తవ ప్రశ్నలకు సమాధానాలు అందించడం | "ఫ్రాన్స్ రాజధాని ఏది?" | +| కోడ్ జనరేషన్ | కోడ్ స్నిప్పెట్‌లను రాయడం లేదా పూర్తి చేయడం | వివరణ ఆధారంగా ఒక ఫంక్షన్‌ను సృష్టించడం | +| తార్కికం (Reasoning) | సమస్యలను దశలవారీగా పరిష్కరించడం | గణిత సమస్యలు లేదా తార్కిక పజిల్స్‌ను పరిష్కరించడం | +| ఫ్యూ-షాట్ లెర్నింగ్ | ప్రాంప్ట్‌లోని కొన్ని ఉదాహరణల నుండి నేర్చుకోవడం | కేవలం 2-3 ఉదాహరణలు చూసిన తర్వాత టెక్స్ట్‌ను వర్గీకరించడం | + +మీరు బ్రౌజర్‌లో నేరుగా హబ్‌లోని నమూనా రిపో పేజీల ద్వారా డీకోడర్-ఆధారిత LLMలతో ప్రయోగాలు చేయవచ్చు. ఇక్కడ క్లాసిక్ [GPT-2](https://huggingface.co/openai-community/gpt2) (OpenAI యొక్క అత్యుత్తమ ఓపెన్ సోర్స్ నమూనా!) తో ఒక ఉదాహరణ ఉంది: -## Sequence-to-sequence models[[sequence-to-sequence-models]] +## సీక్వెన్స్-టు-సీక్వెన్స్ నమూనాలు[[sequence-to-sequence-models]] -Encoder-decoder models (also called *sequence-to-sequence models*) use both parts of the Transformer architecture. At each stage, the attention layers of the encoder can access all the words in the initial sentence, whereas the attention layers of the decoder can only access the words positioned before a given word in the input. +ఎన్‌కోడర్-డీకోడర్ నమూనాలు (సీక్వెన్స్-టు-సీక్వెన్స్ నమూనాలు అని కూడా పిలుస్తారు) Transformer నిర్మాణం యొక్క రెండు భాగాలను ఉపయోగిస్తాయి. ప్రతి దశలో, ఎన్‌కోడర్ యొక్క శ్రద్ధా పొరలు ప్రారంభ వాక్యంలోని అన్ని పదాలను యాక్సెస్ చేయగలవు, అయితే డీకోడర్ యొక్క శ్రద్ధా పొరలు ఇన్‌పుట్‌లో ఇచ్చిన పదం ముందు ఉన్న పదాలను మాత్రమే యాక్సెస్ చేయగలవు. -The pretraining of these models can take different forms, but it often involves reconstructing a sentence for which the input has been somehow corrupted (for instance by masking random words). The pretraining of the T5 model consists of replacing random spans of text (that can contain several words) with a single mask special token, and the task is then to predict the text that this mask token replaces. +ఈ నమూనాల యొక్క ప్రీ-ట్రైనింగ్ వివిధ రూపాలను తీసుకోవచ్చు, కానీ ఇది తరచుగా ఇన్‌పుట్ ఏదో ఒక విధంగా పాడు చేయబడిన వాక్యాన్ని పునర్నిర్మించడం (ఉదాహరణకు యాదృచ్ఛిక పదాలను మాస్క్ చేయడం ద్వారా) ఉంటుంది. T5 నమూనా యొక్క ప్రీ-ట్రైనింగ్ యాదృచ్ఛిక టెక్స్ట్ స్పాన్‌లను (ఇవి అనేక పదాలను కలిగి ఉండవచ్చు) ఒకే మాస్క్ ప్రత్యేక టోకెన్‌తో భర్తీ చేయడం, మరియు అప్పుడు ఈ మాస్క్ టోకెన్ భర్తీ చేసే టెక్స్ట్‌ను అంచనా వేయడం పని. -Sequence-to-sequence models are best suited for tasks revolving around generating new sentences depending on a given input, such as summarization, translation, or generative question answering. +సీక్వెన్స్-టు-సీక్వెన్స్ నమూనాలు సారాంశీకరణ, అనువాదం, లేదా సృజనాత్మక ప్రశ్న-సమాధానం వంటి ఇచ్చిన ఇన్‌పుట్‌పై ఆధారపడి కొత్త వాక్యాలను ఉత్పత్తి చేయడం చుట్టూ తిరిగే పనులకు ఉత్తమంగా సరిపోతాయి. -As we saw in [How 🤗 Transformers solve tasks](/chapter1/5), encoder-decoder models like BART and T5 combine the strengths of both architectures. The encoder provides deep bidirectional understanding of the input, while the decoder generates appropriate output text. This makes them perfect for tasks that transform one sequence into another, like translation or summarization. +[How 🤗 Transformers solve tasks](/chapter1/5),లో మనం చూసినట్లుగా, BART మరియు T5 వంటి ఎన్‌కోడర్-డీకోడర్ నమూనాలు రెండు నిర్మాణాల యొక్క బలాలను మిళితం చేస్తాయి. ఎన్‌కోడర్ ఇన్‌పుట్ యొక్క లోతైన ద్విదిశాత్మక అవగాహనను అందిస్తుంది, అయితే డీకోడర్ తగిన అవుట్‌పుట్ టెక్స్ట్‌ను ఉత్పత్తి చేస్తుంది. ఇది ఒక సీక్వెన్స్‌ను మరొకదానికి మార్చే పనులకు, అనువాదం లేదా సారాంశీకరణ వంటి వాటికి వాటిని పరిపూర్ణంగా చేస్తుంది. -### Practical applications +### ఆచరణాత్మక అనువర్తనాలు -Sequence-to-sequence models excel at tasks that require transforming one form of text into another while preserving meaning. Some practical applications include: +సీక్వెన్స్-టు-సీక్వెన్స్ నమూనాలు అర్థాన్ని కాపాడుకుంటూ ఒక రూపంలోని టెక్స్ట్‌ను మరొక రూపంలోకి మార్చాల్సిన పనులలో రాణిస్తాయి. కొన్ని ఆచరణాత్మక అనువర్తనాలు: -| Application | Description | Example Model | -|-------------|-------------|---------------| -| Machine translation | Converting text between languages | Marian, T5 | -| Text summarization | Creating concise summaries of longer texts | BART, T5 | -| Data-to-text generation | Converting structured data into natural language | T5 | -| Grammar correction | Fixing grammatical errors in text | T5 | -| Question answering | Generating answers based on context | BART, T5 | +| అనువర్తనం | వివరణ | ఉదాహరణ నమూనా | +| ------------------------ | ----------------------------------------------- | ------------ | +| యంత్ర అనువాదం | భాషల మధ్య టెక్స్ట్‌ను మార్చడం | Marian, T5 | +| టెక్స్ట్ సారాంశీకరణ | పొడవైన టెక్స్ట్‌ల క్లుప్త సారాంశాలను సృష్టించడం | BART, T5 | +| డేటా-టు-టెక్స్ట్ జనరేషన్ | నిర్మాణాత్మక డేటాను సహజ భాషలోకి మార్చడం | T5 | +| వ్యాకరణ దిద్దుబాటు | టెక్స్ట్‌లోని వ్యాకరణ దోషాలను సరిచేయడం | T5 | -Here's an interactive demo of a sequence-to-sequence model for translation: +ఈ నమూనాల కుటుంబం యొక్క ప్రతినిధులు: Representatives of this family of models include: @@ -138,87 +134,73 @@ Representatives of this family of models include: - [Marian](https://huggingface.co/docs/transformers/model_doc/marian) - [T5](https://huggingface.co/docs/transformers/model_doc/t5) -## Choosing the right architecture[[choosing-the-right-architecture]] +## సరైన నిర్మాణాన్ని ఎంచుకోవడం[[choosing-the-right-architecture]] -When working on a specific NLP task, how do you decide which architecture to use? Here's a quick guide: +ఒక నిర్దిష్ట NLP పనిలో పనిచేస్తున్నప్పుడు, మీరు ఏ నిర్మాణాన్ని ఉపయోగించాలో ఎలా నిర్ణయిస్తారు? ఇక్కడ ఒక శీఘ్ర మార్గదర్శి ఉంది: -| Task | Suggested Architecture | Examples | -|------|------------------------|----------| -| Text classification (sentiment, topic) | Encoder | BERT, RoBERTa | -| Text generation (creative writing) | Decoder | GPT, LLaMA | -| Translation | Encoder-Decoder | T5, BART | -| Summarization | Encoder-Decoder | BART, T5 | -| Named entity recognition | Encoder | BERT, RoBERTa | -| Question answering (extractive) | Encoder | BERT, RoBERTa | -| Question answering (generative) | Encoder-Decoder or Decoder | T5, GPT | -| Conversational AI | Decoder | GPT, LLaMA | +| పని | సూచించిన నిర్మాణం | ఉదాహరణలు | +| ------------------------------------ | -------------------------- | ------------- | +| టెక్స్ట్ వర్గీకరణ (భావోద్వేగం, అంశం) | Encoder | BERT, RoBERTa | +| టెక్స్ట్ ఉత్పత్తి (సృజనాత్మక రచన) | Decoder | GPT, LLaMA | +| అనువాదం | Encoder-Decoder | T5, BART | +| సంక్షిప్తీకరణ | Encoder-Decoder | BART, T5 | +| పేరుతో గుర్తింపు | Encoder | BERT, RoBERTa | +| ప్రశ్నలకు సమాధానం (ఎక్స్‌ట్రాక్టివ్) | Encoder | BERT, RoBERTa | +| ప్రశ్నలకు సమాధానం (జనరేటివ్) | Encoder-Decoder or Decoder | T5, GPT | +| సంభాషణ AI | Decoder | GPT, LLaMA | - + -When in doubt about which model to use, consider: +ఏ నమూనాను ఉపయోగించాలో సందేహంలో ఉన్నప్పుడు, పరిగణించండి: -1. What kind of understanding does your task need? (Bidirectional or unidirectional) -2. Are you generating new text or analyzing existing text? -3. Do you need to transform one sequence into another? +1. మీ పనికి ఎలాంటి అవగాహన అవసరం? (ద్విదిశాత్మక లేదా ఏకదిశాత్మక) +2. మీరు కొత్త టెక్స్ట్‌ను ఉత్పత్తి చేస్తున్నారా లేదా ఉన్న టెక్స్ట్‌ను విశ్లేషిస్తున్నారా? +3. మీరు ఒక సీక్వెన్స్‌ను మరొకదానికి మార్చాల్సిన అవసరం ఉందా? -The answers to these questions will guide you toward the right architecture. +ఈ ప్రశ్నలకు సమాధానాలు మిమ్మల్ని సరైన నిర్మాణం వైపు నడిపిస్తాయి. - + -## The evolution of LLMs +## LLMల పరిణామం -Large Language Models have evolved rapidly in recent years, with each generation bringing significant improvements in capabilities. +పెద్ద భాషా నమూనాలు ఇటీవలి సంవత్సరాలలో వేగంగా అభివృద్ధి చెందాయి, ప్రతి తరం సామర్థ్యాలలో గణనీయమైన మెరుగుదలలను తీసుకువచ్చింది. -## Attention mechanisms[[attention-mechanisms]] +## అటెన్షన్ మెకానిజమ్స్[[attention-mechanisms]] -Most transformer models use full attention in the sense that the attention matrix is square. It can be a big -computational bottleneck when you have long texts. Longformer and reformer are models that try to be more efficient and -use a sparse version of the attention matrix to speed up training. +చాలా ట్రాన్స్‌ఫార్మర్ నమూనాలు పూర్తి శ్రద్ధను ఉపయోగిస్తాయి, అంటే శ్రద్ధా మాత్రిక చతురస్రాకారంలో ఉంటుంది. మీకు పొడవైన టెక్స్ట్‌లు ఉన్నప్పుడు ఇది ఒక పెద్ద గణన అవరోధంగా ఉంటుంది. లాంగ్‌ఫార్మర్ మరియు రిఫార్మర్ అనే నమూనాలు మరింత సమర్థవంతంగా ఉండటానికి ప్రయత్నిస్తాయి మరియు శిక్షణను వేగవంతం చేయడానికి శ్రద్ధా మాత్రిక యొక్క స్పాన్ వెర్షన్‌ను ఉపయోగిస్తాయి. -Standard attention mechanisms have a computational complexity of O(n²), where n is the sequence length. This becomes problematic for very long sequences. The specialized attention mechanisms below help address this limitation. +ప్రామాణిక శ్రద్ధా యంత్రాంగాలు O(n²) యొక్క గణన సంక్లిష్టతను కలిగి ఉంటాయి, ఇక్కడ n సీక్వెన్స్ పొడవు. చాలా పొడవైన సీక్వెన్స్‌లకు ఇది సమస్యాత్మకంగా మారుతుంది. కింద పేర్కొన్న ప్రత్యేక శ్రద్ధా యంత్రాంగాలు ఈ పరిమితిని పరిష్కరించడంలో సహాయపడతాయి. -### LSH attention +### LSH అటెన్షన్ -[Reformer](https://huggingface.co/docs/transformers/model_doc/reformer) uses LSH attention. In the softmax(QK^t), only the biggest elements (in the softmax dimension) of the matrix QK^t are going to give useful contributions. So for each query q in Q, we can consider only -the keys k in K that are close to q. A hash function is used to determine if q and k are close. The attention mask is -modified to mask the current token (except at the first position), because it will give a query and a key equal (so -very similar to each other). Since the hash can be a bit random, several hash functions are used in practice -(determined by a n_rounds parameter) and then are averaged together. +[Reformer](https://huggingface.co/docs/transformers/model_doc/reformer) LSH అటెన్షన్ ఉపయోగిస్తుంది. సాఫ్ట్‌మాక్స్(QK^t)లో, మాత్రిక QK^t యొక్క అతిపెద్ద అంశాలు మాత్రమే (సాఫ్ట్‌మాక్స్ డైమెన్షన్‌లో) ఉపయోగకరమైన సహకారం అందిస్తాయి. కాబట్టి Q లోని ప్రతి క్వెరీ q కోసం, మనం K లో q కు దగ్గరగా ఉన్న కీలను మాత్రమే పరిగణించవచ్చు. q మరియు k దగ్గరగా ఉన్నాయో లేదో నిర్ధారించడానికి ఒక హాష్ ఫంక్షన్ ఉపయోగించబడుతుంది. ప్రస్తుత టోకెన్‌ను మాస్క్ చేయడానికి శ్రద్ధా మాస్క్ సవరించబడింది (మొదటి స్థానంలో తప్ప), ఎందుకంటే ఇది సమానమైన క్వెరీ మరియు కీని ఇస్తుంది (కాబట్టి ఒకదానికొకటి చాలా పోలి ఉంటుంది). హాష్ కొంచెం యాదృచ్ఛికంగా ఉండగలదు కాబట్టి, ఆచరణలో అనేక హాష్ ఫంక్షన్లు ఉపయోగించబడతాయి (n_rounds పారామితి ద్వారా నిర్ధారించబడతాయి) మరియు తరువాత అవి సగటు చేయబడతాయి. -### Local attention +### లోకల్ అటెన్షన్ -[Longformer](https://huggingface.co/docs/transformers/model_doc/longformer) uses local attention: often, the local context (e.g., what are the two tokens to the left and right?) is enough to take action for a given token. Also, by stacking attention layers that have a small -window, the last layer will have a receptive field of more than just the tokens in the window, allowing them to build a -representation of the whole sentence. +[Longformer](https://huggingface.co/docs/transformers/model_doc/longformer) స్థానిక శ్రద్ధను ఉపయోగిస్తుంది: తరచుగా, స్థానిక సందర్భం (ఉదా., ఎడమ మరియు కుడి వైపున ఉన్న రెండు టోకెన్‌లు ఏమిటి?) ఒక నిర్దిష్ట టోకెన్ కోసం చర్య తీసుకోవడానికి సరిపోతుంది. అలాగే, చిన్న విండో ఉన్న శ్రద్ధా పొరలను పేర్చడం ద్వారా, చివరి పొర కేవలం విండోలోని టోకెన్‌ల కంటే ఎక్కువ గ్రహణ క్షేత్రాన్ని కలిగి ఉంటుంది, ఇది మొత్తం వాక్యం యొక్క ప్రాతినిధ్యాన్ని నిర్మించడానికి వీలు కల్పిస్తుంది. -Some preselected input tokens are also given global attention: for those few tokens, the attention matrix can access -all tokens and this process is symmetric: all other tokens have access to those specific tokens (on top of the ones in -their local window). This is shown in Figure 2d of the paper, see below for a sample attention mask: +కొన్ని ముందుగా ఎంచుకున్న ఇన్‌పుట్ టోకెన్‌లకు గ్లోబల్ అటెన్షన్ కూడా ఇవ్వబడుతుంది: ఆ కొన్ని టోకెన్‌ల కోసం, శ్రద్ధా మాత్రిక అన్ని టోకెన్‌లను యాక్సెస్ చేయగలదు మరియు ఈ ప్రక్రియ సుష్టంగా ఉంటుంది: అన్ని ఇతర టోకెన్‌లు ఆ నిర్దిష్ట టోకెన్‌లకు యాక్సెస్ కలిగి ఉంటాయి (వాటి స్థానిక విండోలోని వాటితో పాటు). ఇది పేపర్‌లోని ఫిగర్ 2డిలో చూపబడింది, ఒక నమూనా శ్రద్ధా మాస్క్ కోసం కింద చూడండి:
- +
-Using those attention matrices with less parameters then allows the model to have inputs having a bigger sequence -length. +తక్కువ పారామితులతో ఆ Attention matrix ఉపయోగించడం వలన నమూనా పెద్ద సీక్వెన్స్ పొడవు ఉన్న ఇన్‌పుట్‌లను కలిగి ఉండటానికి వీలు కల్పిస్తుంది. -### Axial positional encodings +### యాక్సియల్ పొజిషనల్ ఎన్‌కోడింగ్స్ -[Reformer](https://huggingface.co/docs/transformers/model_doc/reformer) uses axial positional encodings: in traditional transformer models, the positional encoding -E is a matrix of size \\(l\\) by \\(d\\), \\(l\\) being the sequence length and \\(d\\) the dimension of the -hidden state. If you have very long texts, this matrix can be huge and take way too much space on the GPU. To alleviate -that, axial positional encodings consist of factorizing that big matrix E in two smaller matrices E1 and E2, with -dimensions \\(l_{1} \times d_{1}\\) and \\(l_{2} \times d_{2}\\), such that \\(l_{1} \times l_{2} = l\\) and -\\(d_{1} + d_{2} = d\\) (with the product for the lengths, this ends up being way smaller). The embedding for time -step \\(j\\) in E is obtained by concatenating the embeddings for timestep \\(j \% l1\\) in E1 and \\(j // l1\\) -in E2. +[Reformer](https://huggingface.co/docs/transformers/model_doc/reformer) యాక్సియల్ పొజిషనల్ ఎన్‌కోడింగ్‌లను ఉపయోగిస్తుంది: సాంప్రదాయ ట్రాన్స్‌ఫార్మర్ నమూనాలలో, పొజిషనల్ ఎన్‌కోడింగ్ E అనేది \(l\) బై \(d\) పరిమాణంలో ఒక మాత్రిక, ఇక్కడ \(l\) సీక్వెన్స్ పొడవు మరియు \(d\) దాగి ఉన్న స్థితి యొక్క డైమెన్షన్. మీకు చాలా పొడవైన టెక్స్ట్‌లు ఉంటే, ఈ మాత్రిక చాలా పెద్దదిగా ఉండవచ్చు మరియు GPUలో చాలా ఎక్కువ స్థలాన్ని తీసుకుంటుంది. దానిని తగ్గించడానికి, యాక్సియల్ పొజిషనల్ ఎన్‌కోడింగ్‌లు ఆ పెద్ద మాత్రిక E ని రెండు చిన్న మాత్రికలు E1 మరియు E2 గా విభజించడం, వాటి డైమెన్షన్లు \(l*{1} \times d*{1}\) మరియు \(l*{2} \times d*{2}\), ఇక్కడ \(l*{1} \times l*{2} = l\) మరియు \(d*{1} + d*{2} = d\) (పొడవుల కోసం గుణకారంతో, ఇది చాలా చిన్నదిగా ముగుస్తుంది). E లో సమయ దశ \(j\) కోసం ఎంబెడ్డింగ్ E1 లో సమయ దశ \(j % l1\) మరియు E2 లో \(j // l1\) కోసం ఎంబెడ్డింగ్‌లను కలపడం ద్వారా పొందబడుతుంది. -## Conclusion[[conclusion]] +## ముగింపు[[conclusion]] -In this section, we've explored the three main Transformer architectures and some specialized attention mechanisms. Understanding these architectural differences is crucial for selecting the right model for your specific NLP task. +ఈ విభాగంలో, మేము మూడు ప్రధాన Transformer నిర్మాణాలను మరియు కొన్ని ప్రత్యేక శ్రద్ధా యంత్రాంగాలను అన్వేషించాము. మీ నిర్దిష్ట NLP పని కోసం సరైన నమూనాను ఎంచుకోవడానికి ఈ నిర్మాణ తేడాలను అర్థం చేసుకోవడం చాలా ముఖ్యం. -As we move forward in the course, you'll get hands-on experience with these different architectures and learn how to fine-tune them for your specific needs. In the next section, we'll look at some of the limitations and biases present in these models that you should be aware of when deploying them. \ No newline at end of file +కోర్సులో మనం ముందుకు సాగుతున్నప్పుడు, మీరు ఈ విభిన్న నిర్మాణాలతో ప్రత్యక్ష అనుభవాన్ని పొందుతారు మరియు మీ నిర్దిష్ట అవసరాలకు వాటిని ఎలా ఫైన్-ట్యూన్ చేయాలో నేర్చుకుంటారు. తదుపరి విభాగంలో, మనం ఈ నమూనాలలో ఉన్న కొన్ని పరిమితులు మరియు పక్షపాతాలను పరిశీలిస్తాము, వాటిని అమలు చేస్తున్నప్పుడు మీరు తెలుసుకోవాలి. diff --git a/chapters/te/chapter1/7.mdx b/chapters/te/chapter1/7.mdx index a01a020fb..48991e51f 100644 --- a/chapters/te/chapter1/7.mdx +++ b/chapters/te/chapter1/7.mdx @@ -1,38 +1,48 @@ -# Ungraded quiz[[ungraded-quiz]] +# గ్రేడ్ లేని క్విజ్[[ungraded-quiz]] - + -So far, this chapter has covered a lot of ground! Don't worry if you didn't grasp all the details, but it's to reflect on what you've learned so far with a quiz. +ఇప్పటివరకు, ఈ అధ్యాయం చాలా విషయాలను కవర్ చేసింది! మీరు అన్ని వివరాలను గ్రహించలేకపోయినా చింతించకండి, కానీ క్విజ్‌తో ఇప్పటివరకు మీరు నేర్చుకున్న వాటిని సమీక్షించుకోవడం మంచిది. -This quiz is ungraded, so you can try it as many times as you want. If you struggle with some questions, follow the tips and revisit the material. You'll be quizzed on this material again in the certification exam. +ఈ క్విజ్‌కు గ్రేడ్ లేదు, కాబట్టి మీరు దీన్ని మీకు కావలసినన్ని సార్లు ప్రయత్నించవచ్చు. కొన్ని ప్రశ్నలతో మీరు ఇబ్బంది పడితే, చిట్కాలను అనుసరించి, మెటీరియల్‌ను మళ్ళీ చూడండి. సర్టిఫికేషన్ పరీక్షలో ఈ మెటీరియల్‌పై మిమ్మల్ని మళ్లీ క్విజ్ చేయబడుతుంది. -### 1. Explore the Hub and look for the `roberta-large-mnli` checkpoint. What task does it perform? +### 1. హబ్‌ను అన్వేషించండి మరియు `roberta-large-mnli` చెక్‌పాయింట్ కోసం చూడండి. ఇది ఏ పనిని చేస్తుంది? +Thoughts +Expand to show model's summarized thoughts -roberta-large-mnli page." - }, - { - text: "Text classification", - explain: "More precisely, it classifies if two sentences are logically linked across three labels (contradiction, neutral, entailment) — a task also called natural language inference.", - correct: true - }, - { - text: "Text generation", - explain: "Look again on the roberta-large-mnli page." - } - ]} -/> + + +గ్రేడ్ లేని క్విజ్[[ungraded-quiz]] -### 2. What will the following code return? + + +ఇప్పటివరకు, ఈ అధ్యాయం చాలా విషయాలను కవర్ చేసింది! మీరు అన్ని వివరాలను గ్రహించలేకపోయినా చింతించకండి, కానీ క్విజ్‌తో ఇప్పటివరకు మీరు నేర్చుకున్న వాటిని సమీక్షించుకోవడం మంచిది. + +ఈ క్విజ్‌కు గ్రేడ్ లేదు, కాబట్టి మీరు దీన్ని మీకు కావలసినన్ని సార్లు ప్రయత్నించవచ్చు. కొన్ని ప్రశ్నలతో మీరు ఇబ్బంది పడితే, చిట్కాలను అనుసరించి, మెటీరియల్‌ను మళ్ళీ చూడండి. సర్టిఫికేషన్ పరీక్షలో ఈ మెటీరియల్‌పై మిమ్మల్ని మళ్లీ క్విజ్ చేయబడుతుంది. + +1. హబ్‌ను అన్వేషించండి మరియు roberta-large-mnli చెక్‌పాయింట్ కోసం చూడండి. ఇది ఏ పనిని చేస్తుంది? + roberta-large-mnli page లో మళ్ళీ చూడండి." + }, + { + text: "టెక్స్ట్ వర్గీకరణ", + explain: "మరింత కచ్చితంగా చెప్పాలంటే, ఇది రెండు వాక్యాలు తార్కికంగా మూడు లేబుల్స్‌లో (వైరుధ్యం, తటస్థం, అనుమితి) ఒకదానికొకటి సంబంధం కలిగి ఉన్నాయో లేదో వర్గీకరిస్తుంది — ఈ పనిని natural language inference అని కూడా పిలుస్తారు.", + correct: true + }, + { + text: "టెక్స్ట్ జనరేషన్", + explain: "roberta-large-mnli page లో మళ్ళీ చూడండి." + } + ]} + /> + +### 2. కింది కోడ్ ఏమి తిరిగి ఇస్తుంది?? ```py from transformers import pipeline @@ -42,24 +52,24 @@ ner("My name is Sylvain and I work at Hugging Face in Brooklyn.") ``` sentiment-analysis pipeline." - }, - { - text: "It will return a generated text completing this sentence.", - explain: "This is incorrect — it would be a text-generation pipeline.", - }, - { - text: "It will return the words representing persons, organizations or locations.", - explain: "Furthermore, with grouped_entities=True, it will group together the words belonging to the same entity, like \"Hugging Face\".", - correct: true - } - ]} + choices={[ + { + text: "ఇది ఈ వాక్యం కోసం "positive" లేదా "negative" లేబుల్స్‌తో వర్గీకరణ స్కోర్‌లను తిరిగి ఇస్తుంది.", + explain: "ఇది తప్పు — ఇది sentiment-analysis పైప్‌లైన్ అవుతుంది." + }, + { + text: "ఇది ఈ వాక్యాన్ని పూర్తి చేస్తూ ఉత్పత్తి చేయబడిన టెక్స్ట్‌ను తిరిగి ఇస్తుంది.", + explain: "ఇది తప్పు — ఇది text-generation పైప్‌లైన్ అవుతుంది.", + }, + { + text: "ఇది వ్యక్తులు, సంస్థలు లేదా ప్రదేశాలను సూచించే పదాలను తిరిగి ఇస్తుంది.", + explain: "అంతేకాకుండా, grouped_entities=True తో, ఇది "Hugging Face" వంటి ఒకే ఎంటిటీకి చెందిన పదాలను సమూహపరుస్తుంది.", + correct: true + } + ]} /> -### 3. What should replace ... in this code sample? +### 3. ఈ కోడ్ నమూనాలో ... స్థానంలో ఏమి ఉండాలి?? ```py from transformers import pipeline @@ -69,24 +79,26 @@ result = filler("...") ``` has been waiting for you.", - explain: "This is incorrect. Check out the bert-base-cased model card and try to spot your mistake." - }, - { - text: "This [MASK] has been waiting for you.", - explain: "This model's mask token is [MASK].", - correct: true - }, - { - text: "This man has been waiting for you.", - explain: "This is incorrect. This pipeline fills in masked words, so it needs a mask token somewhere." - } - ]} + choices={[ + { + text: "This has been waiting for you.", + explain: + "ఇది తప్పు. bert-base-cased మోడల్ కార్డును తనిఖీ చేసి మీ పొరపాటును గుర్తించడానికి ప్రయత్నించండి.", + }, + { + text: "This [MASK] has been waiting for you.", + explain: "ఈ మోడల్ యొక్క మాస్క్ టోకెన్ [MASK].", + correct: true, + }, + { + text: "This man has been waiting for you.", + explain: + "ఇది తప్పు. ఈ పైప్‌లైన్ మాస్క్ చేయబడిన పదాలను నింపుతుంది, కాబట్టి దీనికి ఎక్కడో ఒక మాస్క్ టోకెన్ అవసరం.", + }, + ]} /> -### 4. Why will this code fail? +### 4. ఈ కోడ్ ఎందుకు విఫలమవుతుంది?? ```py from transformers import pipeline @@ -96,162 +108,181 @@ result = classifier("This is a course about the Transformers library") ``` candidate_labels=[...].", - correct: true - }, - { - text: "This pipeline requires several sentences, not just one.", - explain: "This is incorrect, though when properly used, this pipeline can take a list of sentences to process (like all other pipelines)." - }, - { - text: "The 🤗 Transformers library is broken, as usual.", - explain: "We won't dignify this answer with a comment!" - }, - { - text: "This pipeline requires longer inputs; this one is too short.", - explain: "This is incorrect. Note that a very long text will be truncated when processed by this pipeline." - } - ]} + choices={[ + { + text: "ఈ పైప్‌లైన్‌కు ఈ టెక్స్ట్‌ను వర్గీకరించడానికి లేబుల్స్ ఇవ్వాలి.", + explain: + "సరిగ్గా — సరైన కోడ్‌కు candidate_labels=[...] ను చేర్చాలి.", + correct: true, + }, + { + text: "ఈ పైప్‌లైన్‌కు కేవలం ఒక వాక్యం కాకుండా, అనేక వాక్యాలు అవసరం.", + explain: + "ఇది తప్పు, సరిగ్గా ఉపయోగించినప్పుడు, ఈ పైప్‌లైన్ (ఇతర అన్ని పైప్‌లైన్‌ల వలె) ప్రాసెస్ చేయడానికి వాక్యాల జాబితాను తీసుకోవచ్చు.", + }, + { + text: "🤗 Transformers లైబ్రరీ మామూలుగానే విఫలమైంది.", + explain: "మేము ఈ సమాధానానికి వ్యాఖ్యానించి గౌరవించము!", + }, + { + text: "ఈ పైప్‌లైన్‌కు పొడవైన ఇన్‌పుట్‌లు అవసరం; ఇది చాలా చిన్నది.", + explain: + "ఇది తప్పు. ఈ పైప్‌లైన్ ద్వారా ప్రాసెస్ చేయబడినప్పుడు చాలా పొడవైన టెక్స్ట్ కుదించబడుతుందని గమనించండి.", + }, + ]} /> -### 5. What does "transfer learning" mean? +### 5. "ట్రాన్స్‌ఫర్ లెర్నింగ్" అంటే ఏమిటి? -### 6. True or false? A language model usually does not need labels for its pretraining. +### 6. నిజమా అబద్ధమా? ఒక భాషా నమూనాకు దాని ప్రీట్రైనింగ్ కోసం సాధారణంగా లేబుల్స్ అవసరం లేదు. self-supervised, which means the labels are created automatically from the inputs (like predicting the next word or filling in some masked words).", - correct: true - }, - { - text: "False", - explain: "This is not the correct answer." - } - ]} + choices={[ + { + text: "నిజం", + explain: + "ప్రీట్రైనింగ్ సాధారణంగా స్వీయ-పర్యవేక్షితం (self-supervised), అంటే లేబుల్స్ ఇన్‌పుట్‌ల నుండి స్వయంచాలకంగా సృష్టించబడతాయి (తదుపరి పదాన్ని అంచనా వేయడం లేదా కొన్ని మాస్క్ చేయబడిన పదాలను పూరించడం వంటివి).", + correct: true, + }, + { + text: "అబద్ధం", + explain: "ఇది సరైన సమాధానం కాదు.", + }, + ]} /> -### 7. Select the sentence that best describes the terms "model", "architecture", and "weights". +### 7. "మోడల్", "ఆర్కిటెక్చర్", మరియు "వెయిట్స్" అనే పదాలను ఉత్తమంగా వర్ణించే వాక్యాన్ని ఎంచుకోండి. - -### 8. Which of these types of models would you use for completing prompts with generated text? +### 8. ఉత్పత్తి చేయబడిన టెక్స్ట్‌తో ప్రాంప్ట్‌లను పూర్తి చేయడానికి మీరు ఈ రకమైన మోడల్స్‌లో దేనిని ఉపయోగిస్తారు? -### 9. Which of those types of models would you use for summarizing texts? +### 9. టెక్స్ట్‌లను సంగ్రహించడానికి మీరు ఆ రకమైన మోడల్స్‌లో దేనిని ఉపయోగిస్తారు? -### 10. Which of these types of models would you use for classifying text inputs according to certain labels? +### 10. కొన్ని లేబుల్స్ ప్రకారం టెక్స్ట్ ఇన్‌పుట్‌లను వర్గీకరించడానికి మీరు ఈ రకమైన మోడల్స్‌లో దేనిని ఉపయోగిస్తారు? -### 11. What possible source can the bias observed in a model have? +### 11. ఒక మోడల్‌లో గమనించిన పక్షపాతానికి సాధ్యమయ్యే మూలం ఏమిటి? diff --git a/chapters/te/chapter1/8.mdx b/chapters/te/chapter1/8.mdx index a84e76f41..7cac6fd12 100644 --- a/chapters/te/chapter1/8.mdx +++ b/chapters/te/chapter1/8.mdx @@ -1,272 +1,303 @@ -# Deep dive into Text Generation Inference with LLMs[[inference-with-llms]] +# LLMలతో టెక్స్ట్ జనరేషన్ ఇన్ఫరెన్స్ పై లోతైన పరిశీలన [[inference-with-llms]] - + -So far, we've explored the transformer architecture in relation to a range of discrete tasks, like text classification or summarization. However, Large Language Models are most used for text generation, and this is what we'll explore in this chapter. +ఇప్పటివరకు, మనం టెక్స్ట్ వర్గీకరణ లేదా సారాంశీకరణ వంటి వివిధ రకాల పనులకు సంబంధించి ట్రాన్స్‌ఫార్మర్ ఆర్కిటెక్చర్‌ను అన్వేషించాము. అయితే, Large Language Models (LLMలు) ఎక్కువగా టెక్స్ట్ జనరేషన్ కోసం ఉపయోగించబడతాయి మరియు ఈ అధ్యాయంలో మనం దీనినే అన్వేషిస్తాము. -In this page, we'll explore the core concepts behind LLM inference, providing a comprehensive understanding of how these models generate text and the key components involved in the inference process. +ఈ పేజీలో, మనం LLM ఇన్ఫరెన్స్ వెనుక ఉన్న ముఖ్యమైన భావనలను అన్వేషిస్తాము. ఈ మోడల్స్ టెక్స్ట్‌ను ఎలా ఉత్పత్తి చేస్తాయి మరియు ఇన్ఫరెన్స్ ప్రక్రియలో కీలకమైన అంశాలు ఏమిటో సమగ్ర అవగాహనను అందిస్తాము. -## Understanding the Basics +## ప్రాథమికాలను అర్థం చేసుకోవడం -Let's start with the fundamentals. Inference is the process of using a trained LLM to generate human-like text from a given input prompt. Language models use their knowledge from training to formulate responses one word at a time. The model leverages learned probabilities from billions of parameters to predict and generate the next token in a sequence. This sequential generation is what allows LLMs to produce coherent and contextually relevant text. +ప్రాథమిక అంశాలతో ప్రారంభిద్దాం. ఇన్ఫరెన్స్ అనేది, శిక్షణ పొందిన LLMను ఉపయోగించి, ఇచ్చిన ఇన్‌పుట్ ప్రాంప్ట్ నుండి మానవ-సహజమైన టెక్స్ట్‌ను ఉత్పత్తి చేసే ప్రక్రియ. భాషా నమూనాలు తమ శిక్షణ నుండి పొందిన జ్ఞానాన్ని ఉపయోగించి, ఒకేసారి ఒక్కో పదాన్ని స్పందనలుగా రూపొందిస్తాయి. మోడల్, బిలియన్ల పారామితుల నుండి నేర్చుకున్న సంభావ్యతలను (probabilities) ఉపయోగించి, ఒక క్రమంలో తదుపరి టోకెన్‌ను అంచనా వేసి, ఉత్పత్తి చేస్తుంది. ఈ వరుస ఉత్పత్తి ప్రక్రియే LLMలను పొందికగా మరియు సందర్భోచితంగా ఉండే టెక్స్ట్‌ను రూపొందించడానికి అనుమతిస్తుంది. -## The Role of Attention +## అటెన్షన్ పాత్ర -The attention mechanism is what gives LLMs their ability to understand context and generate coherent responses. When predicting the next word, not every word in a sentence carries equal weight - for example, in the sentence *"The capital of France is ..."*, the words "France" and "capital" are crucial for determining that "Paris" should come next. This ability to focus on relevant information is what we call attention. +అటెన్షన్ మెకానిజం, LLMలకు సందర్భాన్ని అర్థం చేసుకుని, పొందికైన ప్రతిస్పందనలను ఉత్పత్తి చేసే సామర్థ్యాన్ని ఇస్తుంది. తదుపరి పదాన్ని అంచనా వేసేటప్పుడు, ఒక వాక్యంలోని ప్రతి పదానికి సమాన ప్రాధాన్యత ఉండదు - ఉదాహరణకు, "The capital of France is ..." అనే వాక్యంలో, "France" మరియు "capital" అనే పదాలు తదుపరి పదం "Paris" అని నిర్ధారించడానికి చాలా ముఖ్యమైనవి. సంబంధిత సమాచారంపై దృష్టి పెట్టే ఈ సామర్థ్యాన్ని మనం అటెన్షన్ అని పిలుస్తాము. Visual Gif of Attention -This process of identifying the most relevant words to predict the next token has proven to be incredibly effective. Although the basic principle of training LLMs—predicting the next token—has remained generally consistent since BERT and GPT-2, there have been significant advancements in scaling neural networks and making the attention mechanism work for longer and longer sequences, at lower and lower costs. +తదుపరి టోకెన్‌ను అంచనా వేయడానికి అత్యంత సంబంధిత పదాలను గుర్తించే ఈ ప్రక్రియ అద్భుతంగా ప్రభావవంతమైనదని నిరూపించబడింది. BERT మరియు GPT-2 కాలం నుండి LLMలకు శిక్షణ ఇచ్చే ప్రాథమిక సూత్రం — తదుపరి టోకెన్‌ను అంచనా వేయడం — సాధారణంగా స్థిరంగా ఉన్నప్పటికీ, న్యూరల్ నెట్‌వర్క్‌లను స్కేల్ చేయడంలో మరియు అటెన్షన్ మెకానిజంను తక్కువ ఖర్చుతో, సుదీర్ఘమైన సీక్వెన్స్‌ల కోసం పనిచేసేలా చేయడంలో గణనీయమైన పురోగతి సాధించబడింది. -In short, the attention mechanism is the key to LLMs being able to generate text that is both coherent and context-aware. It sets modern LLMs apart from previous generations of language models. +సంక్షిప్తంగా, LLMలు పొందికగా మరియు సందర్భానుసారంగా ఉండే టెక్స్ట్‌ను ఉత్పత్తి చేయగలగడానికి అటెన్షన్ మెకానిజం కీలకం. ఇది ఆధునిక LLMలను పాత తరం భాషా నమూనాల నుండి వేరుగా నిలుపుతుంది. -### Context Length and Attention Span +### కాంటెక్స్ట్ లెంగ్త్ మరియు అటెన్షన్ స్పాన్ -Now that we understand attention, let's explore how much context an LLM can actually handle. This brings us to context length, or the model's 'attention span'. +ఇప్పుడు మనం అటెన్షన్ గురించి అర్థం చేసుకున్నాం కాబట్టి, ఒక LLM వాస్తవానికి ఎంత కాంటెక్స్ట్‌ను నిర్వహించగలదో అన్వేషిద్దాం. ఇది మనల్ని కాంటెక్స్ట్ లెంగ్త్, లేదా మోడల్ యొక్క 'అటెన్షన్ స్పాన్' వద్దకు తీసుకువస్తుంది. -The context length refers to the maximum number of tokens (words or parts of words) that the LLM can process at once. Think of it as the size of the model's working memory. +కాంటెక్స్ట్ లెంగ్త్ అనేది LLM ఒకేసారి ప్రాసెస్ చేయగల గరిష్ట సంఖ్య టోకెన్‌లను (పదాలు లేదా పదాల భాగాలు) సూచిస్తుంది. దీనిని మోడల్ యొక్క వర్కింగ్ మెమరీ పరిమాణంగా భావించండి. -These capabilities are limited by several practical factors: -- The model's architecture and size -- Available computational resources -- The complexity of the input and desired output +ఈ సామర్థ్యాలు అనేక ఆచరణాత్మక కారకాల ద్వారా పరిమితం చేయబడ్డాయి: -In an ideal world, we could feed unlimited context to the model, but hardware constraints and computational costs make this impractical. This is why different models are designed with different context lengths to balance capability with efficiency. +- మోడల్ యొక్క ఆర్కిటెక్చర్ మరియు పరిమాణం +- అందుబాటులో ఉన్న కంప్యూటేషనల్ వనరులు +- ఇన్‌పుట్ మరియు కావలసిన అవుట్‌పుట్ యొక్క సంక్లిష్టత + +ఒక ఆదర్శ ప్రపంచంలో, మనం మోడల్‌కు అపరిమితమైన కాంటెక్స్ట్‌ను అందించవచ్చు, కానీ హార్డ్‌వేర్ పరిమితులు మరియు గణన ఖర్చులు దీనిని అసాధ్యం చేస్తాయి. అందుకే సామర్థ్యాన్ని మరియు సమర్థతను సమతుల్యం చేయడానికి వివిధ మోడల్స్ వివిధ కాంటెక్స్ట్ లెంగ్త్‌లతో రూపొందించబడ్డాయి. -The context length is the maximum number of tokens the model can consider at once when generating a response. +కాంటెక్స్ట్ లెంగ్త్ అనేది, స్పందనను ఉత్పత్తి చేసేటప్పుడు మోడల్ ఒకేసారి పరిగణించగల గరిష్ట టోకెన్‌ల సంఖ్య. -### The Art of Prompting +### ప్రాంప్టింగ్ కళ -When we pass information to LLMs, we structure our input in a way that guides the generation of the LLM toward the desired output. This is called _prompting_. +మనం LLMలకు సమాచారాన్ని అందించినప్పుడు, LLM యొక్క జనరేషన్‌ను కావలసిన అవుట్‌పుట్ వైపు నడిపించే విధంగా మన ఇన్‌పుట్‌ను రూపొందిస్తాము. దీనిని ప్రాంప్టింగ్ అని అంటారు. -Understanding how LLMs process information helps us craft better prompts. Since the model's primary task is to predict the next token by analyzing the importance of each input token, the wording of your input sequence becomes crucial. +LLMలు సమాచారాన్ని ఎలా ప్రాసెస్ చేస్తాయో అర్థం చేసుకోవడం, మెరుగైన ప్రాంప్ట్‌లను రూపొందించడంలో మనకు సహాయపడుతుంది. మోడల్ యొక్క ప్రాథమిక విధి ప్రతి ఇన్‌పుట్ టోకెన్ యొక్క ప్రాముఖ్యతను విశ్లేషించడం ద్వారా తదుపరి టోకెన్‌ను అంచనా వేయడం కాబట్టి, మీ ఇన్‌పుట్ సీక్వెన్స్ యొక్క పదజాలం చాలా కీలకమైనది. -Careful design of the prompt makes it easier **to guide the generation of the LLM toward the desired output**. +ప్రాంప్ట్‌ను జాగ్రత్తగా రూపొందించడం వల్ల LLM జనరేషన్‌ను కావలసిన అవుట్‌పుట్ వైపు నడిపించడం సులభం అవుతుంది. -## The Two-Phase Inference Process +## రెండు-దశల ఇన్ఫరెన్స్ ప్రక్రియ -Now that we understand the basic components, let's dive into how LLMs actually generate text. The process can be broken down into two main phases: prefill and decode. These phases work together like an assembly line, each playing a crucial role in producing coherent text. +ఇప్పుడు మనం ప్రాథమిక భాగాలను అర్థం చేసుకున్నాం కాబట్టి, LLMలు వాస్తవానికి టెక్స్ట్‌ను ఎలా ఉత్పత్తి చేస్తాయో లోతుగా చూద్దాం. ఈ ప్రక్రియను రెండు ప్రధాన దశలుగా విభజించవచ్చు: ప్రీఫిల్ (prefill) మరియు డీకోడ్ (decode). ఈ దశలు ఒక అసెంబ్లీ లైన్ లాగా కలిసి పనిచేస్తాయి, పొందికైన టెక్స్ట్‌ను ఉత్పత్తి చేయడంలో ప్రతి ఒక్కటి కీలక పాత్ర పోషిస్తుంది. -### The Prefill Phase +### ప్రీఫిల్ దశ -The prefill phase is like the preparation stage in cooking - it's where all the initial ingredients are processed and made ready. This phase involves three key steps: +ప్రీఫిల్ దశ వంటలో తయారీ దశ లాంటిది - ఇక్కడ అన్ని ప్రారంభ పదార్థాలు ప్రాసెస్ చేయబడి సిద్ధంగా ఉంటాయి. ఈ దశలో మూడు కీలక దశలు ఉంటాయి: -1. **Tokenization**: Converting the input text into tokens (think of these as the basic building blocks the model understands) -2. **Embedding Conversion**: Transforming these tokens into numerical representations that capture their meaning -3. **Initial Processing**: Running these embeddings through the model's neural networks to create a rich understanding of the context +1. **టోకనైజేషన్**: ఇన్‌పుట్ టెక్స్ట్‌ను టోకెన్‌లుగా మార్చడం (వీటిని మోడల్ అర్థం చేసుకునే ప్రాథమిక బిల్డింగ్ బ్లాక్‌లుగా భావించండి) +2. **ఎంబెడ్డింగ్ మార్పిడి**: ఈ టోకెన్‌లను వాటి అర్థాన్ని సంగ్రహించే సంఖ్యా ప్రాతినిధ్యాలుగా మార్చడం +3. **ప్రారంభ ప్రాసెసింగ్**: కాంటెక్స్ట్ యొక్క గొప్ప అవగాహనను సృష్టించడానికి ఈ ఎంబెడ్డింగ్‌లను మోడల్ యొక్క న్యూరల్ నెట్‌వర్క్‌ల ద్వారా అమలు చేయడం -This phase is computationally intensive because it needs to process all input tokens at once. Think of it as reading and understanding an entire paragraph before starting to write a response. +ఈ దశ కంప్యూటేషనల్‌గా చాలా తీవ్రమైనది ఎందుకంటే ఇది అన్ని ఇన్‌పుట్ టోకెన్‌లను ఒకేసారి ప్రాసెస్ చేయాలి. ఒక ప్రతిస్పందన రాయడం ప్రారంభించే ముందు ఒక పూర్తి పేరా చదివి అర్థం చేసుకున్నట్లుగా దీనిని భావించండి. -You can experiment with different tokenizers in the interactive playground below: +కింది ఇంటరాక్టివ్ ప్లేగ్రౌండ్‌లో మీరు వివిధ టోకనైజర్‌లతో ప్రయోగాలు చేయవచ్చు: -### The Decode Phase +### డీకోడ్ దశ + +ప్రీఫిల్ దశ ఇన్‌పుట్‌ను ప్రాసెస్ చేసిన తర్వాత, మనం డీకోడ్ దశకు వెళ్తాము - ఇక్కడే అసలు టెక్స్ట్ జనరేషన్ జరుగుతుంది. మోడల్ ఒక ఆటోరిగ్రెసివ్ ప్రక్రియలో (ఇక్కడ ప్రతి కొత్త టోకెన్ మునుపటి అన్ని టోకెన్లపై ఆధారపడి ఉంటుంది) ఒకేసారి ఒక్కో టోకెన్‌ను ఉత్పత్తి చేస్తుంది. -After the prefill phase has processed the input, we move to the decode phase - this is where the actual text generation happens. The model generates one token at a time in what we call an autoregressive process (where each new token depends on all previous tokens). +డీకోడ్ దశలో ప్రతి కొత్త టోకెన్ కోసం జరిగే అనేక కీలక దశలు ఉంటాయి: -The decode phase involves several key steps that happen for each new token: -1. **Attention Computation**: Looking back at all previous tokens to understand context -2. **Probability Calculation**: Determining the likelihood of each possible next token -3. **Token Selection**: Choosing the next token based on these probabilities -4. **Continuation Check**: Deciding whether to continue or stop generation +1. **అటెన్షన్ కంప్యూటేషన్**: కాంటెక్స్ట్‌ను అర్థం చేసుకోవడానికి మునుపటి అన్ని టోకెన్‌లను తిరిగి చూడటం +2. **సంభావ్యత గణన**: సాధ్యమయ్యే ప్రతి తదుపరి టోకెన్ యొక్క సంభావ్యతను నిర్ణయించడం +3. **టోకెన్ ఎంపిక**: ఈ సంభావ్యతల ఆధారంగా తదుపరి టోకెన్‌ను ఎంచుకోవడం +4. **కొనసాగింపు తనిఖీ**: జనరేషన్‌ను కొనసాగించాలా లేదా ఆపాలా అని నిర్ణయించడం -This phase is memory-intensive because the model needs to keep track of all previously generated tokens and their relationships. +ఈ దశ మెమరీ-ఇంటెన్సివ్ ఎందుకంటే మోడల్ గతంలో ఉత్పత్తి చేయబడిన అన్ని టోకెన్‌లను మరియు వాటి సంబంధాలను గుర్తుంచుకోవాలి. -## Sampling Strategies +## శాంప్లింగ్ వ్యూహాలు -Now that we understand how the model generates text, let's explore the various ways we can control this generation process. Just like a writer might choose between being more creative or more precise, we can adjust how the model makes its token selections. +ఇప్పుడు మనం మోడల్ టెక్స్ట్‌ను ఎలా ఉత్పత్తి చేస్తుందో అర్థం చేసుకున్నాం కాబట్టి, ఈ జనరేషన్ ప్రక్రియను మనం నియంత్రించగల వివిధ మార్గాలను అన్వేషిద్దాం. ఒక రచయిత మరింత సృజనాత్మకంగా లేదా మరింత కచ్చితంగా ఉండటానికి మధ్య ఎంచుకున్నట్లే, మోడల్ తన టోకెన్ ఎంపికలను ఎలా చేయాలో మనం సర్దుబాటు చేయవచ్చు. -You can interact with the basic decoding process yourself with SmolLM2 in this Space (remember, it decodes until reaching an **EOS** token which is **<|im_end|>** for this model): +ఈ స్పేస్‌లో SmolLM2 తో మీరు ప్రాథమిక డీకోడింగ్ ప్రక్రియతో స్వయంగా ఇంటరాక్ట్ అవ్వవచ్చు (గుర్తుంచుకోండి, ఇది ఈ మోడల్‌కు **EOS** అయిన `<|im_end|>` టోకెన్‌ను చేరుకునే వరకు డీకోడ్ చేస్తుంది): -### Understanding Token Selection: From Probabilities to Token Choices - -When the model needs to choose the next token, it starts with raw probabilities (called logits) for every word in its vocabulary. But how do we turn these probabilities into actual choices? Let's break down the process: - -![image](https://huggingface.co/reasoning-course/images/resolve/main/inference/1.png) - -1. **Raw Logits**: Think of these as the model's initial gut feelings about each possible next word -2. **Temperature Control**: Like a creativity dial - higher settings (>1.0) make choices more random and creative, lower settings (<1.0) make them more focused and deterministic -3. **Top-p (Nucleus) Sampling**: Instead of considering all possible words, we only look at the most likely ones that add up to our chosen probability threshold (e.g., top 90%) -4. **Top-k Filtering**: An alternative approach where we only consider the k most likely next words - -### Managing Repetition: Keeping Output Fresh - -One common challenge with LLMs is their tendency to repeat themselves - much like a speaker who keeps returning to the same points. To address this, we use two types of penalties: - -1. **Presence Penalty**: A fixed penalty applied to any token that has appeared before, regardless of how often. This helps prevent the model from reusing the same words. -2. **Frequency Penalty**: A scaling penalty that increases based on how often a token has been used. The more a word appears, the less likely it is to be chosen again. - -![image](https://huggingface.co/reasoning-course/images/resolve/main/inference/2.png) - -These penalties are applied early in the token selection process, adjusting the raw probabilities before other sampling strategies are applied. Think of them as gentle nudges encouraging the model to explore new vocabulary. +### టోకెన్ ఎంపికను అర్థం చేసుకోవడం: సంభావ్యతల నుండి టోకెన్ ఎంపికల వరకు -### Controlling Generation Length: Setting Boundaries +మోడల్ తదుపరి టోకెన్‌ను ఎంచుకోవలసి వచ్చినప్పుడు, అది దాని పదజాలంలోని ప్రతి పదానికి ముడి సంభావ్యతలతో (logits అని పిలుస్తారు) ప్రారంభమవుతుంది. కానీ ఈ సంభావ్యతలను మనం అసలు ఎంపికలుగా ఎలా మారుస్తాం? ప్రక్రియను విభజించి చూద్దాం: -Just as a good story needs proper pacing and length, we need ways to control how much text our LLM generates. This is crucial for practical applications - whether we're generating a tweet-length response or a full blog post. +![image](https://huggingface.co/reasoning-course/images/resolve/main/inference/1.png) -We can control generation length in several ways: -1. **Token Limits**: Setting minimum and maximum token counts -2. **Stop Sequences**: Defining specific patterns that signal the end of generation -3. **End-of-Sequence Detection**: Letting the model naturally conclude its response +1. **రా లాజిట్స్ (Raw Logits)**: సాధ్యమైన ప్రతి తదుపరి పదం గురించి మోడల్ యొక్క ప్రారంభ అంతర్ దృష్టిగా వీటిని భావించండి +2. **టెంపరేచర్ కంట్రోల్**: ఒక క్రియేటివిటీ డయల్ లాంటిది - అధిక సెట్టింగ్‌లు (>1.0) ఎంపికలను మరింత యాదృచ్ఛికంగా మరియు సృజనాత్మకంగా చేస్తాయి, తక్కువ సెట్టింగ్‌లు (<1.0) వాటిని మరింత కేంద్రీకృతంగా మరియు నిర్ధారితంగా చేస్తాయి +3. **టాప్-పి (న్యూక్లియస్) శాంప్లింగ్**: సాధ్యమయ్యే అన్ని పదాలను పరిగణలోకి తీసుకోకుండా, మనం ఎంచుకున్న సంభావ్యత థ్రెషోల్డ్‌కు (ఉదా., టాప్ 90%) సరిపోయే అత్యంత సంభావ్య పదాలను మాత్రమే చూస్తాము +4. **టాప్-కె ఫిల్టరింగ్**: ఒక ప్రత్యామ్నాయ విధానం, ఇక్కడ మనం k అత్యంత సంభావ్య తదుపరి పదాలను మాత్రమే పరిగణలోకి తీసుకుంటాము -For example, if we want to generate a single paragraph, we might set a maximum of 100 tokens and use "\n\n" as a stop sequence. This ensures our output stays focused and appropriately sized for its purpose. +### పునరావృత్తిని నిర్వహించడం: అవుట్‌పుట్‌ను తాజాగా ఉంచడం -![image](https://huggingface.co/reasoning-course/images/resolve/main/inference/3.png) +LLMలతో ఒక సాధారణ సవాలు ఏమిటంటే, అవి తమను తాము పునరావృతం చేసుకునే ధోరణి - ఒకే పాయింట్లకు పదేపదే తిరిగివచ్చే స్పీకర్ లాగా. దీనిని పరిష్కరించడానికి, మేము రెండు రకాల పెనాల్టీలను ఉపయోగిస్తాము: -### Beam Search: Looking Ahead for Better Coherence +1. **ప్రెజెన్స్ పెనాల్టీ (Presence Penalty)**: ఇదివరకు కనిపించిన ఏ టోకెన్‌కైనా, అది ఎంత తరచుగా కనిపించినా వర్తించే ఒక స్థిరమైన పెనాల్టీ. ఇది మోడల్ అదే పదాలను తిరిగి ఉపయోగించకుండా నిరోధించడానికి సహాయపడుతుంది. +2. **ఫ్రీక్వెన్సీ పెనాల్టీ (Frequency Penalty)**: ఒక టోకెన్ ఎంత తరచుగా ఉపయోగించబడిందనే దానిపై ఆధారపడి పెరిగే స్కేలింగ్ పెనాల్టీ. ఒక పదం ఎంత ఎక్కువగా కనిపిస్తే, అది మళ్లీ ఎంపికయ్యే అవకాశం అంత తక్కువ. -While the strategies we've discussed so far make decisions one token at a time, beam search takes a more holistic approach. Instead of committing to a single choice at each step, it explores multiple possible paths simultaneously - like a chess player thinking several moves ahead. +![image](https://huggingface.co/reasoning-course/images/resolve/main/inference/2.png) -![image](https://huggingface.co/reasoning-course/images/resolve/main/inference/4.png) +ఇతర శాంప్లింగ్ వ్యూహాలు వర్తించే ముందు, ఈ పెనాల్టీలు టోకెన్ ఎంపిక ప్రక్రియలో ప్రారంభంలోనే వర్తింపజేయబడతాయి, ముడి సంభావ్యతలను సర్దుబాటు చేస్తాయి. కొత్త పదజాలాన్ని అన్వేషించడానికి మోడల్‌ను ప్రోత్సహించే సున్నితమైన ప్రోత్సాహకాలుగా వీటిని భావించండి. -Here's how it works: -1. At each step, maintain multiple candidate sequences (typically 5-10) -2. For each candidate, compute probabilities for the next token -3. Keep only the most promising combinations of sequences and next tokens -4. Continue this process until reaching the desired length or stop condition -5. Select the sequence with the highest overall probability +### జనరేషన్ పొడవును నియంత్రించడం: సరిహద్దులను సెట్ చేయడం -You can explore beam search visually here: +ఒక మంచి కథకు సరైన వేగం మరియు పొడవు అవసరమైనట్లే, మన LLM ఎంత టెక్స్ట్ ఉత్పత్తి చేస్తుందో నియంత్రించడానికి మనకు మార్గాలు అవసరం. ఆచరణాత్మక అనువర్తనాలకు ఇది చాలా ముఖ్యం - మనం ట్వీట్-పొడవు ప్రతిస్పందనను ఉత్పత్తి చేస్తున్నా లేదా పూర్తి బ్లాగ్ పోస్ట్‌ను ఉత్పత్తి చేస్తున్నా. - - -This approach often produces more coherent and grammatically correct text, though it requires more computational resources than simpler methods. +మనం జనరేషన్ పొడవును అనేక విధాలుగా నియంత్రించవచ్చు: -## Practical Challenges and Optimization +1. **టోకెన్ పరిమితులు**: కనీస మరియు గరిష్ట టోకెన్ల సంఖ్యను సెట్ చేయడం +2. **స్టాప్ సీక్వెన్సులు**: జనరేషన్ ముగింపును సూచించే నిర్దిష్ట నమూనాలను నిర్వచించడం +3. **ఎండ్-ఆఫ్-సీక్వెన్స్ డిటెక్షన్**: మోడల్ తన ప్రతిస్పందనను సహజంగా ముగించనివ్వడం -As we wrap up our exploration of LLM inference, let's look at the practical challenges you'll face when deploying these models, and how to measure and optimize their performance. +ఉదాహరణకు, మనం ఒకే పేరాగ్రాఫ్‌ను రూపొందించాలనుకుంటే, గరిష్టంగా 100 టోకెన్‌లను సెట్ చేసి "\n\n" ను స్టాప్ సీక్వెన్స్‌గా ఉపయోగించవచ్చు. ఇది మన అవుట్‌పుట్ దాని ప్రయోజనం కోసం కేంద్రీకృతమై మరియు తగిన పరిమాణంలో ఉండేలా చేస్తుంది. -### Key Performance Metrics +![image](https://huggingface.co/reasoning-course/images/resolve/main/inference/3.png) -When working with LLMs, four critical metrics will shape your implementation decisions: +### బీమ్ సెర్చ్: మెరుగైన పొందిక కోసం ముందుకు చూడటం -1. **Time to First Token (TTFT)**: How quickly can you get the first response? This is crucial for user experience and is primarily affected by the prefill phase. -2. **Time Per Output Token (TPOT)**: How fast can you generate subsequent tokens? This determines the overall generation speed. -3. **Throughput**: How many requests can you handle simultaneously? This affects scaling and cost efficiency. -4. **VRAM Usage**: How much GPU memory do you need? This often becomes the primary constraint in real-world applications. +ఇప్పటివరకు మనం చర్చించిన వ్యూహాలు ఒక సమయంలో ఒక్కో టోకెన్‌కు మాత్రమే నిర్ణయాలు తీసుకుంటాయి, కానీ బీమ్ సెర్చ్ మరింత సమగ్రమైన విధానాన్ని తీసుకుంటుంది. ప్రతి దశలో ఒకే ఎంపికకు కట్టుబడి ఉండటానికి బదులుగా, ఇది ఒకేసారి అనేక సాధ్యమైన మార్గాలను అన్వేషిస్తుంది - చదరంగం ఆటగాడు అనేక ఎత్తుగడలను ముందుకు ఆలోచించినట్లుగా. -### The Context Length Challenge +![image](https://huggingface.co/reasoning-course/images/resolve/main/inference/4.png) -One of the most significant challenges in LLM inference is managing context length effectively. Longer contexts provide more information but come with substantial costs: +ఇది ఎలా పనిచేస్తుందో ఇక్కడ ఉంది: -- **Memory Usage**: Grows quadratically with context length -- **Processing Speed**: Decreases linearly with longer contexts -- **Resource Allocation**: Requires careful balancing of VRAM usage +1. ప్రతీ దశలో, అనేక అభ్యర్థి సీక్వెన్సులను (సాధారణంగా 5-10) నిర్వహించండి +2. ప్రతి అభ్యర్థికి, తదుపరి టోకెన్ కోసం సంభావ్యతలను గణించండి +3. సీక్వెన్సులు మరియు తదుపరి టోకెన్‌ల యొక్క అత్యంత ఆశాజనకమైన కలయికలను మాత్రమే ఉంచండి +4. కావలసిన పొడవు లేదా స్టాప్ కండిషన్ చేరే వరకు ఈ ప్రక్రియను కొనసాగించండి +5. అత్యధిక మొత్తం సంభావ్యత ఉన్న సీక్వెన్స్‌ను ఎంచుకోండి -Recent models like [Qwen2.5-1M](https://huggingface.co/Qwen/Qwen2.5-14B-Instruct-1M) offer impressive 1M token context windows, but this comes at the cost of significantly slower inference times. The key is finding the right balance for your specific use case. +మీరు బీమ్ సెర్చ్‌ను దృశ్యమానంగా ఇక్కడ అన్వేషించవచ్చు: + -
-
-
-
- Input Text (Raw) -
-
-
- Tokenized Input -
-
-
-
+
+
+
+ Input Text (Raw) +
+
+
+ Tokenized Input +
+
+
+
- Context Window
(e.g., 4K tokens) -
-
+ Context Window +
+ (e.g., 4K tokens) +
+
-
+
-
+
-
+
-
-
+ 2px;" + >
-
-
-
+
+
- Memory Usage
∝ Length² -
-
-
-
+ Memory Usage +
∝ Length² +
+
+
+
- Processing Time
∝ Length -
-
+ border-radius: 4px;" + > + Processing Time +
∝ Length
+
+
-### The KV Cache Optimization +### KV కాష్ ఆప్టిమైజేషన్ + +ఈ సవాళ్లను ఎదుర్కోవడానికి, అత్యంత శక్తివంతమైన ఆప్టిమైజేషన్‌లలో ఒకటి KV (కీ-వాల్యూ) కాషింగ్. ఈ టెక్నిక్ మధ్యంతర గణనలను నిల్వ చేయడం మరియు తిరిగి ఉపయోగించడం ద్వారా ఇన్ఫరెన్స్ వేగాన్ని గణనీయంగా మెరుగుపరుస్తుంది. ఈ ఆప్టిమైజేషన్: -To address these challenges, one of the most powerful optimizations is KV (Key-Value) caching. This technique significantly improves inference speed by storing and reusing intermediate calculations. This optimization: -- Reduces repeated calculations -- Improves generation speed -- Makes long-context generation practical +- పునరావృత గణనలను తగ్గిస్తుంది +- జనరేషన్ వేగాన్ని మెరుగుపరుస్తుంది +- సుదీర్ఘ-సందర్భ (long-context) జనరేషన్‌ను ఆచరణాత్మకంగా చేస్తుంది -The trade-off is additional memory usage, but the performance benefits usually far outweigh this cost. +దీని ప్రతికూలత అదనపు మెమరీ వినియోగం, కానీ పనితీరు ప్రయోజనాలు సాధారణంగా ఈ ఖర్చును అధిగమిస్తాయి. -## Conclusion +## ముగింపు -Understanding LLM inference is crucial for effectively deploying and optimizing these powerful models. We've covered the key components: +ఈ శక్తివంతమైన మోడల్స్‌ను సమర్థవంతంగా అమలు చేయడానికి మరియు ఆప్టిమైజ్ చేయడానికి LLM ఇన్ఫరెన్స్‌ను అర్థం చేసుకోవడం చాలా ముఖ్యం. మేము కవర్ చేసిన ముఖ్య అంశాలు: -- The fundamental role of attention and context -- The two-phase inference process -- Various sampling strategies for controlling generation -- Practical challenges and optimizations +- అటెన్షన్ మరియు కాంటెక్స్ట్ యొక్క ప్రాథమిక పాత్ర +- రెండు-దశల ఇన్ఫరెన్స్ ప్రక్రియ +- జనరేషన్‌ను నియంత్రించడానికి వివిధ శాంప్లింగ్ వ్యూహాలు +- ఆచరణాత్మక సవాళ్లు మరియు ఆప్టిమైజేషన్లు -By mastering these concepts, you'll be better equipped to build applications that leverage LLMs effectively and efficiently. +ఈ భావనలపై పట్టు సాధించడం ద్వారా, LLMలను సమర్థవంతంగా మరియు ప్రభావవంతంగా ఉపయోగించుకునే అప్లికేషన్‌లను రూపొందించడానికి మీరు మరింత మెరుగ్గా సిద్ధమవుతారు. -Remember that the field of LLM inference is rapidly evolving, with new techniques and optimizations emerging regularly. Stay curious and keep experimenting with different approaches to find what works best for your specific use cases. +LLM ఇన్ఫరెన్స్ రంగం వేగంగా అభివృద్ధి చెందుతోందని, కొత్త టెక్నిక్‌లు మరియు ఆప్టిమైజేషన్‌లు క్రమం తప్పకుండా వస్తున్నాయని గుర్తుంచుకోండి. ఆసక్తిగా ఉండండి మరియు మీ నిర్దిష్ట వినియోగ సందర్భాలకు ఏది ఉత్తమంగా పనిచేస్తుందో కనుగొనడానికి వివిధ విధానాలతో ప్రయోగాలు చేస్తూ ఉండండి. diff --git a/chapters/te/chapter1/9.mdx b/chapters/te/chapter1/9.mdx index b5082b85e..4543b436d 100644 --- a/chapters/te/chapter1/9.mdx +++ b/chapters/te/chapter1/9.mdx @@ -1,15 +1,25 @@ -# Bias and limitations[[bias-and-limitations]] +# పక్షపాతం మరియు పరిమితులు[[bias-and-limitations]] - - -If your intent is to use a pretrained model or a fine-tuned version in production, please be aware that, while these models are powerful tools, they come with limitations. The biggest of these is that, to enable pretraining on large amounts of data, researchers often scrape all the content they can find, taking the best as well as the worst of what is available on the internet. - -To give a quick illustration, let's go back the example of a `fill-mask` pipeline with the BERT model: + { + label: "Google Colab", + value: + "https://colab.research.google.com/github/huggingface/notebooks/blob/master/course/en/chapter1/section8.ipynb", + }, + { + label: "Aws Studio", + value: + "https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/course/en/chapter1/section8.ipynb", + }, + ]} +/> + +మీ ఉద్దేశ్యం ఒక ప్రీట్రైన్డ్ మోడల్ లేదా ఫైన్-ట్యూన్డ్ వెర్షన్‌ను ఉత్పత్తిలో ఉపయోగించాలనుకుంటే, దయచేసి ఈ మోడల్స్ శక్తివంతమైన సాధనాలు అయినప్పటికీ, వాటికి పరిమితులు ఉన్నాయని గుర్తుంచుకోండి. వీటిలో అతిపెద్దది ఏమిటంటే, పెద్ద మొత్తంలో డేటాపై ప్రీట్రైనింగ్‌ను ప్రారంభించడానికి, పరిశోధకులు తరచుగా వారు కనుగొనగలిగిన అన్ని కంటెంట్‌ను స్క్రాప్ చేస్తారు, ఇంటర్నెట్‌లో అందుబాటులో ఉన్న వాటిలో ఉత్తమమైనవి మరియు చెత్తైనవి రెండింటినీ తీసుకుంటారు. + +త్వరగా వివరించడానికి, BERT మోడల్‌తో `fill-mask` పైప్‌లైన్ ఉదాహరణకు తిరిగి వెళ్దాం: ```python from transformers import pipeline @@ -27,6 +37,6 @@ print([r["token_str"] for r in result]) ['nurse', 'waitress', 'teacher', 'maid', 'prostitute'] ``` -When asked to fill in the missing word in these two sentences, the model gives only one gender-free answer (waiter/waitress). The others are work occupations usually associated with one specific gender -- and yes, prostitute ended up in the top 5 possibilities the model associates with "woman" and "work." This happens even though BERT is one of the rare Transformer models not built by scraping data from all over the internet, but rather using apparently neutral data (it's trained on the [English Wikipedia](https://huggingface.co/datasets/wikipedia) and [BookCorpus](https://huggingface.co/datasets/bookcorpus) datasets). +ఈ రెండు వాక్యాలలో తప్పిపోయిన పదాన్ని పూరించమని అడిగినప్పుడు, మోడల్ ఒకే ఒక లింగ-రహిత సమాధానం (waiter/waitress) మాత్రమే ఇస్తుంది. మిగిలినవి సాధారణంగా ఒక నిర్దిష్ట లింగంతో ముడిపడి ఉన్న వృత్తులు -- మరియు అవును, "స్త్రీ" మరియు "పని"తో మోడల్ అనుబంధించే టాప్ 5 అవకాశాలలో prostitute చేరింది. BERT ఇంటర్నెట్ నుండి డేటాను స్క్రాప్ చేయడం ద్వారా నిర్మించబడని అరుదైన Transformer మోడల్స్‌లో ఒకటి అయినప్పటికీ ఇది జరుగుతుంది, బదులుగా తటస్థ డేటాను ఉపయోగించి (ఇది [English Wikipedia](https://huggingface.co/datasets/wikipedia) మరియు [BookCorpus](https://huggingface.co/datasets/bookcorpus) డేటాసెట్‌లపై శిక్షణ పొందింది). -When you use these tools, you therefore need to keep in the back of your mind that the original model you are using could very easily generate sexist, racist, or homophobic content. Fine-tuning the model on your data won't make this intrinsic bias disappear. +మీరు ఈ సాధనాలను ఉపయోగించినప్పుడు, మీరు ఉపయోగిస్తున్న అసలు మోడల్ చాలా సులభంగా సెక్సిస్ట్, జాతి వివక్షతో కూడిన లేదా హోమోఫోబిక్ కంటెంట్‌ను రూపొందించగలదని మీరు గుర్తుంచుకోవాలి. మీ డేటాపై మోడల్‌ను ఫైన్-ట్యూన్ చేయడం ఈ అంతర్గత పక్షపాతాన్ని తొలగించదు.