[PATCH] D88281: [clangd] Use Decision Forest to score code compeltions.

Utkarsh Saxena via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 28 06:17:35 PDT 2020


usaxena95 added a comment.

If we just consider ranking, there are not many code paths. Most of the code paths are for gathering and creating code completion items.
In the end all the code paths end up in the `addCandidate` method to get `scored` either by heuristics or by decision forest.
So I have added 2 tests for checking sanity and exercising the code path.



================
Comment at: clang-tools-extra/clangd/CodeComplete.cpp:1635
+    case RM::Heuristics:
+      Scores.Quality = Quality.evaluate();
+      Scores.Relevance = Relevance.evaluate();
----------------
adamcz wrote:
> Ideally we'd rename the evaluate() here, since SymbolQualitySignals is used for both heuristic and DecisionForest version, but evaluate is heuristic-specific. I think in pefect world this would be out of SymbolQualitySignals class (which would become just storage), but at least it should be renamed to evaluateUsingHeuristic().
Right. I plan to do this but the changes for a rename would include unrelated files. So I planed to do this another patch keeping this one tractable and clean.
Let me know if you want me to do it in this one itself.


================
Comment at: clang-tools-extra/clangd/CodeComplete.cpp:1655
+      // NameMatch should be a multiplier on total score to support rescoring.
+      Scores.Total = Relevance.NameMatch * Scores.ExcludingName;
+      return Scores;
----------------
adamcz wrote:
> Could we make the weight of Relevance.NameMatch configurable, maybe through CodeCompletionOptions or such? I'm worried it may dominate the score too much and being able to configure this would allow us to run experiments easily.
Since this is multiplicative, I don't think it is possible to weigh NameMatch.
Although we can weigh the contribution of DF prediction.
Did some maths and realised that the `base` in `pow(base, Evaluate(E))` can effectively represent the weightage given to DF Model.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88281/new/

https://reviews.llvm.org/D88281



More information about the cfe-commits mailing list