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

[NL] Disable llm fallback for entity based queries. #4722

Merged
merged 3 commits into from
Nov 9, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions server/lib/nl/detection/llm_fallback.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ def need_llm(heuristic: Detection, prev_uttr: Utterance,
need_sv = False
need_place = False

# Do not use LLM when an entity has been identified.
if _has_entity(heuristic):
return NeedLLM.No

# 1. If there was no SV or prop.
if _has_no_sv(heuristic, ctr) and _has_no_prop(heuristic, ctr):

Expand Down Expand Up @@ -122,6 +126,10 @@ def _has_no_entity(d: Detection) -> bool:
return not d.places_detected or not d.places_detected.entities_found


def _has_entity(d: Detection) -> bool:
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I don't think we need this helper since there's not really any logic here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The double negative is a little rough for readability -- I updated the code to only have _has_entity to avoid this issue. Is that okay?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll merge this for now so that the logic is in autopush. I can change the readability part if you prefer the _has_no_entity with the double negative as a follow up!

return not _has_no_entity(d)


#
# Returns true if the original query is likely a "complex" one with
# multiple SVs.
Expand Down
Loading