{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "This notebook regroups the code sample of the video below, which is a part of the [Hugging Face course](https://huggingface.co/course)." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "cellView": "form" }, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "execution_count": null, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#@title\n", "from IPython.display import HTML\n", "\n", "HTML('')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Install the Transformers and Datasets libraries to run this notebook." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "! pip install datasets transformers[sentencepiece]" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from transformers import pipeline" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "model_checkpoint = \"distilbert-base-uncased\"\n", "fill_masker = pipeline(\"fill-mask\", model=model_checkpoint)\n", "fill_masker(\"This is a great [MASK].\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "model_checkpoint = \"huggingface-course/distilbert-base-uncased-finetuned-imdb\"\n", "fill_masker = pipeline(\"fill-mask\", model=model_checkpoint)\n", "fill_masker(\"This is a great [MASK].\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "model_checkpoint = \"Helsinki-NLP/opus-mt-en-fr\"\n", "translator = pipeline(\"translation\", model=model_checkpoint)\n", "translator(\"This plugin automatically translates emails.\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "model_checkpoint = \"huggingface-course/marian-finetuned-kde4-en-to-fr\")\n", "translator = pipeline(\"translation\", model=model_checkpoint)\n", "translator(\"This plugin automatically translates emails.\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "colab": { "name": "What is domain adaptation?", "provenance": [] } }, "nbformat": 4, "nbformat_minor": 4 }