evaluate_orqa.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. # coding=utf-8
  2. # Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. """Main tasks functionality."""
  16. from megatron import get_args, print_rank_0
  17. from megatron.indexer import IndexBuilder
  18. from tasks.orqa.evaluate_utils import ORQAEvaluator
  19. def main():
  20. """
  21. Main program
  22. """
  23. args = get_args()
  24. """
  25. Create a BlockData data structure by running an IndexBuilder over an
  26. ICT Dataset and then evaluate on NQ task
  27. """
  28. print_rank_0("Starting index builder!")
  29. index_builder = IndexBuilder()
  30. index_builder.build_and_save_index()
  31. print_rank_0("Build and save indices: done!")
  32. print_rank_0("Starting evaluations!")
  33. # Set up the model and evaluator
  34. evaluator = ORQAEvaluator()
  35. # Run evaluation
  36. if args.qa_data_dev is not None:
  37. evaluator.evaluate(args.qa_data_dev, "DEV")
  38. if args.qa_data_test is not None:
  39. evaluator.evaluate(args.qa_data_test, "TEST")