{"id":28447979,"url":"https://github.com/labmlai/python_autocomplete","last_synced_at":"2026-02-12T22:01:47.539Z","repository":{"id":54462541,"uuid":"286007298","full_name":"labmlai/python_autocomplete","owner":"labmlai","description":"Use Transformers and LSTMs to learn Python source code","archived":false,"fork":false,"pushed_at":"2022-01-18T11:14:57.000Z","size":14256,"stargazers_count":195,"open_issues_count":3,"forks_count":42,"subscribers_count":8,"default_branch":"master","last_synced_at":"2026-01-13T16:31:40.358Z","etag":null,"topics":["autocomplete-python","deep-learning","deep-learning-tutorial","nlp","pytorch"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/labmlai.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-08-08T08:50:00.000Z","updated_at":"2025-12-20T05:51:50.000Z","dependencies_parsed_at":"2022-08-13T16:20:45.223Z","dependency_job_id":null,"html_url":"https://github.com/labmlai/python_autocomplete","commit_stats":null,"previous_names":["lab-ml/python_autocomplete"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/labmlai/python_autocomplete","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/labmlai%2Fpython_autocomplete","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/labmlai%2Fpython_autocomplete/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/labmlai%2Fpython_autocomplete/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/labmlai%2Fpython_autocomplete/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/labmlai","download_url":"https://codeload.github.com/labmlai/python_autocomplete/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/labmlai%2Fpython_autocomplete/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29382863,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-12T20:34:40.886Z","status":"ssl_error","status_checked_at":"2026-02-12T20:23:00.490Z","response_time":55,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["autocomplete-python","deep-learning","deep-learning-tutorial","nlp","pytorch"],"created_at":"2025-06-06T12:08:19.535Z","updated_at":"2026-02-12T22:01:47.515Z","avatar_url":"https://github.com/labmlai.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![PyPI - Python Version](https://badge.fury.io/py/labml-python-autocomplete.svg)](https://badge.fury.io/py/labml-python-autocomplete)\n[![PyPI Status](https://pepy.tech/badge/labml-python-autocomplete)](https://pepy.tech/project/labml-python-autocomplete)\n[![Join Slack](https://img.shields.io/badge/slack-chat-green.svg?logo=slack)](https://join.slack.com/t/labforml/shared_invite/zt-egj9zvq9-Dl3hhZqobexgT7aVKnD14g/)\n[![Twitter](https://img.shields.io/twitter/follow/labmlai?style=social)](https://twitter.com/labmlai?ref_src=twsrc%5Etfw)\n\n# Python Autocomplete\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"/images/vscode_attention.gif?raw=true\" title=\"VSCode plugin\"\u003e\n\u003c/p\u003e\n\n[The full length Python autocompletion Video](https://www.youtube.com/watch?v=ZFzxBPBUh0M) and a [Twitter thread describing how it works](https://twitter.com/labmlai/status/1367444214963838978)\n\nThis is a learning/demo project to show how deep learning can be used to auto complete Python code.\nYou can experiment with LSTM and Transformer models.\nWe also have built a simple VSCode extension to try out the trained models.\n\nTraining\nmodel: [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/lab-ml/python_autocomplete/blob/master/notebooks/train.ipynb)\n\nEvaluating trained\nmodel: [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/lab-ml/python_autocomplete/blob/master/notebooks/evaluate.ipynb)\n\nIt gives quite decent results by saving above 30% key strokes in most files, and close to 50% in some. We calculated key\nstrokes saved by making a single (best)\nprediction and selecting it with a single key.\n\nThe dataset we use is the python code found in repos linked in\n[Awesome-pytorch-list](https://github.com/bharathgs/Awesome-pytorch-list). We download all the repositories as zip\nfiles, extract them, remove non python files and split them randomly to build training and validation datasets.\n\nWe train a character level model without any tokenization of the source code, since it's the simplest.\n\n### Try it yourself\n\n1. Clone this repo\n2. Install requirements from `requirements.txt`\n3. Run `python_autocomplete/create_dataset.py`.\n    * It collects repos mentioned in\n      [PyTorch awesome list](https://github.com/bharathgs/Awesome-pytorch-list)\n    * Downloads the zip files of the repos\n    * Extract the zips\n    * Remove non python files\n    * Collect all python code to `data/train.py` and, `data/eval.py`\n4. Run `python_autocomplete/train.py` to train the model.\n   *Try changing hyper-parameters like model dimensions and number of layers*.\n5. Run `evaluate.py` to evaluate the model.\n\nYou can also run the training notebook on Google Colab.\n\n[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/lab-ml/python_autocomplete/blob/master/notebooks/train.ipynb)\n\n### VSCode extension\n\n1. Clone this repo\n\n2. Install requirements from `requirements.txt`\n\n3. Install npm packages\n\nYou need to have [Node.JS](https://nodejs.dev/) installed\n\n```shell\ncd vscode_extension\nnpm install # This will install the NPM packages\n```\n\n4. Start the server `python_autocomplete/serve.py`\n\n5. Open the extension project (folder) in [VSCode](https://code.visualstudio.com/)\n\n```shell\ncd vscode_extension\ncode . # This will open vscode_extension in VSCode\n```\n\nIf you don't have [VSCode command line launcher](https://code.visualstudio.com/docs/setup/mac#_launching-from-the-command-line)\nstart VSCode and open the project with `File \u003e Open`\n\n6. Run the extension from VSCode\n\n```\nRun \u003e Start Debugging\n```\n\nThis will open another VSCode editor window, with the extension\n\n7. Create or open a python file and start editing!\n\n### Sample\n\nHere's a sample evaluation of a trained transformer model.\n\nColors:\n\n* \u003cspan style=\"color:yellow\"\u003eyellow\u003c/span\u003e: the token predicted is wrong and the user needs to type that character.\n* \u003cspan style=\"color:blue\"\u003eblue\u003c/span\u003e: the token predicted is correct and the user selects it with a special key press,\n  such as TAB or ENTER.\n* \u003cspan style=\"color:green\"\u003egreen\u003c/span\u003e: autocompleted characters based on the prediction\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"/images/python-autocomplete.png?raw=true\" width=\"100%\" title=\"Screenshot\"\u003e\n\u003c/p\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flabmlai%2Fpython_autocomplete","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flabmlai%2Fpython_autocomplete","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flabmlai%2Fpython_autocomplete/lists"}