GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - vpj/python_autocomplete: A simple neural network for python autocompletion

BranchesTags
Open more actions menu

Latest commit

 

History

8 Commits
8 Commits

Folders and files

NameName
Last commit message
Last commit date
logs/simple_lstm/2a86d636936d11eab8740dffb016e7b1
logs/simple_lstm/2a86d636936d11eab8740dffb016e7b1
 
 
parser
parser
 
 
.gitignore
.gitignore
 
 
.labml.yaml
.labml.yaml
 
 
LICENSE
LICENSE
 
 
evaluate.py
evaluate.py
 
 
extract_code.py
extract_code.py
 
 
model.py
model.py
 
 
python-autocomplete.png
python-autocomplete.png
 
 
readme.md
readme.md
 
 
requirements.txt
requirements.txt
 
 
train.py
train.py
 
 

Repository files navigation

⭐️ We rewrote a simpler version of this at lab-ml/source_code_modelling and we intend to maintain it for a while

This a toy project we started to see how well a simple LSTM model can autocomplete python code.

It gives quite decent results by saving above 30% key strokes in most files, and close to 50% in some. We calculated key strokes saved by making a single (best) prediction and selecting it with a single key.

We do a beam search to find predictions, upto ~10 characters ahead. So far it's too inefficient, if you are wondering about editor integration.

We train and predict on after cleaning comments, strings and blank lines in python code. The model is trained after tokenizing python code. It seems more efficient than character level prediction with byte-pair encoding.

A saved model is included in this repo. It is trained on tensorflow/models.

Here's a sample evaluation on a source file from validation set. Red characters are when a auto-completion started; i.e. user presses TAB to select the completion. The green character and and the following characters highlighted in gray are auto-completed. As you can see, it starts and ends completions arbitrarily. That is a suggestion could be 'tensorfl' and not the complete identifier 'tensorflow' which can be a little annoying in a real usage scenario. We can limit them to finish on end of tokens to fix that. Also you can notice that it completes across operators as well. Increasing the length of the beam search will let it complete longer pieces of code.

Try it yourself

  1. Clone this repo

  2. Install requirements from requirements.txt

  3. Copy data to ./data/source

  4. Run extract_code.py to collect all python files, encode and merge them into all.py

  5. Run evaluate.py to evaluate the model. I have included a checkpoint in the repo.

  6. Run train.py to train the model

About

A simple neural network for python autocompletion

Topics

autocompletelstmmachine-learningpython

Resources

Readme
MIT license
Activity

Stars

816 stars

Watchers

43 watching

Forks

126 forks
Report repository

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.