@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.
- package/CHANGELOG.md +22 -0
- package/afm-cc/tsconfig.json +3 -0
- package/afm-products/tsconfig.json +3 -0
- package/dist/cjs/autocompletePlugin.js +3 -2
- package/dist/cjs/pm-plugins/autocomplete-plugin.js +32 -3
- package/dist/cjs/pm-plugins/scoring-pipeline.js +43 -17
- package/dist/cjs/pm-plugins/text-predictor.js +27 -13
- package/dist/es2019/autocompletePlugin.js +3 -2
- package/dist/es2019/pm-plugins/autocomplete-plugin.js +32 -3
- package/dist/es2019/pm-plugins/scoring-pipeline.js +32 -14
- package/dist/es2019/pm-plugins/text-predictor.js +18 -8
- package/dist/esm/autocompletePlugin.js +3 -2
- package/dist/esm/pm-plugins/autocomplete-plugin.js +32 -3
- package/dist/esm/pm-plugins/scoring-pipeline.js +42 -17
- package/dist/esm/pm-plugins/text-predictor.js +28 -14
- package/dist/types/autocompletePluginType.d.ts +3 -1
- package/dist/types/pm-plugins/autocomplete-plugin.d.ts +3 -1
- package/dist/types/pm-plugins/scoring-pipeline.d.ts +10 -0
- package/dist/types-ts4.5/autocompletePluginType.d.ts +5 -1
- package/dist/types-ts4.5/pm-plugins/autocomplete-plugin.d.ts +3 -1
- package/dist/types-ts4.5/pm-plugins/scoring-pipeline.d.ts +10 -0
- package/package.json +3 -2
- package/src/autocompletePlugin.tsx +2 -2
- package/src/autocompletePluginType.ts +3 -1
- package/src/pm-plugins/autocomplete-plugin.ts +33 -3
- package/src/pm-plugins/scoring-pipeline.ts +41 -15
- package/src/pm-plugins/text-predictor.ts +26 -8
- package/tsconfig.app.json +3 -0
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
?
|
|
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.
|
|
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
|
|
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 (
|
|
660
|
-
const val =
|
|
677
|
+
if (prefixLmLogits) {
|
|
678
|
+
const val = prefixLmLogits[r.word.toLowerCase()];
|
|
661
679
|
if (val !== undefined) {
|
|
662
680
|
rawLogit = Number(val.toFixed(5));
|
|
663
681
|
}
|