Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

[BB2] Add check for correct query generator #4366

Merged
merged 1 commit into from
Feb 17, 2022
Merged
Changes from all commits
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
10 changes: 10 additions & 0 deletions projects/blenderbot2/agents/sub_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,23 @@ def __init__(self, opt: Opt):
opt['knowledge_access_method']
)
model_file = modelzoo_path(opt['datapath'], opt['query_generator_model_file'])
if (
self.knowledge_access_method is KnowledgeAccessMethod.SEARCH_ONLY
and 'blenderbot2/query_generator/model' in model_file
):
raise ValueError(
'You cannot use the blenderbot2 query generator with search_only. Please '
'consider setting --query-generator-model-file zoo:sea/bart_sq_gen/model '
'instead.'
)
if model_file and os.path.exists(model_file):
logging.info(f'Building Query Generator from file: {model_file}')
logging.disable()
overrides: Dict[str, Any] = {'skip_generation': False}
overrides['inference'] = opt['query_generator_inference']
overrides['beam_size'] = opt.get('query_generator_beam_size', 3)
overrides['beam_min_length'] = opt.get('query_generator_beam_min_length', 2)
overrides['model_parallel'] = opt['model_parallel']
if self.opt['query_generator_truncate'] > 0:
overrides['text_truncate'] = self.opt['query_generator_truncate']
overrides['truncate'] = self.opt['query_generator_truncate']
Expand Down