Name: Towards AI Legal Name: Towards AI, Inc. Description: Towards AI is the world's leading artificial intelligence (AI) and technology publication. Read by thought-leaders and decision-makers around the world. Phone Number: +1-650-246-9381 Email: pub@towardsai.net
228 Park Avenue South New York, NY 10003 United States
Website: Publisher: https://towardsai.net/#publisher Diversity Policy: https://towardsai.net/about Ethics Policy: https://towardsai.net/about Masthead: https://towardsai.net/about
Name: Towards AI Legal Name: Towards AI, Inc. Description: Towards AI is the world's leading artificial intelligence (AI) and technology publication. Founders: Roberto Iriondo, , Job Title: Co-founder and Advisor Works for: Towards AI, Inc. Follow Roberto: X, LinkedIn, GitHub, Google Scholar, Towards AI Profile, Medium, ML@CMU, FreeCodeCamp, Crunchbase, Bloomberg, Roberto Iriondo, Generative AI Lab, Generative AI Lab Denis Piffaretti, Job Title: Co-founder Works for: Towards AI, Inc. Louie Peters, Job Title: Co-founder Works for: Towards AI, Inc. Louis-François Bouchard, Job Title: Co-founder Works for: Towards AI, Inc. Cover:
Towards AI Cover
Logo:
Towards AI Logo
Areas Served: Worldwide Alternate Name: Towards AI, Inc. Alternate Name: Towards AI Co. Alternate Name: towards ai Alternate Name: towardsai Alternate Name: towards.ai Alternate Name: tai Alternate Name: toward ai Alternate Name: toward.ai Alternate Name: Towards AI, Inc. Alternate Name: towardsai.net Alternate Name: pub.towardsai.net
5 stars – based on 497 reviews

Frequently Used, Contextual References

TODO: Remember to copy unique IDs whenever it needs used. i.e., URL: 304b2e42315e

Resources

Take our 85+ lesson From Beginner to Advanced LLM Developer Certification: From choosing a project to deploying a working product this is the most comprehensive and practical LLM course out there!

Publication

A Journey into the Fabulous Applications of Transformers — Part 2
Latest   Machine Learning

A Journey into the Fabulous Applications of Transformers — Part 2

Last Updated on July 25, 2023 by Editorial Team

Author(s): Dr. Dharini R

Originally published on Towards AI.

Demo with Emphasis on NLP using Python, Hugging Face

Photo by Samule Sun on Unsplash

Transformer architecture is widely used in Natural Language Processing and it highly contributed to the need-of-the-hour Large Language Models (LLM). With the rise of transfer learning in NLP using LLMs, many models are built and shared with the research community in Hugging Face.

We are going to see some of the intriguing applications of transformers in NLP with demos and explanations. This article is a continuation of a previous one linked below.

A Journey into the Fabulous Applications of Transformers — Part 1

Demo with Emphasis on NLP using Python, Hugging Face.

pub.towardsai.net

The hugging face models used in this article can also be used as a Plug-and-Play model using the Accelerated Inference API. Kindly refer to this article to know more about how to utilize a model using its API.

Plug-and-Play ML Models with ‘Accelerated Inference API’ from Hugging Face

With a 4-Step guide to python implementation

blog.jovian.ai

The demo code for all the applications discussed, along with the Colab link, is given in this GitHub link. Being an introductory article, the details about the models discussed are linked in the respective sections. For all the applications to work (except for sentence similarity), we need to install transformers library using pip install transformers.

The applications we are going to see in this article are

6. Translation

7. Token Classification

8. Sentence Similarity

9. Zero-shot Classification

10. Fill Mask

6. Translation

An interesting and useful application with transformers is the ability to translate text between languages. Several models are available for the translation task, depending on the languages being used in the training phase.

In our example, we are going to translate an English language text into Italian language. To know what model can perform the translation, we have to explore the Hugging Face library. The model named Helsinki-NLP/opus-mt-en-it performs this translation, and we will use that for our demo.

The first step is to instantiate the pipeline with the task translation.The task name varies according to the languages being dealt with. More information on the translation of the text in different languages, the corresponding models, and the datasets can be found in this link.

In our case, the task is translation_en_to_it and is given along with the model name as follows.

from transformers import pipeline
text_translator = pipeline("translation_en_to_it", model="Helsinki-NLP/opus-mt-en-it")

input_text is stored with the English sentence that we wish to translate.

input_text = "This text is translated from English to Italian"

In the following line, we load the input to our model and store the output in italian_text. On printing the same, we get the translated version of our input.

italian_text = text_translator(input_text, clean_up_tokenization_spaces=True)
print(italian_text)
Output:
[{'translation_text': "Questo testo è tradotto dall'inglese all'italiano"}]

7. Token Classification

Token classification is the task of assigning a tag/label to words present in the text. An individual word in the sentence is called a token. Examples of token classification are Named Entity Recognition(NER) and Part-of-Speech(PoS) tagging.

We have covered NER in the first part of our article, and so here we will look at the second task, PoS tagging. Part-of-Speech tagging is the process of identifying the corresponding part of speech of a word and labeling it with tags like nouns, pronouns, adjectives, adverbs etc, in a sentence.

We begin by importing pipeline and instantiating it with the task token-classification.

from transformers import pipeline

pos_classifier = pipeline("token-classification", model = "vblagoje/bert-english-uncased-finetuned-pos")

As given above, the model we have used is vblagoje/bert-english-uncased-finetuned-pos. Now we shall classify the tokens and display them.

tags = pos_classifier("Hello I am happy when I see waterfalls.")
print(tags)

Output:
[{'entity': 'INTJ', 'score': 0.9958117, 'index': 1, 'word': 'hello', 'start': 0, 'end': 5}, {'entity': 'PRON', 'score': 0.9995704, 'index': 2, 'word': 'i', 'start': 6, 'end': 7}, {'entity': 'AUX', 'score': 0.9966484, 'index': 3, 'word': 'am', 'start': 8, 'end': 10}, {'entity': 'ADJ', 'score': 0.99829704, 'index': 4, 'word': 'happy', 'start': 11, 'end': 16}, {'entity': 'ADV', 'score': 0.99861526, 'index': 5, 'word': 'when', 'start': 17, 'end': 21}, {'entity': 'PRON', 'score': 0.9995561, 'index': 6, 'word': 'i', 'start': 22, 'end': 23}, {'entity': 'VERB', 'score': 0.99941325, 'index': 7, 'word': 'see', 'start': 24, 'end': 27}, {'entity': 'NOUN', 'score': 0.9958626, 'index': 8, 'word': 'waterfalls', 'start': 28, 'end': 38}, {'entity': 'PUNCT', 'score': 0.9996631, 'index': 9, 'word': '.', 'start': 38, 'end': 39}]

To see the output clearly, we shall import pandas and create a dataframe of the result and see the output as shown below.

import pandas as pd
df_tags = pd.DataFrame(tags)
print(df_tags)

Output:
entity score index word start end
0 INTJ 0.995812 1 hello 0 5
1 PRON 0.999570 2 i 6 7
2 AUX 0.996648 3 am 8 10
3 ADJ 0.998297 4 happy 11 16
4 ADV 0.998615 5 when 17 21
5 PRON 0.999556 6 i 22 23
6 VERB 0.999413 7 see 24 27
7 NOUN 0.995863 8 waterfalls 28 38
8 PUNCT 0.999663 9 . 38 39

8. Sentence Similarity

An interesting application with transformers is the ability to extract sentence embeddings that captures semantic information. A sentence embedding is the numerical representation of a whole sentence and is used as input to the model. In our example, we will use a sentence transformer to generate sentence embeddings and use it to identify the similarity between two sentences.

For this example, we have to install sentence-transformers library from hugging face, unlike the other applications where we will install transformers library. There are many models available for the task of sentence similarity, and we are going to use the model sentence-transformers/all-MiniLM-L6-v2 in our example.

The first step is to import SentenceTransformer and util as shown below. The util package is needed to use the cosine similarity function to measure the distance between the two embeddings.

!pip install sentence-transformers
from sentence_transformers import SentenceTransformer, util

Next step, we load the input_sentences with sentences that we would like to try our model with. We give the specific model name to be used to the SentenceTransformer.

similarity_model = SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2')
input_sentences = ["I'm happy", "I'm not sad"]

In the next step, we extract the embedding for both sentences. The embeddings for both sentences are stored in separate variables.

embedding_1= similarity_model.encode(input_sentences[0], convert_to_tensor=True)
embedding_2 = similarity_model.encode(input_sentences[1], convert_to_tensor=True)

In the last step, we utilize the cos_sim function from util to calculate the distance between two vectors (embeddings)

print(util.pytorch_cos_sim(embedding_1, embedding_2))
Output:
tensor([[0.4624]])

The more the value closer to 1, the more the similarity between the sentences. If the value is closer to 0, we can understand that the sentences are not similar.

9. Zero-shot classification

Zero-shot classification has its root in Zero-shot learning which basically means a classifier is trained with one set of labels and tested with a different set of labels. The evaluating set of labels is not seen by the model at all.

This means we can take a zero-shot classification model, give input and also give labels of our own. The model will classify the text according to the labels given by us, even though the model was not trained by any of these labels. Now we will try out the same in our demo. Let us start by instantiating the pipeline with the task zero-shot-classification.

from transformers import pipeline
zero_shot_classifier = pipeline("zero-shot-classification")
Output:
No model was supplied, defaulted to facebook/bart-large-mnli and revision c626438 (https://huggingface.co/facebook/bart-large-mnli).
Using a pipeline without specifying a model name and revision in production is not recommended.
Downloading: 100%
1.15k/1.15k [00:00<00:00, 28.0kB/s]
Downloading: 100%
1.63G/1.63G [00:26<00:00, 63.5MB/s]
Downloading: 100%
26.0/26.0 [00:00<00:00, 467B/s]
Downloading: 100%
899k/899k [00:00<00:00, 5.16MB/s]
Downloading: 100%
456k/456k [00:00<00:00, 2.73MB/s]
Downloading: 100%
1.36M/1.36M [00:00<00:00, 2.71MB/s]

As we have not given a specific model, the model facebook/bart-large-mnli is selected by the library, and the model weights are downloaded and referred with zero_shot_classifier.

The next step is to define the input text and the labels with which we need the classification. Using the zero_shot_classifier, we pass the input text and labels to be classified.

input_sentence = "I am hungry and angry. I think an ice cream will make me feel good"
labels = ['food', 'travel','entertainment','sad','happy','neutral']
results = zero_shot_classifier(input_sentence, labels)
print(results)

Output:
{'sequence': 'I am hungry and angry. I think an ice cream will make me feel good', 'labels': ['food', 'sad', 'entertainment', 'travel', 'neutral', 'happy'], 'scores': [0.8720405101776123, 0.07575708627700806, 0.023996146395802498, 0.010163746774196625, 0.009797507897019386, 0.00824508722871542]}

To see the output clearly, we shall import pandas library and see the result in a data frame. As shown in the below data frame, the score for the labels food and sad are more than the other labels. We can see that the sentence given, relates to the label food more than all the other labels. So we get the highest score in that.

import pandas as pd
df_result = pd.DataFrame(results)
print(df_result.loc[:, ['labels','scores']])
Output:
labels scores
0 food 0.872041
1 sad 0.075757
2 entertainment 0.023996
3 travel 0.010164
4 neutral 0.009798
5 happy 0.008245

10. Fill Mask

The concept of Masked Language Modeling (MLM) deals with predicting words to replace the purposefully masked words in the data. This helps in improving the statistical understanding of the language with which the model is trained and leads to better text representations. The merit of MLM is the self-supervised pretraining that does not need labeled data for training.

The task Fill Mask, thus dealing with masking random words in the given sentence and exploring the various suggestions given by the model for replacing the mask.

Let us start with instantiating pipeline with the fill-mask task as shown below. Since we have not given a specific model, the default model (distilroberta-base) is downloaded.

from transformers import pipeline
fill_mask_clf = pipeline("fill-mask")

Output:
No model was supplied, defaulted to distilroberta-base and revision ec58a5b (https://huggingface.co/distilroberta-base).
Using a pipeline without specifying a model name and revision in production is not recommended.
Downloading: 100%
480/480 [00:00<00:00, 13.5kB/s]
Downloading: 100%
331M/331M [00:08<00:00, 43.4MB/s]
Downloading: 100%
899k/899k [00:00<00:00, 1.56MB/s]
Downloading: 100%
456k/456k [00:00<00:00, 1.77MB/s]
Downloading: 100%
1.36M/1.36M [00:00<00:00, 1.77MB/s]

Now we give a sentence to the model by masking a word in it with the <mask> token. On printing the output, we see five different possible words for the masked word, the corresponding score, the token representation, and the complete sentence with the predicted word.

print(fill_mask_clf("artificial intelligence is going to be <mask> in the future"))

Output:
[{'score': 0.061495572328567505,
'token': 30208,
'token_str': ' commonplace',
'sequence': 'artificial intelligence is going to be commonplace in the future'},
{'score': 0.05322642996907234,
'token': 25107,
'token_str': ' ubiquitous',
'sequence': 'artificial intelligence is going to be ubiquitous in the future'},
{'score': 0.0344822071492672,
'token': 5616,
'token_str': ' useful',
'sequence': 'artificial intelligence is going to be useful in the future'},
{'score': 0.033160075545310974,
'token': 6128,
'token_str': ' everywhere',
'sequence': 'artificial intelligence is going to be everywhere in the future'},
{'score': 0.025654001161456108,
'token': 956,
'token_str': ' needed',
'sequence': 'artificial intelligence is going to be needed in the future'}]

Summary

In these two parts of the article, we went through the most important 10 applications that are achievable with the transformers. The takeaway is that, with the rise of transformers and large language models, complex tasks that would have needed heavy cost and time are now available to use at ease. It also has to be noted that the same model can be used for different tasks.

The idea is to understand the possibilities of a model and fine-tune it for your own purpose. The more we try, the more we learn. Proceed and Succeed!!!

Please find more articles related to NLP in this page.

Thank you!!

Join thousands of data leaders on the AI newsletter. Join over 80,000 subscribers and keep up to date with the latest developments in AI. From research to projects and ideas. If you are building an AI startup, an AI-related product, or a service, we invite you to consider becoming a sponsor.

Published via Towards AI

Feedback ↓

Sign Up for the Course
`; } else { console.error('Element with id="subscribe" not found within the page with class "home".'); } } }); // Remove duplicate text from articles /* Backup: 09/11/24 function removeDuplicateText() { const elements = document.querySelectorAll('h1, h2, h3, h4, h5, strong'); // Select the desired elements const seenTexts = new Set(); // A set to keep track of seen texts const tagCounters = {}; // Object to track instances of each tag elements.forEach(el => { const tagName = el.tagName.toLowerCase(); // Get the tag name (e.g., 'h1', 'h2', etc.) // Initialize a counter for each tag if not already done if (!tagCounters[tagName]) { tagCounters[tagName] = 0; } // Only process the first 10 elements of each tag type if (tagCounters[tagName] >= 2) { return; // Skip if the number of elements exceeds 10 } const text = el.textContent.trim(); // Get the text content const words = text.split(/\s+/); // Split the text into words if (words.length >= 4) { // Ensure at least 4 words const significantPart = words.slice(0, 5).join(' '); // Get first 5 words for matching // Check if the text (not the tag) has been seen before if (seenTexts.has(significantPart)) { // console.log('Duplicate found, removing:', el); // Log duplicate el.remove(); // Remove duplicate element } else { seenTexts.add(significantPart); // Add the text to the set } } tagCounters[tagName]++; // Increment the counter for this tag }); } removeDuplicateText(); */ // Remove duplicate text from articles function removeDuplicateText() { const elements = document.querySelectorAll('h1, h2, h3, h4, h5, strong'); // Select the desired elements const seenTexts = new Set(); // A set to keep track of seen texts const tagCounters = {}; // Object to track instances of each tag // List of classes to be excluded const excludedClasses = ['medium-author', 'post-widget-title']; elements.forEach(el => { // Skip elements with any of the excluded classes if (excludedClasses.some(cls => el.classList.contains(cls))) { return; // Skip this element if it has any of the excluded classes } const tagName = el.tagName.toLowerCase(); // Get the tag name (e.g., 'h1', 'h2', etc.) // Initialize a counter for each tag if not already done if (!tagCounters[tagName]) { tagCounters[tagName] = 0; } // Only process the first 10 elements of each tag type if (tagCounters[tagName] >= 10) { return; // Skip if the number of elements exceeds 10 } const text = el.textContent.trim(); // Get the text content const words = text.split(/\s+/); // Split the text into words if (words.length >= 4) { // Ensure at least 4 words const significantPart = words.slice(0, 5).join(' '); // Get first 5 words for matching // Check if the text (not the tag) has been seen before if (seenTexts.has(significantPart)) { // console.log('Duplicate found, removing:', el); // Log duplicate el.remove(); // Remove duplicate element } else { seenTexts.add(significantPart); // Add the text to the set } } tagCounters[tagName]++; // Increment the counter for this tag }); } removeDuplicateText(); //Remove unnecessary text in blog excerpts document.querySelectorAll('.blog p').forEach(function(paragraph) { // Replace the unwanted text pattern for each paragraph paragraph.innerHTML = paragraph.innerHTML .replace(/Author\(s\): [\w\s]+ Originally published on Towards AI\.?/g, '') // Removes 'Author(s): XYZ Originally published on Towards AI' .replace(/This member-only story is on us\. Upgrade to access all of Medium\./g, ''); // Removes 'This member-only story...' }); //Load ionic icons and cache them if ('localStorage' in window && window['localStorage'] !== null) { const cssLink = 'https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css'; const storedCss = localStorage.getItem('ionicons'); if (storedCss) { loadCSS(storedCss); } else { fetch(cssLink).then(response => response.text()).then(css => { localStorage.setItem('ionicons', css); loadCSS(css); }); } } function loadCSS(css) { const style = document.createElement('style'); style.innerHTML = css; document.head.appendChild(style); } //Remove elements from imported content automatically function removeStrongFromHeadings() { const elements = document.querySelectorAll('h1, h2, h3, h4, h5, h6, span'); elements.forEach(el => { const strongTags = el.querySelectorAll('strong'); strongTags.forEach(strongTag => { while (strongTag.firstChild) { strongTag.parentNode.insertBefore(strongTag.firstChild, strongTag); } strongTag.remove(); }); }); } removeStrongFromHeadings(); "use strict"; window.onload = () => { /* //This is an object for each category of subjects and in that there are kewords and link to the keywods let keywordsAndLinks = { //you can add more categories and define their keywords and add a link ds: { keywords: [ //you can add more keywords here they are detected and replaced with achor tag automatically 'data science', 'Data science', 'Data Science', 'data Science', 'DATA SCIENCE', ], //we will replace the linktext with the keyword later on in the code //you can easily change links for each category here //(include class="ml-link" and linktext) link: 'linktext', }, ml: { keywords: [ //Add more keywords 'machine learning', 'Machine learning', 'Machine Learning', 'machine Learning', 'MACHINE LEARNING', ], //Change your article link (include class="ml-link" and linktext) link: 'linktext', }, ai: { keywords: [ 'artificial intelligence', 'Artificial intelligence', 'Artificial Intelligence', 'artificial Intelligence', 'ARTIFICIAL INTELLIGENCE', ], //Change your article link (include class="ml-link" and linktext) link: 'linktext', }, nl: { keywords: [ 'NLP', 'nlp', 'natural language processing', 'Natural Language Processing', 'NATURAL LANGUAGE PROCESSING', ], //Change your article link (include class="ml-link" and linktext) link: 'linktext', }, des: { keywords: [ 'data engineering services', 'Data Engineering Services', 'DATA ENGINEERING SERVICES', ], //Change your article link (include class="ml-link" and linktext) link: 'linktext', }, td: { keywords: [ 'training data', 'Training Data', 'training Data', 'TRAINING DATA', ], //Change your article link (include class="ml-link" and linktext) link: 'linktext', }, ias: { keywords: [ 'image annotation services', 'Image annotation services', 'image Annotation services', 'image annotation Services', 'Image Annotation Services', 'IMAGE ANNOTATION SERVICES', ], //Change your article link (include class="ml-link" and linktext) link: 'linktext', }, l: { keywords: [ 'labeling', 'labelling', ], //Change your article link (include class="ml-link" and linktext) link: 'linktext', }, pbp: { keywords: [ 'previous blog posts', 'previous blog post', 'latest', ], //Change your article link (include class="ml-link" and linktext) link: 'linktext', }, mlc: { keywords: [ 'machine learning course', 'machine learning class', ], //Change your article link (include class="ml-link" and linktext) link: 'linktext', }, }; //Articles to skip let articleIdsToSkip = ['post-2651', 'post-3414', 'post-3540']; //keyword with its related achortag is recieved here along with article id function searchAndReplace(keyword, anchorTag, articleId) { //selects the h3 h4 and p tags that are inside of the article let content = document.querySelector(`#${articleId} .entry-content`); //replaces the "linktext" in achor tag with the keyword that will be searched and replaced let newLink = anchorTag.replace('linktext', keyword); //regular expression to search keyword var re = new RegExp('(' + keyword + ')', 'g'); //this replaces the keywords in h3 h4 and p tags content with achor tag content.innerHTML = content.innerHTML.replace(re, newLink); } function articleFilter(keyword, anchorTag) { //gets all the articles var articles = document.querySelectorAll('article'); //if its zero or less then there are no articles if (articles.length > 0) { for (let x = 0; x < articles.length; x++) { //articles to skip is an array in which there are ids of articles which should not get effected //if the current article's id is also in that array then do not call search and replace with its data if (!articleIdsToSkip.includes(articles[x].id)) { //search and replace is called on articles which should get effected searchAndReplace(keyword, anchorTag, articles[x].id, key); } else { console.log( `Cannot replace the keywords in article with id ${articles[x].id}` ); } } } else { console.log('No articles found.'); } } let key; //not part of script, added for (key in keywordsAndLinks) { //key is the object in keywords and links object i.e ds, ml, ai for (let i = 0; i < keywordsAndLinks[key].keywords.length; i++) { //keywordsAndLinks[key].keywords is the array of keywords for key (ds, ml, ai) //keywordsAndLinks[key].keywords[i] is the keyword and keywordsAndLinks[key].link is the link //keyword and link is sent to searchreplace where it is then replaced using regular expression and replace function articleFilter( keywordsAndLinks[key].keywords[i], keywordsAndLinks[key].link ); } } function cleanLinks() { // (making smal functions is for DRY) this function gets the links and only keeps the first 2 and from the rest removes the anchor tag and replaces it with its text function removeLinks(links) { if (links.length > 1) { for (let i = 2; i < links.length; i++) { links[i].outerHTML = links[i].textContent; } } } //arrays which will contain all the achor tags found with the class (ds-link, ml-link, ailink) in each article inserted using search and replace let dslinks; let mllinks; let ailinks; let nllinks; let deslinks; let tdlinks; let iaslinks; let llinks; let pbplinks; let mlclinks; const content = document.querySelectorAll('article'); //all articles content.forEach((c) => { //to skip the articles with specific ids if (!articleIdsToSkip.includes(c.id)) { //getting all the anchor tags in each article one by one dslinks = document.querySelectorAll(`#${c.id} .entry-content a.ds-link`); mllinks = document.querySelectorAll(`#${c.id} .entry-content a.ml-link`); ailinks = document.querySelectorAll(`#${c.id} .entry-content a.ai-link`); nllinks = document.querySelectorAll(`#${c.id} .entry-content a.ntrl-link`); deslinks = document.querySelectorAll(`#${c.id} .entry-content a.des-link`); tdlinks = document.querySelectorAll(`#${c.id} .entry-content a.td-link`); iaslinks = document.querySelectorAll(`#${c.id} .entry-content a.ias-link`); mlclinks = document.querySelectorAll(`#${c.id} .entry-content a.mlc-link`); llinks = document.querySelectorAll(`#${c.id} .entry-content a.l-link`); pbplinks = document.querySelectorAll(`#${c.id} .entry-content a.pbp-link`); //sending the anchor tags list of each article one by one to remove extra anchor tags removeLinks(dslinks); removeLinks(mllinks); removeLinks(ailinks); removeLinks(nllinks); removeLinks(deslinks); removeLinks(tdlinks); removeLinks(iaslinks); removeLinks(mlclinks); removeLinks(llinks); removeLinks(pbplinks); } }); } //To remove extra achor tags of each category (ds, ml, ai) and only have 2 of each category per article cleanLinks(); */ //Recommended Articles var ctaLinks = [ /* ' ' + '

Subscribe to our AI newsletter!

' + */ '

Take our 85+ lesson From Beginner to Advanced LLM Developer Certification: From choosing a project to deploying a working product this is the most comprehensive and practical LLM course out there!

'+ '

Towards AI has published Building LLMs for Production—our 470+ page guide to mastering LLMs with practical projects and expert insights!

' + '
' + '' + '' + '

Note: Content contains the views of the contributing authors and not Towards AI.
Disclosure: This website may contain sponsored content and affiliate links.

' + 'Discover Your Dream AI Career at Towards AI Jobs' + '

Towards AI has built a jobs board tailored specifically to Machine Learning and Data Science Jobs and Skills. Our software searches for live AI jobs each hour, labels and categorises them and makes them easily searchable. Explore over 10,000 live jobs today with Towards AI Jobs!

' + '
' + '

🔥 Recommended Articles 🔥

' + 'Why Become an LLM Developer? Launching Towards AI’s New One-Stop Conversion Course'+ 'Testing Launchpad.sh: A Container-based GPU Cloud for Inference and Fine-tuning'+ 'The Top 13 AI-Powered CRM Platforms
' + 'Top 11 AI Call Center Software for 2024
' + 'Learn Prompting 101—Prompt Engineering Course
' + 'Explore Leading Cloud Providers for GPU-Powered LLM Training
' + 'Best AI Communities for Artificial Intelligence Enthusiasts
' + 'Best Workstations for Deep Learning
' + 'Best Laptops for Deep Learning
' + 'Best Machine Learning Books
' + 'Machine Learning Algorithms
' + 'Neural Networks Tutorial
' + 'Best Public Datasets for Machine Learning
' + 'Neural Network Types
' + 'NLP Tutorial
' + 'Best Data Science Books
' + 'Monte Carlo Simulation Tutorial
' + 'Recommender System Tutorial
' + 'Linear Algebra for Deep Learning Tutorial
' + 'Google Colab Introduction
' + 'Decision Trees in Machine Learning
' + 'Principal Component Analysis (PCA) Tutorial
' + 'Linear Regression from Zero to Hero
'+ '

', /* + '

Join thousands of data leaders on the AI newsletter. It’s free, we don’t spam, and we never share your email address. Keep up to date with the latest work in AI. From research to projects and ideas. If you are building an AI startup, an AI-related product, or a service, we invite you to consider becoming a sponsor.

',*/ ]; var replaceText = { '': '', '': '', '
': '
' + ctaLinks + '
', }; Object.keys(replaceText).forEach((txtorig) => { //txtorig is the key in replacetext object const txtnew = replaceText[txtorig]; //txtnew is the value of the key in replacetext object let entryFooter = document.querySelector('article .entry-footer'); if (document.querySelectorAll('.single-post').length > 0) { //console.log('Article found.'); const text = entryFooter.innerHTML; entryFooter.innerHTML = text.replace(txtorig, txtnew); } else { // console.log('Article not found.'); //removing comment 09/04/24 } }); var css = document.createElement('style'); css.type = 'text/css'; css.innerHTML = '.post-tags { display:none !important } .article-cta a { font-size: 18px; }'; document.body.appendChild(css); //Extra //This function adds some accessibility needs to the site. function addAlly() { // In this function JQuery is replaced with vanilla javascript functions const imgCont = document.querySelector('.uw-imgcont'); imgCont.setAttribute('aria-label', 'AI news, latest developments'); imgCont.title = 'AI news, latest developments'; imgCont.rel = 'noopener'; document.querySelector('.page-mobile-menu-logo a').title = 'Towards AI Home'; document.querySelector('a.social-link').rel = 'noopener'; document.querySelector('a.uw-text').rel = 'noopener'; document.querySelector('a.uw-w-branding').rel = 'noopener'; document.querySelector('.blog h2.heading').innerHTML = 'Publication'; const popupSearch = document.querySelector$('a.btn-open-popup-search'); popupSearch.setAttribute('role', 'button'); popupSearch.title = 'Search'; const searchClose = document.querySelector('a.popup-search-close'); searchClose.setAttribute('role', 'button'); searchClose.title = 'Close search page'; // document // .querySelector('a.btn-open-popup-search') // .setAttribute( // 'href', // 'https://medium.com/towards-artificial-intelligence/search' // ); } // Add external attributes to 302 sticky and editorial links function extLink() { // Sticky 302 links, this fuction opens the link we send to Medium on a new tab and adds a "noopener" rel to them var stickyLinks = document.querySelectorAll('.grid-item.sticky a'); for (var i = 0; i < stickyLinks.length; i++) { /* stickyLinks[i].setAttribute('target', '_blank'); stickyLinks[i].setAttribute('rel', 'noopener'); */ } // Editorial 302 links, same here var editLinks = document.querySelectorAll( '.grid-item.category-editorial a' ); for (var i = 0; i < editLinks.length; i++) { editLinks[i].setAttribute('target', '_blank'); editLinks[i].setAttribute('rel', 'noopener'); } } // Add current year to copyright notices document.getElementById( 'js-current-year' ).textContent = new Date().getFullYear(); // Call functions after page load extLink(); //addAlly(); setTimeout(function() { //addAlly(); //ideally we should only need to run it once ↑ }, 5000); }; function closeCookieDialog (){ document.getElementById("cookie-consent").style.display = "none"; return false; } setTimeout ( function () { closeCookieDialog(); }, 15000); console.log(`%c 🚀🚀🚀 ███ █████ ███████ █████████ ███████████ █████████████ ███████████████ ███████ ███████ ███████ ┌───────────────────────────────────────────────────────────────────┐ │ │ │ Towards AI is looking for contributors! │ │ Join us in creating awesome AI content. │ │ Let's build the future of AI together → │ │ https://towardsai.net/contribute │ │ │ └───────────────────────────────────────────────────────────────────┘ `, `background: ; color: #00adff; font-size: large`); //Remove latest category across site document.querySelectorAll('a[rel="category tag"]').forEach(function(el) { if (el.textContent.trim() === 'Latest') { // Remove the two consecutive spaces (  ) if (el.nextSibling && el.nextSibling.nodeValue.includes('\u00A0\u00A0')) { el.nextSibling.nodeValue = ''; // Remove the spaces } el.style.display = 'none'; // Hide the element } }); // Add cross-domain measurement, anonymize IPs 'use strict'; //var ga = gtag; ga('config', 'G-9D3HKKFV1Q', 'auto', { /*'allowLinker': true,*/ 'anonymize_ip': true/*, 'linker': { 'domains': [ 'medium.com/towards-artificial-intelligence', 'datasets.towardsai.net', 'rss.towardsai.net', 'feed.towardsai.net', 'contribute.towardsai.net', 'members.towardsai.net', 'pub.towardsai.net', 'news.towardsai.net' ] } */ }); ga('send', 'pageview'); -->