introduction_cn.ipynb 3.6 KB
Notebook
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "e42aa4df",
   "metadata": {},
   "source": [
    "# GerPT2\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "08fd6403",
   "metadata": {},
   "source": [
    "See the GPT2 model card for considerations on limitations and bias. See the GPT2 documentation for details on GPT2.\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8295e28d",
   "metadata": {},
   "source": [
    "## Comparison to dbmdz/german-gpt2\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c0f50f67",
   "metadata": {},
   "source": [
    "I evaluated both GerPT2-large and the other German GPT2, dbmdz/german-gpt2 on the [CC-100](http://data.statmt.org/cc-100/) dataset and on the German Wikipedia:\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6ecdc149",
   "metadata": {},
   "source": [
    "|                   | CC-100 (PPL) | Wikipedia (PPL) |\n",
    "|-------------------|--------------|-----------------|\n",
    "| dbmdz/german-gpt2 | 49.47        | 62.92           |\n",
    "| GerPT2            | 24.78        | 35.33           |\n",
    "| GerPT2-large      | __16.08__    | __23.26__       |\n",
    "|                   |              |                 |\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3cddd6a8",
   "metadata": {},
   "source": [
    "See the script `evaluate.py` in the [GerPT2 Github repository](https://github.com/bminixhofer/gerpt2) for the code.\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d838da15",
   "metadata": {},
   "source": [
    "## Usage\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "476bf523",
   "metadata": {},
   "outputs": [],
   "source": [
    "!pip install --upgrade paddlenlp"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8f509fec",
   "metadata": {},
   "outputs": [],
   "source": [
    "import paddle\n",
    "from paddlenlp.transformers import AutoModel\n",
    "\n",
    "model = AutoModel.from_pretrained(\"benjamin/gerpt2-large\")\n",
    "input_ids = paddle.randint(100, 200, shape=[1, 20])\n",
    "print(model(input_ids))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d135a538",
   "metadata": {},
   "source": [
    "```\n",
    "@misc{Minixhofer_GerPT2_German_large_2020,\n",
    "author = {Minixhofer, Benjamin},\n",
    "doi = {10.5281/zenodo.5509984},\n",
    "month = {12},\n",
    "title = {{GerPT2: German large and small versions of GPT2}},\n",
    "url = {https://github.com/bminixhofer/gerpt2},\n",
    "year = {2020}\n",
    "}\n",
    "```"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "63e09ad7",
   "metadata": {},
   "source": [
    "## Acknowledgements\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d9dc51e1",
   "metadata": {},
   "source": [
    "Thanks to [Hugging Face](https://huggingface.co) for awesome tools and infrastructure.\n",
    "Huge thanks to [Artus Krohn-Grimberghe](https://twitter.com/artuskg) at [LYTiQ](https://www.lytiq.de/) for making this possible by sponsoring the resources used for training.\n",
    "\n",
    "> 此模型介绍及权重来源于[https://huggingface.co/benjamin/gerpt2-large](https://huggingface.co/benjamin/gerpt2-large),并转换为飞桨模型格式。\n"
   ]
  }
 ],
 "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.7.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}