Skip to content
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

[A/B] Changes to the RAG functionality #630

Merged
merged 15 commits into from
Jun 25, 2024
Merged

[A/B] Changes to the RAG functionality #630

merged 15 commits into from
Jun 25, 2024

Conversation

wpfl-dbt
Copy link
Collaborator

@wpfl-dbt wpfl-dbt commented Jun 21, 2024

Context

We want to split test two paths for the RAG functionality:

  • @search is the standard
  • @supasearch implements a higher k, similarity threshold and hybrid search with a boosted similarity weight

Note I also change the keywords we use to make them a bit nicer for users, and remove the enum for keywords in the frontend.

Note I haven't put in a unit test because this is about lightweight experimentation.

Changes proposed in this pull request

  • Adds @supasearch route
  • Rename @summarisation to @summarise to enable people to say things like "@summarise the people in these docs"
  • Rename @retrieval to @search to enable people to say things like "@search which type of energy saw the largest spike in prices"
  • Removes enum for routes in the frontend

Guidance to review

  • Check you're happy with my changes

Relevant links

Things to check

  • I have added any new ENV vars in all deployed environments
  • I have tested any code added or changed
  • I have run integration tests


return {
"size": env.ai.rag_k,
"size": params["size"],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"size": params["size"],
"size": env.ai.rag_k or params["size"],

or i f we arent using env.ai we should remove it (but i think its probably a good idea)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, these are added in the default params further down the function, so definitely still used and I think we should keep them for now.

{
"knn": {
"field": "embedding",
"query_vector": vector,
"num_candidates": env.ai.rag_num_candidates,
"filter": knn_filter,
"num_candidates": params["num_candidates"],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as above

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so below

{
"match": {
"text": {
"query": query["question"],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Collaborator

@gecBurton gecBurton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

not for now but we should think about aliases for summary/summarise etc

@@ -147,7 +147,19 @@ def get_routable_chains(
ChatRoute.ability: build_static_response_chain(ABILITY_RESPONSE, ChatRoute.ability),
ChatRoute.coach: build_static_response_chain(COACH_RESPONSE, ChatRoute.coach),
ChatRoute.gratitude: build_static_response_chain("You're welcome!", ChatRoute.gratitude),
ChatRoute.retrieval: retrieval_chain,
ChatRoute.summarisation: summary_chain,
ChatRoute.search: retrieval_chain,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes will need to be reflected in the Django app, in the ChatRoute enum.

Copy link
Collaborator Author

@wpfl-dbt wpfl-dbt Jun 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to remove this enum from the frontend and just hold it as a string. An advantage of keywords is we can quickly add and remove them to test stuff, and doing this as an enum in the front will mean a db migration every time this happens because keywords and routes are currently bound together.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll rue this one day, you mark my words. But if you must, you must.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the migration has been put in to handle route as a string in Django? Is this thread resolved?

Copy link
Contributor

@brunns brunns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you rebase and run the integration tests? The looks good to me.

@gecBurton
Copy link
Collaborator

Can you rebase and run the integration tests? The looks good to me.

https://github.com/i-dot-ai/redbox-copilot/actions/runs/9659121995

this is working locally for me

@gecBurton gecBurton merged commit c66d8aa into main Jun 25, 2024
4 checks passed
@gecBurton gecBurton deleted the test/k2 branch June 25, 2024 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants