@atlaskit/editor-plugin-autocomplete 2.0.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -20,7 +20,7 @@ import l3VocabularyData from './data/l3_vocabulary.json';
20
20
  import vocabularyData from './data/vocabulary_10k.json';
21
21
  import wordIndexData from './data/word_index_10k.json';
22
22
  // import { rankCandidates, isGrammarAllowed } from './scoring-pipeline';
23
- import { rankCandidates } from './scoring-pipeline';
23
+ import { rankCandidates, STAGE1_WEIGHT, STAGE2_WEIGHT, MIN_STAGE1_SCORE } from './scoring-pipeline';
24
24
  import type { ScoringCandidate } from './scoring-pipeline';
25
25
  import { getStoredContextVector, getStoredLmLogits } from './slow-lane-client';
26
26
 
@@ -533,11 +533,21 @@ export const predict = (textBefore: string): string | null => {
533
533
  sessionFreq: node.sessionFreq,
534
534
  }));
535
535
 
536
- const { candidates: ranked, grammarMeta } = rankCandidates(
536
+ // Filter the LM payload to only words matching the current prefix so that
537
+ // lmMax in rankCandidates reflects prefix-relevant signal, not the global distribution.
538
+ const prefix = currentWord.toLowerCase();
539
+ const prefixLmLogits = lmLogits
540
+ ? Object.fromEntries(Object.entries(lmLogits).filter(([word]) => word.startsWith(prefix)))
541
+ : null;
542
+ const {
543
+ candidates: ranked,
544
+ grammarMeta,
545
+ pipelineDebug,
546
+ } = rankCandidates(
537
547
  scoringCandidates,
538
548
  contextVector,
539
549
  (w: string) => getWordVector(w),
540
- lmLogits,
550
+ prefixLmLogits,
541
551
  wordTrie.maxTenantFreq,
542
552
  previousWord,
543
553
  );
@@ -624,7 +634,7 @@ export const predict = (textBefore: string): string | null => {
624
634
  // 4. Scoring formula active this prediction
625
635
  const formulaLabel =
626
636
  lmLogits && Object.keys(lmLogits).length > 0
627
- ? 'Stage1(×0.6) + LM(×0.4)'
637
+ ? `Stage1(×${STAGE1_WEIGHT}) + LM(×${STAGE2_WEIGHT})`
628
638
  : 'Stage1 only (no LM logits)';
629
639
  // eslint-disable-next-line no-console
630
640
  console.log('%cFormula:', 'color: #888; font-style: italic;', formulaLabel);
@@ -645,9 +655,17 @@ export const predict = (textBefore: string): string | null => {
645
655
  }
646
656
  }
647
657
 
648
- // 6. Candidate table
658
+ // 6. Pipeline funnel
659
+ // eslint-disable-next-line no-console
660
+ console.log(
661
+ `%c[Pipeline Funnel] %c📥 In: ${pipelineDebug.initial} | ❌ Stage 1 (< ${MIN_STAGE1_SCORE}): -${pipelineDebug.stage1Rejected.length} | ❌ Grammar: -${pipelineDebug.grammarRejected.length} | ✅ Final: ${pipelineDebug.final}`,
662
+ 'color: #9c27b0; font-weight: bold;',
663
+ 'color: inherit;',
664
+ );
665
+
666
+ // 7. Candidate table
649
667
  if (ranked.length > 0) {
650
- const lmCoverage = ranked.slice(0, 10).filter((r) => r.lmScore > 0.05).length;
668
+ const lmCoverage = ranked.slice(0, 10).filter((r) => r.lmScore > 0).length;
651
669
  // eslint-disable-next-line no-console
652
670
  console.log(
653
671
  `%cLM coverage: ${lmCoverage}/${Math.min(ranked.length, 10)} candidates had real logit scores`,
@@ -656,8 +674,8 @@ export const predict = (textBefore: string): string | null => {
656
674
 
657
675
  const tableData = ranked.slice(0, 10).map((r) => {
658
676
  let rawLogit: string | number = 'Not in Payload';
659
- if (lmLogits) {
660
- const val = lmLogits[r.word.toLowerCase()];
677
+ if (prefixLmLogits) {
678
+ const val = prefixLmLogits[r.word.toLowerCase()];
661
679
  if (val !== undefined) {
662
680
  rawLogit = Number(val.toFixed(5));
663
681
  }
package/tsconfig.app.json CHANGED
@@ -35,6 +35,9 @@
35
35
  {
36
36
  "path": "../editor-common/tsconfig.app.json"
37
37
  },
38
+ {
39
+ "path": "../editor-plugin-analytics/tsconfig.app.json"
40
+ },
38
41
  {
39
42
  "path": "../editor-prosemirror/tsconfig.app.json"
40
43
  }