Fish sheep from concave the temple qubit commentary | QbitAI number

Tapping code line by line is like moving bricks with your bare hands. Clever programmers say: Let’s unleash productivity!

Like this:

In the era of machine learning, AI code completion is no longer a dream, and ides and plug-ins are working to help programmers reduce keystrokes and extend keyboard life.

A programmer from Sri Lanka, who joined the Keyboard Care Group, tried to auto-complete Python code using a simple deep learning model, and it worked surprisingly well. The project is now open source!

Simple models are powerful

With an experimental mentality, the Sri Lankan boy used only a simple LSTM (Long short-term Memory) model in this project.

The algorithm used for prediction is beam search, which is a heuristic graph search algorithm. In each step of deep expansion, cluster search only retains some nodes of high quality, reducing space consumption and improving time efficiency. The cluster search algorithm can predict up to 10 characters.

The data fed to the model is tokenized Python code that has been cleaned of comments, strings, and blank lines.

The training effect is this: \

The green letter is the starting position of automatic completion, press TAB to select completion, and the highlighted gray part is the code supplemented by AI.

Using deep learning to auto-complete Python code in such a simple model can still reduce keystrokes by 30-50%.

GitHub provides a Python parser, but as long as you write a parser for other languages, this solution can be extended to other languages, Java auto-complete, C auto-complete, etc.

Method of use

Want to test the effect?

No problem, you can train your autocomplete model in just five steps.

1. Install the lab environment for machine learning (see end for address).

2. Copy the data to./data/source.

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

4. Run evaluate.py to evaluate the model.

5. Run the train.py training model.

Still need to grow up

It’s simple, it works, and it sounds like it has a lot of potential. However, the ideal is full, the reality is a bit skinny. The nascent AI still faces a number of growth challenges.

Challenge 1: Inefficiency

The first is that its performance has not been able to meet the needs of practical use. Due to the limitations of the editing integrator, the cluster search algorithm is inefficient. If it has time to complete the code, you can manually type several lines of code.

“Next, we will try different architectures to improve our reasoning performance,” he said. “We welcome ideas and suggestions.”

Challenge 2: Strong predecessors

Reddit users also pointed out that the idea of using machine learning to complete code has already been implemented successfully, such as Trith Ventures’ Kite.

Kite is used by over 30,000 Python developers worldwide and has been hailed as the most useful Python auto-completion tool available today. Not only can you complete your code, Kite also allows you to skip documentation and see how others are using functions in real time, but it also provides definitions and usages for your custom code base.

Even the father of Python couldn’t help but give Kite a thumbs up: that’s pretty cool.

Kite’s project is very young compared to its predecessor, but Kite is not open source, and the cloud engine it uses as a supplement has raised questions about security.

Your legal department will go crazy if you use Kite for work.

How does AI compare with Pycharm? After all, Pycharm’s auto-complete is already useful.

portal

Github:github.com/vpj/python_…

Lab:github.com/vpj/lab

– the – \

\

Click to become a registered member of the community ** “Watching” **