Skip to content

Instantly share code, notes, and snippets.

@fmnobar
Created April 10, 2023 22:55
Show Gist options
  • Save fmnobar/6903854edb43173ec0cb712e6ea194b4 to your computer and use it in GitHub Desktop.
Save fmnobar/6903854edb43173ec0cb712e6ea194b4 to your computer and use it in GitHub Desktop.
HuggingFace - NLP
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"id": "b04d77ac-92ed-43a0-bd4b-7085b63a889c",
"metadata": {},
"source": [
"# Implement NLP Tasks Using Hugging Face\n",
"\n",
"Hugging Face is an open-source community for machine learning practitioners with a focus on Natural Language Processing (NLP), computer vision and audio/speech processing tasks. Whether you already work in this space or aspire to enter this realm in the future, you will benefit from learning how to use Hugging Face tools and models. \n",
"\n",
"In this post we are going to go over some of the most frequently used NLP tasks by leveraging pre-trained models available on Hugging Face. \n",
"\n",
"Before jumping into the tasks, let's take a minute to talk about the distinction between \"Training\" and \"Inference\", which are two important concepts in machine learning, in order to clarify what we will be working on today. \n",
"\n",
"## Training vs. Inference in Machine Learning\n",
"\n",
"Training is the process of feeding a machine learning model with large amounts of data. During this process the model \"learns\" from the provided data (by optimizing an objective function) and hence this process is called \"Training\". Once we have a trained model, we can use it to make predictions in new data that model has not seen before. This process is called \"Inference\". In short, training is the learning process for the model, while inference is the model making predictions (i.e. when we actually use the model). \n",
"\n",
"Now that we understand the distinction between training and inference, we can more concretely define what we will be working on today. In this post, we will be using some pre-trained models for inference. In other words, we would not be going through the expensive process of training any new models here. On the other hand, we are going to leverage the myriad of existing pre-trained models in the Hugging Face Hub and use those to make predictions. \n",
"\n",
"Let's get started!\n",
"\n",
"## 1. Text Generation (a.k.a. Language Modeling)\n",
"\n",
"I decided to start with this task, given the recent hiked interest about Generative AI such as ChatGPT. This task is usually called language modeling and the task that the models perform usually is to predict missing parts of text (this can be a word, token or larger strings of text). What has attracted a lot of interest recently is that the models can generate text without necessarily having seen such prompts before. \n",
"\n",
"Let's see how it works in practice!\n",
"\n",
"### 1.1. Text Generation - Implementation\n",
"\n",
"In order to implement text generation, we will use `pipeline` from `transformers` library, use one of the GPT models and take the steps below. I have also added comments in the code so that you can more easily follow the steps:\n",
"\n",
"1. Import libraries\n",
"2. Specify the name of the pre-trained model to be used for this specific task\n",
"3. Specify the sentence, which will be completed by the model\n",
"4. Create an instance of `pipeline` as `generator`\n",
"5. Perform the text generation and store the results as `output`\n",
"6. Return the results"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "f1b16b22-7adc-4135-bd04-1fa13488aa79",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Setting `pad_token_id` to `eos_token_id`:50256 for open-end generation.\n"
]
},
{
"data": {
"text/plain": [
"[{'generated_text': 'If you are interested in learing more about data science, I can teach you how to set up a free demo from your favorite data science courses on the free Github repo.\\n\\nI can teach you some basic techniques to extract and analyze'}]"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Import libraries\n",
"from transformers import pipeline\n",
"\n",
"# Specify the model\n",
"model = \"gpt2\"\n",
"\n",
"# Specify the task\n",
"task = \"text-generation\"\n",
"\n",
"# Instantiate pipeline\n",
"generator = pipeline(model = model, task = task, max_new_tokens = 30)\n",
"\n",
"# Specify input text\n",
"input_text = \"If you are interested in learing more about data science, I can teach you how to\"\n",
"\n",
"# Perform text generation and store the results\n",
"output = generator(input_text)\n",
"\n",
"# Return the results\n",
"output"
]
},
{
"cell_type": "markdown",
"id": "7af34922-5881-444e-8b77-a4025ac1c068",
"metadata": {},
"source": [
"We can see in the results that the model took our provided input text and generated additional text, given the data it has been trained on and the sentence that we provided. Note that I limited the length of the output using the `max_new_tokens` to 30 tokens to prevent a lengthy response. The generated text sounds reasonable and relevant to context. \n",
"\n",
"But what about a case where we would like to ask a question from the model? Can the model answer a question, instead of just completing an incomplete sentence? Let's explora that next. \n",
"\n",
"## 2. Question Answering\n",
"\n",
"Question answering, as the name suggests, is a task where the model answers a question provided by the user. There are generally two types of question answering tasks:\n",
"\n",
"1. **Extractive (i.e. context-dependent):** Where we describe a situation to the model in our question/prompt and ask the model to generate a response, given that provided information. In this scenario, the model picks the relevant parts of the information from the prompt and returns the results\n",
"2. **Abstractive (i.e. context-independent):** Where we just ask a question from the model, without providing any context\n",
"\n",
"Let's look at how question answering can be implemented. \n",
"\n",
"### 2.1. Question Answering - Implementation\n",
"\n",
"Implementation process is similar to the language modeling task. We will use two different models to be able to compare the results. \n",
"\n",
"Let's start with the `distilbert-base-cased-distilled-squad` model ([link](https://huggingface.co/distilbert-base-cased-distilled-squad)). "
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "af1bf614-a91d-4067-b80b-d42de4fd32ad",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"score: 0.3341, start: 65, end: 92, answer: natural language processing\n"
]
}
],
"source": [
"# Specify model\n",
"model = 'distilbert-base-cased-distilled-squad'\n",
"\n",
"# Instantiate pipeline\n",
"answerer = pipeline(model = model, task=\"question-answering\")\n",
"\n",
"# Specify question and context\n",
"question = \"What does NLP stand for?\"\n",
"context = \"Today we are talking about machine learning and specifically the natural language processing, which enables computers to understand, process and generate languages\"\n",
"\n",
"# Generate predictions\n",
"preds = answerer(\n",
" question = question,\n",
" context = context,\n",
")\n",
"\n",
"# Return results\n",
"print(\n",
" f\"score: {round(preds['score'], 4)}, start: {preds['start']}, end: {preds['end']}, answer: {preds['answer']}\"\n",
")"
]
},
{
"cell_type": "markdown",
"id": "4f36f2a7-491a-4b3c-9f35-43668097d14e",
"metadata": {},
"source": [
"We can see the summary and the model was able to determine which part of the context was relevant to answer the question. \n",
"\n",
"let's implement the same problem using a different model, named `deepset/roberta-base-squad2` ([link](https://huggingface.co/deepset/roberta-base-squad2))."
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "10bb1edb-7f40-454b-aff6-4ba91a55a46c",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'score': 0.04662786424160004,\n",
" 'start': 65,\n",
" 'end': 92,\n",
" 'answer': 'natural language processing'}"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Specify model\n",
"model = \"deepset/roberta-base-squad2\"\n",
"\n",
"# Specify task\n",
"task = \"question-answering\"\n",
"\n",
"# Instantiate pipeline\n",
"answerer = pipeline(task = task, model = model, tokenizer = model)\n",
"\n",
"# Specify input\n",
"qa_input = {\n",
" 'question': 'What does NLP stand for?',\n",
" 'context': 'Today we are talking about machine learning and specifically the natural language processing, which enables computers to understand, process and generate languages'\n",
"}\n",
"\n",
"# Generate predictions\n",
"output = answerer(qa_input)\n",
"\n",
"# Return results\n",
"output"
]
},
{
"cell_type": "markdown",
"id": "d8b496d8-7a4c-43e0-a3c7-7eac21af0e84",
"metadata": {},
"source": [
"As we see in the above example, the second model was also able to identify that NLP stands for natural language processing, given the context that we provided.\n",
"\n",
"Let's continue our journey in the NLP tasks by looking at sentiment analysis next. \n",
"\n",
"## 3. Sentiment Analysis\n",
"\n",
"Sentiment analysis is the process of categorizing the sentiment of a text into positive, negative or neutral. There is a wide range of applications for sentiment analysis in different industries, such as monitoring customers' sentiment (think about customer product review) or even in politics (such as gauging public interest in a given topic during an election year). Focus of this post is to use Hugging Face for various tasks so we will not dive deeper into each topic but if you are interested in learning more about sentiment analysis in depth, you can refer to this post:\n",
"\n",
"[Sentiment Analysis - Intro and Implementation](https://towardsdatascience.com/sentiment-analysis-intro-and-implementation-ddf648f79327)\n",
"\n",
"### 3.1. Sentiment Analysis - Implementation\n",
"\n",
"In order to implement sentiment analysis, we will use `pipeline` from `transformers` library and take the steps below. I have also added comments in the code so that you can more easily follow the steps:\n",
"\n",
"1. Import libraries\n",
"2. Specify the name of the pre-trained model to be used for this specific task (i.e. sentiment analysis)\n",
"3. Specify the task (i.e. sentiment analysis)\n",
"4. Specify the sentence, which will be sentiment analyzed\n",
"5. Create an instance of `pipeline` as `analyzer`\n",
"6. Perform the sentiment analysis and save the results as `output`\n",
"7. Return the results"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "f256a6da-08d2-4f5b-bdf5-5be8569aa266",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[{'label': 'POSITIVE', 'score': 0.8548848628997803}]"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Specify pre-trained model to use\n",
"model = 'distilbert-base-uncased-finetuned-sst-2-english'\n",
"\n",
"# Specify task\n",
"task = 'sentiment-analysis'\n",
"\n",
"# Text to be analyzed\n",
"input_text = 'Performing NLP tasks using HuggingFace pipeline is super easy!'\n",
"\n",
"# Instantiate pipeline\n",
"analyzer = pipeline(task, model = model)\n",
"\n",
"# Store the output of the analysis\n",
"output = analyzer(input_text)\n",
"\n",
"# Return output\n",
"output"
]
},
{
"cell_type": "markdown",
"id": "dde6abd0-819d-456d-a883-d4c6da0fed4d",
"metadata": {},
"source": [
"The results indicate that the sentiment of the sentence is a positive one with a score of ~85%. The sentence sounds pretty positive to me so I like the results so far. Feel free to replicate the process for other sentences and test it out!\n",
"\n",
"Let's move on to a different type of text classification. \n",
"\n",
"## 4. Text Classification\n",
"\n",
"Sentiment analysis can be considered a special case of text classification, where the categories (or classes) are only positive, negative or neutral. Text classification is more generic in that it can classify (or categorize) the incoming text (e.g. sentence, paragraph or document) into pre-defined classes. \n",
"\n",
"### 4.1. Text Classification - Implementation\n",
"\n",
"We will use the same `pipeline` package and take steps very similar to what we did for sentiment analysis, as follows:"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "3a83b9ad-44e7-4309-aae5-f9636dc3426b",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'sequence': 'This is a tutorial about using pre-trained models through HuggingFace',\n",
" 'labels': ['education', 'business', 'music', 'sports', 'politics'],\n",
" 'scores': [0.40113750100135803,\n",
" 0.21706841886043549,\n",
" 0.14547283947467804,\n",
" 0.1450752168893814,\n",
" 0.09124604612588882]}"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Specify model\n",
"model = 'facebook/bart-large-mnli'\n",
"\n",
"# Specify Task\n",
"task = 'zero-shot-classification'\n",
"\n",
"# Specify input text\n",
"input_text = 'This is a tutorial about using pre-trained models through HuggingFace'\n",
"\n",
"# Identify the classes/categories/labels\n",
"labels = ['business', 'sports', 'education', 'politics', 'music']\n",
"\n",
"# Instantiate pipeline\n",
"classifier = pipeline(task, model = model)\n",
"\n",
"# Store the output of the analysis\n",
"output = classifier(input_text, candidate_labels = labels)\n",
"\n",
"# Return output\n",
"output"
]
},
{
"cell_type": "markdown",
"id": "53d760e7-96d0-4bdc-b3b1-9481aa657350",
"metadata": {},
"source": [
"Results are quite interesting. The scores correspond to each label, sorted from largest to smallest for ease of reading. For example, the results indicate that our sentence is labeled as \"education\" with a score of ~40%, followed by \"business\" by ~22%, while labels for \"music\", \"sports\" and \"politics\" have very low scores, which makes sense to me overall. \n",
"\n",
"Let's move on to our next task, which is summarization. \n",
"\n",
"## 5. Text Summarization\n",
"\n",
"Text summarization is the task of automatically summarizing textual input, while still conveying the main points and gist of the incoming text. One example of the business intuition behind the need for such summarization models is the situations where humans read incoming text communications (e.g. customer emails) and using a summarization model can save human time. For example, these human representatives can read the summary of the emails instead of the entire email, resulting in improved operational efficiency by saving human time and cost.\n",
"\n",
"Let's look at how we can implement text summarization. \n",
"\n",
"### 5.1. Text Summarization - Implementation\n",
"\n",
"Similar to other tasks, we will use the `pipeline` for a summarization task. For this specific task, we will be using a text-to-text pre-rained model from Google named [T5](https://github.com/google-research/text-to-text-transfer-transformer) to summarize the description that we just read about \"Text Summarization\" in the section above. Let's see how we can implement this. "
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "517d1c12-4c0a-4721-a7a5-2a7c7d5c9c72",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"All model checkpoint layers were used when initializing TFT5ForConditionalGeneration.\n",
"\n",
"All the layers of TFT5ForConditionalGeneration were initialized from the model checkpoint at t5-base.\n",
"If your task is similar to the task the model of the checkpoint was trained on, you can already use TFT5ForConditionalGeneration for predictions without further training.\n",
"Your max_length is set to 200, but you input_length is only 82. You might consider decreasing max_length manually, e.g. summarizer('...', max_length=41)\n"
]
},
{
"data": {
"text/plain": [
"[{'summary_text': 'text summarization is the task of automatically summarizing textual input . using a model can save human time in situations where humans read incoming text .'}]"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Specify model and tokenizer\n",
"model = \"t5-base\"\n",
"tokenizer = \"t5-base\"\n",
"\n",
"# Specify task\n",
"task = \"summarization\"\n",
"\n",
"# Specify input text\n",
"input_text = \"Text summarization is the task of automatically summarizing textual input, while still conveying the main points and gist of the incoming text. One example of the business intuition behind the need for such summarization models is the situations where humans read incoming text communications (e.g. customer emails) and using a summarization model can save human time. \"\n",
"\n",
"# Instantiate pipeline\n",
"summarizer = pipeline(task = task, model = model, tokenizer = tokenizer, framework = \"tf\")\n",
"\n",
"# Summarize and store results\n",
"output = summarizer(input_text)\n",
"\n",
"# Return output\n",
"output"
]
},
{
"cell_type": "markdown",
"id": "e2a93a2b-211e-49dc-85c1-6e22c2cda509",
"metadata": {},
"source": [
"As you see in the results, the T5 model took the input text, which was rather long, and returned a brief summary of what it considered the main points of the input text. I like the summary since it explains what text summarization is and what benefits it can provide - that's a good summary!\n",
"\n",
"Let's try another model from Google named [Pegasus](https://huggingface.co/google/pegasus-cnn_dailymail) to see if and how the results change, when we use a different model."
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "bdc4d3ff-e703-42cd-a2a4-5fc69c68e884",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Your max_length is set to 75, but you input_length is only 71. You might consider decreasing max_length manually, e.g. summarizer('...', max_length=35)\n"
]
},
{
"data": {
"text/plain": [
"[{'summary_text': 'Sumomarization is the task of automatically summarizing textual input, while still conveying the main points and gist of the incoming text .<n>One example of the business intuition behind the need for such summarization models is the situations where humans read incoming text communications .'}]"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Specify model\n",
"model = 'google/pegasus-cnn_dailymail'\n",
"\n",
"# Specify task\n",
"task = 'summarization'\n",
"\n",
"# Specify inpute text\n",
"input_text = \"Text summarization is the task of automatically summarizing textual input, while still conveying the main points and gist of the incoming text. One example of the business intuition behind the need for such summarization models is the situations where humans read incoming text communications (e.g. customer emails) and using a summarization model can save human time. \"\n",
"\n",
"# Instantiate pipeline\n",
"summarizer = pipeline(task = task, model = model)\n",
"\n",
"# Summarize and store results\n",
"output = summarizer(input_text, max_length = 75, min_length = 25)\n",
"\n",
"# Return output\n",
"output"
]
},
{
"cell_type": "markdown",
"id": "0c02bb5a-d281-4061-9866-6186447781ff",
"metadata": {},
"source": [
"As expected, resulting outputs of the two models defer, since they are each trained using specific data and training objectives but both somehow accomplished the task. I persoanlly prefer the outcome of the T5 model, since it more succinctly states the point of the input text. \n",
"\n",
"Last, but not the least task that we will be looking at is machine translation. \n",
"\n",
"## 6. Machine Translation\n",
"\n",
"Machine translation is the task of generating the translation of an input text in a target language. This is similar to what Google Translate or other similar translation engines provide. One of the benefits of using Hugging Face for machine translation is that we get to choose what model to use for our translation, which can potentially provide a more accurate translation for the specific language that we are looking for. \n",
"\n",
"Let's look at the implementation of machine translation in Hugging Face. \n",
"\n",
"### 6.1. Machine Translation - Implementation\n",
"\n",
"In order to generate translations, we will use two of the most common pre-trained models to translate the same sentence from English to French. Implementation of each slightly varies but the overall process is the same as other tasks that we have implemented so far. \n",
"\n",
"#### 6.1.1. T5\n",
"[T5](https://huggingface.co/docs/transformers/model_doc/t5) is an encoder-decoder model developed by Google, which works well on multiple tasks, including machine translation. In order to prompt T5 to perform a tasks such as translation from language X to language Y, we will add a string (called a \"prefix\") to the sentence to the input of each task follows: `\"translate X to Y: sentence_to_be_translated\"`. \n",
"\n",
"This is actually easier in practice to understand so let's just translate a sentence from English to French using T5 and see how it works."
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "ec6f6466-3f5b-432b-b4cb-df9b58eb7b1c",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/mafarzad/opt/anaconda3/lib/python3.9/site-packages/transformers/pipelines/__init__.py:955: UserWarning: \"translation\" task was used, instead of \"translation_XX_to_YY\", defaulting to \"translation_en_to_de\"\n",
" warnings.warn(\n"
]
},
{
"data": {
"text/plain": [
"[{'translation_text': \"Il s'agit d'un poste sur Medium sur diverses tâches de NLP utilisant Hugging Face.\"}]"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Specify prefix\n",
"original_language = 'English'\n",
"target_language = 'French'\n",
"prefix = f\"translate {original_language} to {target_language}: \"\n",
"\n",
"# Specify input text\n",
"input_text = f\"{prefix}This is a post on Medium about various NLP tasks using Hugging Face.\"\n",
"\n",
"# Specify model\n",
"model = \"t5-base\"\n",
"\n",
"# Specify task\n",
"task = \"translation\"\n",
"\n",
"# Instantiate pipeline\n",
"translator = pipeline(task = task, model = model)\n",
"\n",
"# Perform translation and store the output\n",
"output = translator(input_text)\n",
"\n",
"# Return output\n",
"output"
]
},
{
"cell_type": "markdown",
"id": "3d43e42d-9a9b-4944-a3ea-bf4f59002ae5",
"metadata": {},
"source": [
"I looked up this translation on Google Translate and this looks like a good translation! I do not know what exact model Google Translate uses for translation but we will see how much the results vary when we run the same translation task using mBART in the next section. \n",
"\n",
"#### 6.1.2. mBART\n",
"[mBART](https://huggingface.co/docs/transformers/model_doc/mbart) is a multilingual encoder-decoder model developed by Meta, which is primarily intended for machine translation tasks. mBART, unlike T5, does not require the prefix in the prompt but we need to identify the original and target languges to the model.\n",
"\n",
"Let's implement the same task in mBART. "
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "5529f426-52a9-4998-8b4b-1d22d1d0c95d",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/mafarzad/opt/anaconda3/lib/python3.9/site-packages/transformers/generation/utils.py:1288: UserWarning: Using `max_length`'s default (200) to control the generation length. This behaviour is deprecated and will be removed from the config in v5 of Transformers -- we recommend using `max_new_tokens` to control the maximum length of the generation.\n",
" warnings.warn(\n"
]
},
{
"data": {
"text/plain": [
"[\"Il s'agit d'un post sur Medium sur diverses tâches NLP utilisant Hugging Face.\"]"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Import packages\n",
"from transformers import MBartForConditionalGeneration, MBart50TokenizerFast\n",
"\n",
"# Specify input text\n",
"input_text = \"This is a post on Medium about various NLP tasks using Hugging Face.\"\n",
"\n",
"# Specify model\n",
"model_name = \"facebook/mbart-large-50-many-to-many-mmt\"\n",
"\n",
"# Instantiate model and tokenizer\n",
"model = MBartForConditionalGeneration.from_pretrained(model_name)\n",
"tokenizer = MBart50TokenizerFast.from_pretrained(model_name)\n",
"\n",
"# Specify source language\n",
"tokenizer.src_lang = \"en_XX\"\n",
"\n",
"# Encode input text\n",
"encoded_en = tokenizer(input_text, return_tensors=\"pt\")\n",
"\n",
"# Perform translation to the target language\n",
"generated_tokens = model.generate(**encoded_en, forced_bos_token_id=tokenizer.lang_code_to_id[\"fr_XX\"])\n",
"\n",
"# Decode the translation and store the output\n",
"output = tokenizer.batch_decode(generated_tokens, skip_special_tokens=True)\n",
"\n",
"# Return output\n",
"output"
]
},
{
"cell_type": "markdown",
"id": "66982b73-92eb-41ab-940a-aff0116e8432",
"metadata": {},
"source": [
"Results seem very similar to what T5 generated, with the exception of \"poste\" having been replaced by \"post\". Regardless of the difference between the two outcomes, the main point of the exercise was to demonstrate how these pre-trained models can generate machine translation, which we have accomplished using both models. \n",
"\n",
"## Conclusion\n",
"\n",
"In this post we introduced Hugging Face, an open-source AI community used by many machine learning practitioners in NLP, computer vision and audio/speech processing tasks. We then walked through implementation of such pre-trained models within the Hugging Face platform to accomplish downstream NLP tasks, such as text generation, question answering, sentiment analysis, text classification, text summarization and machine translation. \n",
"\n",
"## References\n",
"\n",
"- [Hugging Face's Pipeline](https://huggingface.co/docs/transformers/v4.27.2/en/main_classes/pipelines#transformers.pipeline)\n",
"- [Tasks within pipeline in HuggingFace](https://huggingface.co/docs/transformers/v4.27.2/en/main_classes/pipelines#transformers.pipeline.task)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0b849fcd-82eb-44cc-bb21-5b0a042eecb5",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment