Skip to content

Commit

Permalink
[NL] Disable llm fallback for entity based queries. (#4722)
Browse files Browse the repository at this point in the history
Disabling the LLM fallback for entity based queries for now since the
prompt is tailored to place+statvar queries.
  • Loading branch information
clincoln8 authored Nov 9, 2024
1 parent d07ffd8 commit c2c1d9d
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 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 All @@ -79,8 +83,8 @@ def need_llm(heuristic: Detection, prev_uttr: Utterance,
ctr.info('info_fallback_no_sv_found', '')
need_sv = True

# 2. If there was no place or entity.
if _has_no_place(heuristic) and _has_no_entity(heuristic):
# 2. If there was no place and no entity.
if _has_no_place(heuristic) and not _has_entity(heuristic):

# For COUNTRY contained-in type, Earth is assumed
# (e.g., countries with worst health), so exclude that.
Expand Down Expand Up @@ -118,8 +122,8 @@ def _has_no_prop(d: Detection, ctr: counters.Counters) -> bool:
d.svs_detected.prop, d.svs_detected.sv_threshold, ctr)


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:
return d.places_detected and d.places_detected.entities_found


#
Expand Down

0 comments on commit c2c1d9d

Please sign in to comment.