Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide ML completion ranking for Rust #6419

Merged
merged 4 commits into from Dec 22, 2020
Merged

Provide ML completion ranking for Rust #6419

merged 4 commits into from Dec 22, 2020

Conversation

artemmukhin
Copy link
Member

@artemmukhin artemmukhin commented Nov 20, 2020

Part of #6411

This PR adds a new module ml-completion to the project. This module provides the ML-based code completion ranking support for Rust. Currently, it consists of:

  • RsCompletionFeaturesPolicy enabling Ngram model for future models
  • RsElementFeatureProvider providing Rust-specific features to train future models, with tests
  • RsMLRankingProvider providing an initial ranking model (trained without the stuff above, therefore not very intelligent so far)

Thanks to @bibaev for help!

How to use

The new ranking model can be enabled in Editor | General | Code Completion | Machine Learning-Assisted Completion settings (see help for more details). However, at the moment, the model is very rough, so it's not strongly recommended for enabling.

settings

before

after

changelog: Provide experimental code completion ranking for Rust based on machine learning. It applies rules learned from data we have gathered anonymously during our EAPs, which results in better suggestions. Note that we have not collected any source code, only information about your interactions with the code completion UI. The ranking model is disabled by default for now. You can enable it via Editor | General | Code Completion | Machine Learning-Assisted Completion settings.

@artemmukhin artemmukhin added this to In Progress in To test via automation Nov 20, 2020
build.gradle.kts Outdated Show resolved Hide resolved
ml-completion/src/main/kotlin/RustMLRankingProvider.kt Outdated Show resolved Hide resolved
build.gradle.kts Outdated Show resolved Hide resolved
ml-completion/src/main/kotlin/RustMLRankingProvider.kt Outdated Show resolved Hide resolved
Copy link
Member

@Undin Undin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM except minor comments

@Undin Undin force-pushed the ortem/ml-completion branch 2 times, most recently from 65a8bc2 to 9ada816 Compare December 9, 2020 15:51
Copy link
Member

@Undin Undin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you rebase into master, please? It will show the problem with com.intellij.stats.completion dependency (CI faces it because it actually checks master + your changes)

ml-completion/src/test/resources/META-INF/plugin.xml Outdated Show resolved Hide resolved
build.gradle.kts Show resolved Hide resolved
Copy link
Member

@Undin Undin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, there is a merge conflict

@Undin Undin added this to the v138 milestone Dec 19, 2020
Copy link
Member

@Undin Undin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note, I've added missed keywords in #6492 (it was merged recently) so we should update RsKeywordMLKind and the corresponding tests

@artemmukhin artemmukhin force-pushed the ortem/ml-completion branch 2 times, most recently from b798157 to 92c95ae Compare December 21, 2020 22:36
@artemmukhin
Copy link
Member Author

Rebased onto master (the first force-push) and fixed comments (the second force-push).

Also, I removed " symbols from RsElementFeatureProviderTest due to [DANGEROUS_CHARACTERS] Name contains characters which can cause problems on Windows warning.

build.gradle.kts Outdated Show resolved Hide resolved
Now we provide these two features:
* Categorical feature `kind` to consider keyword/PSI type of element
* Binary feature `is_from_stdlib` to consider if element's origin is stdlib
Copy link
Member

@Undin Undin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bors r+

@bors
Copy link
Contributor

bors bot commented Dec 22, 2020

Build succeeded:

@bors bors bot merged commit fed8256 into master Dec 22, 2020
To test automation moved this from In Progress to Test Dec 22, 2020
@bors bors bot deleted the ortem/ml-completion branch December 22, 2020 14:07
@lancelote lancelote moved this from Test to Done in To test Jan 24, 2021
bors bot added a commit that referenced this pull request May 20, 2021
7237: Update Rust ML ranking provider to 0.2.2 r=Undin a=ortem

Part of #6411.

This PR updates the Rust ML ranking provider version to 0.2.2. The new model takes into account Rust-specific features introduced in #6419, and so is more precise than the previous one.

In addition, this PR adds support for decorating the most relevant item with a star icon.

<img width="725" alt="Screenshot 2021-05-19 at 16 22 48" src="https://user-images.githubusercontent.com/4854600/118829579-83d4f200-b8be-11eb-9eff-0a6e303fcd35.png">

This feature can be enabled via `Mark the most relevant item in the completion popup` option in `Preferences | Editor | General | Code Completion` settings.


changelog: Update experimental code completion ranking for Rust based on machine learning. The ranking model is disabled by default for now. You can enable it via `Editor | General | Code Completion | Machine Learning-Assisted Completion` [settings](https://www.jetbrains.com/help/idea/auto-completing-code.html#ml_completion).

Co-authored-by: ortem <ortem00@gmail.com>
bors bot added a commit that referenced this pull request May 20, 2021
7237: Update Rust ML ranking provider to 0.2.2 r=Undin a=ortem

Part of #6411.

This PR updates the Rust ML ranking provider version to 0.2.2. The new model takes into account Rust-specific features introduced in #6419, and so is more precise than the previous one.

In addition, this PR adds support for decorating the most relevant item with a star icon.

<img width="725" alt="Screenshot 2021-05-19 at 16 22 48" src="https://user-images.githubusercontent.com/4854600/118829579-83d4f200-b8be-11eb-9eff-0a6e303fcd35.png">

This feature can be enabled via `Mark the most relevant item in the completion popup` option in `Preferences | Editor | General | Code Completion` settings.


changelog: Update experimental code completion ranking for Rust based on machine learning. The ranking model is disabled by default for now. You can enable it via `Editor | General | Code Completion | Machine Learning-Assisted Completion` [settings](https://www.jetbrains.com/help/idea/auto-completing-code.html#ml_completion).

Co-authored-by: ortem <ortem00@gmail.com>
bors bot added a commit that referenced this pull request Sep 2, 2021
7777: Enable by default ML code completion ranking for Rust r=Undin a=ortem

This PR enables the new ML-based code completion ranking by default. See #6419 for more information on this feature.

In case of any issues, the new ranking model can be disabled in `Editor | General | Code Completion | Machine Learning-Assisted Completion` settings. 

Part of #6411

changelog: Enable by default code completion ranking for Rust based on machine learning. Now the completion suggestions are sorted by their relevance based on the rules learned from data we have gathered anonymously during our EAPs. Note that we have not collected any source code, only information about your interactions with the code completion UI. In case of any issues, you can disable the new ranking model via `Editor | General | Code Completion | Machine Learning-Assisted Completion` settings.




Co-authored-by: Artem Mukhin <ortem00@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
To test
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants