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

Question in training reader model. #231

Open
gaishun opened this issue Sep 1, 2022 · 1 comment
Open

Question in training reader model. #231

gaishun opened this issue Sep 1, 2022 · 1 comment

Comments

@gaishun
Copy link

gaishun commented Sep 1, 2022

Hi, I'm trying to reproduce this work and I have trouble training the reader.
It's not clear to me which file path to the retriever train set results file and path to the retriever dev set results file refer to.
I am expecting any replies.

@gaishun
Copy link
Author

gaishun commented Sep 1, 2022

I use the dataset biencoder-nq-train.json and biencoder-nq-dev.json ( download from dpr/data/download_data.py ).
Error information like that:

Traceback (most recent call last):
  File "train_extractive_reader.py", line 574, in <module>
    main()
  File "/home/ykw/anaconda3/envs/DPR/lib/python3.8/site-packages/hydra/main.py", line 90, in decorated_main
    _run_hydra(
  File "/home/ykw/anaconda3/envs/DPR/lib/python3.8/site-packages/hydra/_internal/utils.py", line 389, in _run_hydra
    _run_app(
  File "/home/ykw/anaconda3/envs/DPR/lib/python3.8/site-packages/hydra/_internal/utils.py", line 452, in _run_app
    run_and_report(
  File "/home/ykw/anaconda3/envs/DPR/lib/python3.8/site-packages/hydra/_internal/utils.py", line 216, in run_and_report
    raise ex
  File "/home/ykw/anaconda3/envs/DPR/lib/python3.8/site-packages/hydra/_internal/utils.py", line 213, in run_and_report
    return func()
  File "/home/ykw/anaconda3/envs/DPR/lib/python3.8/site-packages/hydra/_internal/utils.py", line 453, in <lambda>
    lambda: hydra.run(
  File "/home/ykw/anaconda3/envs/DPR/lib/python3.8/site-packages/hydra/_internal/hydra.py", line 132, in run
    _ = ret.return_value
  File "/home/ykw/anaconda3/envs/DPR/lib/python3.8/site-packages/hydra/core/utils.py", line 260, in return_value
    raise self._return_value
  File "/home/ykw/anaconda3/envs/DPR/lib/python3.8/site-packages/hydra/core/utils.py", line 186, in run_job
    ret.return_value = task_function(task_cfg)
  File "train_extractive_reader.py", line 555, in main
    trainer.run_train()
  File "train_extractive_reader.py", line 147, in run_train
    train_iterator = self.get_data_iterator(
  File "train_extractive_reader.py", line 127, in get_data_iterator
    dataset.load_data()
  File "/home/ykw/DPR-main/dpr/data/reader_data.py", line 141, in load_data
    preprocessed_data_files = self._get_preprocessed_files(data_files)
  File "/home/ykw/DPR-main/dpr/data/reader_data.py", line 185, in _get_preprocessed_files
    serialized_files = _run_preprocessing(self.tensorizer)
  File "/home/ykw/DPR-main/dpr/data/reader_data.py", line 173, in _run_preprocessing
    serialized_files = convert_retriever_results(
  File "/home/ykw/DPR-main/dpr/data/reader_data.py", line 361, in convert_retriever_results
    for file_name in workers.map(_parse_batch, chunks):
  File "/home/ykw/anaconda3/envs/DPR/lib/python3.8/multiprocessing/pool.py", line 364, in map
    return self._map_async(func, iterable, mapstar, chunksize).get()
  File "/home/ykw/anaconda3/envs/DPR/lib/python3.8/multiprocessing/pool.py", line 768, in get
    raise self._value
KeyError: 'ctxs'

When I use the result file from

python dense_retriever.py \
	model_file={path to a checkpoint downloaded from our download_data.py as 'checkpoint.retriever.single.nq.bert-base-encoder'} \
	qa_dataset={the name os the test source} \
	ctx_datatsets=[{list of passage sources's names, comma separated without spaces}] \
	encoded_ctx_files=[{list of encoded document files glob expression, comma separated without spaces}] \
	out_file={path to output json file with results} 

the error information like that:

[2022-09-01 23:19:24,106][root][INFO] - Total iterations per epoch=225
[2022-09-01 23:19:24,106][root][INFO] -  Total updates=22500000
[2022-09-01 23:19:24,106][root][INFO] -   Eval step = 2000
[2022-09-01 23:19:24,106][root][INFO] - ***** Training *****
[2022-09-01 23:19:24,106][root][INFO] - ***** Epoch 0 *****
Error executing job with overrides: ['encoder.sequence_length=350', 'train_files=/home/ykw/DPR-main/model_best/model/nq_nq_test/nq_nq_test.out.json', 'dev_files=/home/ykw/DPR-main/dataset/biencoder-nq-dev.json', 'output_dir=/home/ykw/DPR-main/temp/']
Traceback (most recent call last):
  File "train_extractive_reader.py", line 574, in <module>
    main()
  File "/home/ykw/anaconda3/envs/DPR/lib/python3.8/site-packages/hydra/main.py", line 90, in decorated_main
    _run_hydra(
  File "/home/ykw/anaconda3/envs/DPR/lib/python3.8/site-packages/hydra/_internal/utils.py", line 389, in _run_hydra
    _run_app(
  File "/home/ykw/anaconda3/envs/DPR/lib/python3.8/site-packages/hydra/_internal/utils.py", line 452, in _run_app
    run_and_report(
  File "/home/ykw/anaconda3/envs/DPR/lib/python3.8/site-packages/hydra/_internal/utils.py", line 216, in run_and_report
    raise ex
  File "/home/ykw/anaconda3/envs/DPR/lib/python3.8/site-packages/hydra/_internal/utils.py", line 213, in run_and_report
    return func()
  File "/home/ykw/anaconda3/envs/DPR/lib/python3.8/site-packages/hydra/_internal/utils.py", line 453, in <lambda>
    lambda: hydra.run(
  File "/home/ykw/anaconda3/envs/DPR/lib/python3.8/site-packages/hydra/_internal/hydra.py", line 132, in run
    _ = ret.return_value
  File "/home/ykw/anaconda3/envs/DPR/lib/python3.8/site-packages/hydra/core/utils.py", line 260, in return_value
    raise self._return_value
  File "/home/ykw/anaconda3/envs/DPR/lib/python3.8/site-packages/hydra/core/utils.py", line 186, in run_job
    ret.return_value = task_function(task_cfg)
  File "train_extractive_reader.py", line 555, in main
    trainer.run_train()
  File "train_extractive_reader.py", line 186, in run_train
    global_step = self._train_epoch(scheduler, epoch, eval_step, train_iterator, global_step)
  File "train_extractive_reader.py", line 297, in _train_epoch
    input = create_reader_input(
  File "/home/ykw/DPR-main/dpr/models/reader.py", line 146, in create_reader_input
    sample_tensors = _create_question_passages_tensors(
  File "/home/ykw/DPR-main/dpr/models/reader.py", line 222, in _create_question_passages_tensors
    positive_idx = _get_positive_idx(positives, max_len, is_random)
  File "/home/ykw/DPR-main/dpr/models/reader.py", line 199, in _get_positive_idx
    positive_idx = np.random.choice(len(positives)) if is_random else 0
  File "mtrand.pyx", line 909, in numpy.random.mtrand.RandomState.choice
ValueError: a must be greater than 0 unless no samples are taken

So... what is the retriever train/dev set results file

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant