Skip to content

Commit defd004

Browse files
[8.19] [Obs AI Assistant] Enable ELSER and e5 on EIS (elastic#220993) (elastic#221148)
# Backport This will backport the following commits from `main` to `8.19`: - [[Obs AI Assistant] Enable ELSER and e5 on EIS (elastic#220993)](elastic#220993) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Viduni Wickramarachchi","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-05-21T15:43:32Z","message":"[Obs AI Assistant] Enable ELSER and e5 on EIS (elastic#220993)\n\nCloses https://github.com/elastic/obs-ai-assistant-team/issues/246\n\n## Summary\n\nThe EIS pre-configured endpoint for ELSER is accessible in the QA\nenvironment (It's not on Prod yet).\n\nAt present the KB `/status` endpoint checks for trained model stats in\norder to determine whether the model is downloaded and deployed and\nready to be used. This flow is not necessary for EIS endpoints as there\nwill be no model downloading and deploying.\n\nThis PR implements the necessary changes to the flow of the `/status`\nendpoint:\n- If the pre-configured endpoint exists, we can assume the KB is ready\nto be used.\n\n## Screen recording\n\n### ELSER via EIS\n\nhttps://github.com/user-attachments/assets/0595e240-0c4a-4b01-9064-5de1c452ce4b\n\n### e5-small on ML node\n\nhttps://github.com/user-attachments/assets/3b7f9710-8fca-4334-a561-e8e5097e3ab0\n\n\n### Checklist\n\n- [x] Any text added follows [EUI's writing\nguidelines](https://elastic.github.io/eui/#/guidelines/writing), uses\nsentence case text and includes [i18n\nsupport](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)\n- [x] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios\n- [x] The PR description includes the appropriate Release Notes section,\nand the correct `release_note:*` label is applied per the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"3337a088693b793af94c86f48c86b000c6dd80da","branchLabelMapping":{"^v9.1.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:feature","Team:Obs AI Assistant","ci:project-deploy-observability","backport:version","v9.1.0","v8.19.0"],"title":"[Obs AI Assistant] Enable ELSER and e5 on EIS","number":220993,"url":"https://github.com/elastic/kibana/pull/220993","mergeCommit":{"message":"[Obs AI Assistant] Enable ELSER and e5 on EIS (elastic#220993)\n\nCloses https://github.com/elastic/obs-ai-assistant-team/issues/246\n\n## Summary\n\nThe EIS pre-configured endpoint for ELSER is accessible in the QA\nenvironment (It's not on Prod yet).\n\nAt present the KB `/status` endpoint checks for trained model stats in\norder to determine whether the model is downloaded and deployed and\nready to be used. This flow is not necessary for EIS endpoints as there\nwill be no model downloading and deploying.\n\nThis PR implements the necessary changes to the flow of the `/status`\nendpoint:\n- If the pre-configured endpoint exists, we can assume the KB is ready\nto be used.\n\n## Screen recording\n\n### ELSER via EIS\n\nhttps://github.com/user-attachments/assets/0595e240-0c4a-4b01-9064-5de1c452ce4b\n\n### e5-small on ML node\n\nhttps://github.com/user-attachments/assets/3b7f9710-8fca-4334-a561-e8e5097e3ab0\n\n\n### Checklist\n\n- [x] Any text added follows [EUI's writing\nguidelines](https://elastic.github.io/eui/#/guidelines/writing), uses\nsentence case text and includes [i18n\nsupport](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)\n- [x] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios\n- [x] The PR description includes the appropriate Release Notes section,\nand the correct `release_note:*` label is applied per the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"3337a088693b793af94c86f48c86b000c6dd80da"}},"sourceBranch":"main","suggestedTargetBranches":["8.19"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/220993","number":220993,"mergeCommit":{"message":"[Obs AI Assistant] Enable ELSER and e5 on EIS (elastic#220993)\n\nCloses https://github.com/elastic/obs-ai-assistant-team/issues/246\n\n## Summary\n\nThe EIS pre-configured endpoint for ELSER is accessible in the QA\nenvironment (It's not on Prod yet).\n\nAt present the KB `/status` endpoint checks for trained model stats in\norder to determine whether the model is downloaded and deployed and\nready to be used. This flow is not necessary for EIS endpoints as there\nwill be no model downloading and deploying.\n\nThis PR implements the necessary changes to the flow of the `/status`\nendpoint:\n- If the pre-configured endpoint exists, we can assume the KB is ready\nto be used.\n\n## Screen recording\n\n### ELSER via EIS\n\nhttps://github.com/user-attachments/assets/0595e240-0c4a-4b01-9064-5de1c452ce4b\n\n### e5-small on ML node\n\nhttps://github.com/user-attachments/assets/3b7f9710-8fca-4334-a561-e8e5097e3ab0\n\n\n### Checklist\n\n- [x] Any text added follows [EUI's writing\nguidelines](https://elastic.github.io/eui/#/guidelines/writing), uses\nsentence case text and includes [i18n\nsupport](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)\n- [x] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios\n- [x] The PR description includes the appropriate Release Notes section,\nand the correct `release_note:*` label is applied per the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"3337a088693b793af94c86f48c86b000c6dd80da"}},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Viduni Wickramarachchi <[email protected]>
1 parent f613896 commit defd004

File tree

6 files changed

+115
-1
lines changed

6 files changed

+115
-1
lines changed

x-pack/platform/packages/shared/kbn-ai-assistant/src/utils/get_model_options_for_inference_endpoints.test.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import type { InferenceAPIConfigResponse } from '@kbn/ml-trained-models-utils';
1717
import {
1818
ELSER_ON_ML_NODE_INFERENCE_ID,
1919
E5_SMALL_INFERENCE_ID,
20+
ELSER_IN_EIS_INFERENCE_ID,
21+
E5_LARGE_IN_EIS_INFERENCE_ID,
2022
} from '@kbn/observability-ai-assistant-plugin/public';
2123

2224
describe('getModelOptionsForInferenceEndpoints', () => {
@@ -44,6 +46,55 @@ describe('getModelOptionsForInferenceEndpoints', () => {
4446
]);
4547
});
4648

49+
it('shows only ELSER in EIS when both ELSER models are available', () => {
50+
const endpoints = [
51+
{ inference_id: ELSER_ON_ML_NODE_INFERENCE_ID },
52+
{ inference_id: ELSER_IN_EIS_INFERENCE_ID },
53+
{ inference_id: E5_SMALL_INFERENCE_ID },
54+
] as InferenceAPIConfigResponse[];
55+
56+
const options = getModelOptionsForInferenceEndpoints({
57+
endpoints,
58+
});
59+
60+
expect(options.map((o) => o.key)).toEqual([ELSER_IN_EIS_INFERENCE_ID, E5_SMALL_INFERENCE_ID]);
61+
});
62+
63+
it('shows only E5-large in EIS when both E5 (small and large) models are available', () => {
64+
const endpoints = [
65+
{ inference_id: ELSER_ON_ML_NODE_INFERENCE_ID },
66+
{ inference_id: E5_SMALL_INFERENCE_ID },
67+
{ inference_id: E5_LARGE_IN_EIS_INFERENCE_ID },
68+
] as InferenceAPIConfigResponse[];
69+
70+
const options = getModelOptionsForInferenceEndpoints({
71+
endpoints,
72+
});
73+
74+
expect(options.map((o) => o.key)).toEqual([
75+
ELSER_ON_ML_NODE_INFERENCE_ID,
76+
E5_LARGE_IN_EIS_INFERENCE_ID,
77+
]);
78+
});
79+
80+
it('shows only EIS models when both ELSER and E5-large pre-configured endpoints are available in EIS', () => {
81+
const endpoints = [
82+
{ inference_id: ELSER_ON_ML_NODE_INFERENCE_ID },
83+
{ inference_id: ELSER_IN_EIS_INFERENCE_ID },
84+
{ inference_id: E5_SMALL_INFERENCE_ID },
85+
{ inference_id: E5_LARGE_IN_EIS_INFERENCE_ID },
86+
] as InferenceAPIConfigResponse[];
87+
88+
const options = getModelOptionsForInferenceEndpoints({
89+
endpoints,
90+
});
91+
92+
expect(options.map((o) => o.key)).toEqual([
93+
ELSER_IN_EIS_INFERENCE_ID,
94+
E5_LARGE_IN_EIS_INFERENCE_ID,
95+
]);
96+
});
97+
4798
it('does not show any EIS models if EIS pre-configured endpoints are not available', () => {
4899
const endpoints = [
49100
{ inference_id: ELSER_ON_ML_NODE_INFERENCE_ID },

x-pack/platform/packages/shared/kbn-ai-assistant/src/utils/get_model_options_for_inference_endpoints.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import { InferenceAPIConfigResponse } from '@kbn/ml-trained-models-utils';
1010
import {
1111
ELSER_ON_ML_NODE_INFERENCE_ID,
1212
E5_SMALL_INFERENCE_ID,
13+
ELSER_IN_EIS_INFERENCE_ID,
14+
E5_LARGE_IN_EIS_INFERENCE_ID,
1315
} from '@kbn/observability-ai-assistant-plugin/public';
1416

1517
export interface ModelOptionsData {
@@ -48,6 +50,21 @@ export const e5SmallDescription = i18n.translate(
4850
}
4951
);
5052

53+
const e5LargeTitle = i18n.translate(
54+
'xpack.aiAssistant.welcomeMessage.knowledgeBase.model.e5largeTitle',
55+
{
56+
defaultMessage: 'E5-large (multilingual)',
57+
}
58+
);
59+
60+
const e5LargeDescription = i18n.translate(
61+
'xpack.aiAssistant.welcomeMessage.knowledgeBase.model.e5largeDescription',
62+
{
63+
defaultMessage:
64+
'E5 is an NLP model by Elastic designed to enhance multilingual semantic search by focusing on query context rather than keywords. E5-large is an optimized version for Intel® silicon.',
65+
}
66+
);
67+
5168
const PRECONFIGURED_INFERENCE_ENDPOINT_METADATA: Record<
5269
string,
5370
{ title: string; description: string }
@@ -56,19 +73,40 @@ const PRECONFIGURED_INFERENCE_ENDPOINT_METADATA: Record<
5673
title: elserTitle,
5774
description: elserDescription,
5875
},
76+
[ELSER_IN_EIS_INFERENCE_ID]: {
77+
title: elserTitle,
78+
description: elserDescription,
79+
},
5980
[E5_SMALL_INFERENCE_ID]: {
6081
title: e5SmallTitle,
6182
description: e5SmallDescription,
6283
},
84+
[E5_LARGE_IN_EIS_INFERENCE_ID]: {
85+
title: e5LargeTitle,
86+
description: e5LargeDescription,
87+
},
6388
};
6489

6590
export const getModelOptionsForInferenceEndpoints = ({
6691
endpoints,
6792
}: {
6893
endpoints: InferenceAPIConfigResponse[];
6994
}): ModelOptionsData[] => {
95+
const hasElserEIS = endpoints.some((ep) => ep.inference_id === ELSER_IN_EIS_INFERENCE_ID);
96+
const hasE5EIS = endpoints.some((ep) => ep.inference_id === E5_LARGE_IN_EIS_INFERENCE_ID);
97+
7098
return endpoints
7199
.filter((endpoint) => {
100+
// if ELSER exists in EIS, skip the other ELSER model
101+
if (endpoint.inference_id === ELSER_ON_ML_NODE_INFERENCE_ID && hasElserEIS) {
102+
return false;
103+
}
104+
105+
// if e5-large exists in EIS, skip the e5-small
106+
if (endpoint.inference_id === E5_SMALL_INFERENCE_ID && hasE5EIS) {
107+
return false;
108+
}
109+
72110
// Only include preconfigured endpoints and skip custom endpoints
73111
return Boolean(PRECONFIGURED_INFERENCE_ENDPOINT_METADATA[endpoint.inference_id]);
74112
})

x-pack/platform/plugins/shared/observability_ai_assistant/common/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,5 @@ export {
5858
ELSER_IN_EIS_INFERENCE_ID,
5959
E5_SMALL_INFERENCE_ID,
6060
E5_LARGE_IN_EIS_INFERENCE_ID,
61+
EIS_PRECONFIGURED_INFERENCE_IDS,
6162
} from './preconfigured_inference_ids';

x-pack/platform/plugins/shared/observability_ai_assistant/common/preconfigured_inference_ids.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,8 @@ export const ELSER_IN_EIS_INFERENCE_ID = '.elser-v2-elastic';
1010

1111
export const E5_SMALL_INFERENCE_ID = '.multilingual-e5-small-elasticsearch';
1212
export const E5_LARGE_IN_EIS_INFERENCE_ID = '.multilingual-e5-large-elastic'; // TODO: verify the inference ID once it's created in EIS
13+
14+
export const EIS_PRECONFIGURED_INFERENCE_IDS = [
15+
ELSER_IN_EIS_INFERENCE_ID,
16+
E5_LARGE_IN_EIS_INFERENCE_ID,
17+
];

x-pack/platform/plugins/shared/observability_ai_assistant/public/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ export {
7373
ELSER_IN_EIS_INFERENCE_ID,
7474
E5_SMALL_INFERENCE_ID,
7575
E5_LARGE_IN_EIS_INFERENCE_ID,
76+
EIS_PRECONFIGURED_INFERENCE_IDS,
7677
} from '../common';
7778

7879
export type {

x-pack/platform/plugins/shared/observability_ai_assistant/server/service/inference_endpoint.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
import { InferenceAPIConfigResponse } from '@kbn/ml-trained-models-utils';
1717
import pRetry from 'p-retry';
1818
import { CoreSetup } from '@kbn/core/server';
19-
import { KnowledgeBaseState } from '../../common';
19+
import { EIS_PRECONFIGURED_INFERENCE_IDS, KnowledgeBaseState } from '../../common';
2020
import { ObservabilityAIAssistantConfig } from '../config';
2121
import {
2222
getConcreteWriteIndex,
@@ -128,12 +128,28 @@ export async function getKbModelStatus({
128128
inferenceId = currentInferenceId;
129129
}
130130

131+
// check if inference ID is an EIS inference ID
132+
const isPreConfiguredInferenceIdInEIS = EIS_PRECONFIGURED_INFERENCE_IDS.includes(inferenceId);
133+
131134
let endpoint: InferenceInferenceEndpointInfo;
132135
try {
133136
endpoint = await getInferenceEndpoint({ esClient, inferenceId });
134137
logger.debug(
135138
`Inference endpoint "${inferenceId}" found with model id "${endpoint?.service_settings?.model_id}"`
136139
);
140+
141+
// if the endpoint is in EIS, the model doesn't have to be downloaded and deployed
142+
// Therefore, return the KB state as READY if the endpoint exists
143+
if (isPreConfiguredInferenceIdInEIS && endpoint.service === 'elastic') {
144+
return {
145+
endpoint,
146+
enabled,
147+
kbState: KnowledgeBaseState.READY,
148+
currentInferenceId,
149+
concreteWriteIndex,
150+
isReIndexing,
151+
};
152+
}
137153
} catch (error) {
138154
if (!isInferenceEndpointMissingOrUnavailable(error)) {
139155
throw error;
@@ -242,6 +258,8 @@ export async function waitForKbModel({
242258
logger.debug('Knowledge base model is not yet ready. Retrying...');
243259
throw new Error('Knowledge base model is not yet ready');
244260
}
261+
262+
logger.debug('Knowledge base model is ready.');
245263
},
246264
{ retries: 30, factor: 2, maxTimeout: 30_000 }
247265
);

0 commit comments

Comments
 (0)