{ "info": { "author": "CyberZHG", "author_email": "CyberZHG@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.6" ], "description": "# PyTorch GPT-2\n\n[![Travis](https://travis-ci.org/CyberZHG/torch-gpt-2.svg)](https://travis-ci.org/CyberZHG/torch-gpt-2)\n[![Coverage](https://coveralls.io/repos/github/CyberZHG/torch-gpt-2/badge.svg?branch=master)](https://coveralls.io/github/CyberZHG/torch-gpt-2)\n\n## Install\n\n```bash\npip install torch-gpt-2\n```\n\n## Demo\n\n```python\nimport os\nimport sys\nfrom torch_gpt_2 import load_trained_model_from_checkpoint, get_bpe_from_files, generate\n\n\nif len(sys.argv) != 2:\n print('python3 demo.py MODEL_FOLDER')\n sys.exit(-1)\n\n\nmodel_folder = sys.argv[1]\nconfig_path = os.path.join(model_folder, 'hparams.json')\ncheckpoint_path = os.path.join(model_folder, 'model.ckpt')\nencoder_path = os.path.join(model_folder, 'encoder.json')\nvocab_path = os.path.join(model_folder, 'vocab.bpe')\n\n\nprint('Load net from checkpoint...')\nnet = load_trained_model_from_checkpoint(config_path, checkpoint_path)\nprint('Load BPE from files...')\nbpe = get_bpe_from_files(encoder_path, vocab_path)\nprint('Generate text...')\noutput = generate(net, bpe, ['From the day forth, my arm'], length=20, top_k=1)\n\n# If you are using the 117M model and top_k equals to 1, then the result would be:\n# \"From the day forth, my arm was broken, and I was in a state of pain. I was in a state of pain,\"\nprint(output[0])\n```", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/CyberZHG/torch-gpt-2", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "torch-gpt-2", "package_url": "https://pypi.org/project/torch-gpt-2/", "platform": "", "project_url": "https://pypi.org/project/torch-gpt-2/", "project_urls": { "Homepage": "https://github.com/CyberZHG/torch-gpt-2" }, "release_url": "https://pypi.org/project/torch-gpt-2/0.3.0/", "requires_dist": null, "requires_python": "", "summary": "GPT-2 implemented in PyTorch", "version": "0.3.0" }, "last_serial": 4869210, "releases": { "0.3.0": [ { "comment_text": "", "digests": { "md5": "47558bbd8c54c701218030e5d18d3a8f", "sha256": "36c99f38fb8a910a3a38f483f776d4f23c19ddfe46387145afda785cdaff2fd0" }, "downloads": -1, "filename": "torch-gpt-2-0.3.0.tar.gz", "has_sig": false, "md5_digest": "47558bbd8c54c701218030e5d18d3a8f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5939, "upload_time": "2019-02-26T10:43:08", "url": "https://files.pythonhosted.org/packages/7d/5c/d784bde9fc5c2ed4a2d2b0d731c2e361e4acfc3d6d141629d783898a16bb/torch-gpt-2-0.3.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "47558bbd8c54c701218030e5d18d3a8f", "sha256": "36c99f38fb8a910a3a38f483f776d4f23c19ddfe46387145afda785cdaff2fd0" }, "downloads": -1, "filename": "torch-gpt-2-0.3.0.tar.gz", "has_sig": false, "md5_digest": "47558bbd8c54c701218030e5d18d3a8f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5939, "upload_time": "2019-02-26T10:43:08", "url": "https://files.pythonhosted.org/packages/7d/5c/d784bde9fc5c2ed4a2d2b0d731c2e361e4acfc3d6d141629d783898a16bb/torch-gpt-2-0.3.0.tar.gz" } ] }