-
Notifications
You must be signed in to change notification settings - Fork 330
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
Feature request: Option to disable cross encoder models #286
Conversation
…t the models available need to be hosted on Sagemaker which increases cost significantly. Having an option to disable cross encoder models would be helpful while exploring the chatbot so that Sagemaker costs can be avoided. Added a config to enable/disable cross encoder models. Also added options to selected embedding models, so that sagemakerModels are not created automatically. Persisted enableSagemakerModels config so that it can be used directly instead of relying on sagemakerModels length.
Added basic feedback mechanism for responses generated by the chatbot. The feedbacks are stored in DynamoDB which can be queried to do analysis as required by admin users. In future we can add a UI page to display the feedbacks, but for now these are being stored and manual analysis would be required. The feedbacks are not adding to the learning of the chatbot.
This reverts commit 1c3b8ce.
@massi-ang could you please have a look? |
@bigadsoleiman I have resolved the merge conflicts in the latest commit. |
@azaylamba We have migrated to AppSync. This PR has conflicts. Could you please fix this? And than we can merge |
@spugachev I couldn't find any conflicts in the PR. I have merged the main branch. Note: I have not tested the changes after syncing with main due to some constraints with my AWS account. Any help in testing the changes is appreciated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On top of my comments on the changes, I would expect changes to the front end. If cross encoder models are not enabled the the menu should not be displayed.
Also, if cross encoder models are not selected, it should not be possible to enable hybrid search on the workspaces.
lib/shared/layers/python-sdk/python/genai_core/opensearch/query.py
Outdated
Show resolved
Hide resolved
@massi-ang It seems syncing with main has caused some unwanted changes, as the original changes were made prior to AppSync migration. I will work on this. |
Hybrid Search won't be available if cross encoding is not enabled.
@massi-ang I have addressed the review comments, please have a look. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain why there are 2 settings (Cross Encoder / Embeddings) , since if you enable embeddings models via SM, you can get Cross Encoder for free.
@massi-ang I understand your point that if we enable embeddings models via SM, we can get cross encoder for free. I kept the settings separate to have more control for cross encoding and to make the intent clear in the backend code. Excluding execution of cross encoding code based on sagemaker models can be a little confusing there. Please let me know if I am missing something. |
I think the configuration should be simple and meaningful for the user not the backend. You could think of an alternative naming for the parameter if you think that could create confusion, or better, you could create a function called |
@massi-ang I have removed the prompt for |
@massi-ang Would you be able to have a look at this again? |
Default embeddings models was not being set correctly. Also error was thrown related to suppression rules if sagemaker models were not enabled. Used props.config.llms.enableSagemakerModels config to add the NAG suppression rules.
@massi-ang Please let me know if more changes are required on this one. |
@massi-ang I wanted to follow up on this PR submitted by @azaylamba that is still pending review. Your feedback and approval are crucial for us, we also would like this feature. Regards |
Hi @azaylamba, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work but few fixes left
cli/magic-config.ts
Outdated
@@ -328,7 +341,7 @@ async function processCreateOptions(options: any): Promise<void> { | |||
choices: embeddingModels.map((m) => ({ name: m.name, value: m })), | |||
initial: options.defaultEmbedding || undefined, | |||
skip(): boolean { | |||
return !(this as any).state.answers.enableRag; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @azaylamba, are you able to address this comment?
props.config.rag.engines.aurora.enabled || | ||
props.config.rag.engines.opensearch.enabled | ||
) { | ||
if (props.config.llms.enableSagemakerModels) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be checking crossEncodingEnabled
and not enableSageMakerModels
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, but won't that be confusing that crossEncodingEnabled is driving the Sagemaker models instead of the config props.config.llms.enableSagemakerModels
which is specific for sagemaker models?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right and props.config.llms.enableSagemakerModels
is better
lib/user-interface/react-app/src/pages/rag/create-workspace/aurora-form.tsx
Outdated
Show resolved
Hide resolved
lib/user-interface/react-app/src/pages/rag/create-workspace/create-workspace-aurora.tsx
Show resolved
Hide resolved
lib/user-interface/react-app/src/pages/rag/create-workspace/create-workspace-aurora.tsx
Show resolved
Hide resolved
lib/user-interface/react-app/src/pages/rag/create-workspace/opensearch-form.tsx
Outdated
Show resolved
Hide resolved
cli/magic-config.ts
Outdated
}; | ||
} | ||
if (!config.rag.enableEmbeddingModelsViaSagemaker) { | ||
config.rag.embeddingsModels = embeddingModels.filter(model => model.provider !== "sagemaker"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic should also be applied to the list of models shown in the UI when selecting the default embedding model.
@massi-ang Addressed the review comments, please have a look. |
Also removed duplicated config.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One last change and it seems to be all good.
lib/rag-engines/index.ts
Outdated
props.config.rag.engines.aurora.enabled || | ||
props.config.rag.engines.opensearch.enabled | ||
) { | ||
if (props.config.rag.crossEncodingEnabled) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You were right, props.config.llms.enableSagemakerModels
is better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the condition.
@massi-ang Addressed the last review comment, please have a look. |
@massi-ang I think @azaylamba commit the last change requested... Could you please have a look? |
Hi @azaylamba , @toeteuf , Apologies for the delay. I am making changes based on your PR to fix/set the list of models in the config instead of adding new properties (and reviewing your change at the same time). I will most likely create a new PR with these changes and follow up until merged (and mention you are the original author @azaylamba ). I will also verify the unit tests/format is passing verifications. Please tell me if you have any concern. |
Hi @charles-marion I don't have any objection, please proceed with the changes. |
Closed in favor of #588 |
Issue #222
Description of changes: Currently cross encoder models are used to rank the search results but the models available need to be hosted on Sagemaker which increases cost significantly. Having an option to disable cross encoder models would be helpful while exploring the chatbot so that Sagemaker costs can be avoided.
Added a config to enable/disable embeddings via Sagemaker which in turn derives cross encoding models.
Persisted enableSagemakerModels config so that it can be used directly instead of relying on sagemakerModels length.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.