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

an issue in running factscore_eval.py with mode = prompt-contrastive-decoding #3

Open
hehebamei opened this issue Oct 21, 2024 · 0 comments

Comments

@hehebamei
Copy link

When I used this mode, I got the bug like this:

  • File "/data-store/shangguanzixuan/project/ICD-main/src/benchmark_evaluation/factscore_eval.py", line 225, in
    model_completion, c_dist = llm.generate(prompt, prompt_evil, **generate_kwargs)
    File "/data-store/shangguanzixuan/project/ICD-main/src/decoding_algorithm/contrastive_decoding.py", line 176, in generate
    outputs = self.model.generate(input_ids, evil_input_ids=evil_input_ids, max_length=max_len, num_return_sequences=1,
    File "/data-store/shangguanzixuan/anaconda3/envs/icd/lib/python3.10/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context
    return func(*args, **kwargs)
    File "/data-store/shangguanzixuan/project/ICD-main/transformers/src/transformers/generation/utils.py", line 1756, in generate
    return self.prompt_contrastive_decoding_sample(
    File "/data-store/shangguanzixuan/project/ICD-main/transformers/src/transformers/generation/utils.py", line 3780, in prompt_contrastive_decoding_sample
    evil_outputs = self(
    File "/data-store/shangguanzixuan/anaconda3/envs/icd/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
    File "/data-store/shangguanzixuan/project/ICD-main/transformers/src/transformers/models/llama/modeling_llama.py", line 821, in forward
    outputs = self.model(
    File "/data-store/shangguanzixuan/anaconda3/envs/icd/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
    File "/data-store/shangguanzixuan/project/ICD-main/transformers/src/transformers/models/llama/modeling_llama.py", line 659, in forward
    position_ids = position_ids.view(-1, seq_length).long()
    RuntimeError: shape '[-1, 177]' is invalid for input of size 105

I guess you didn't reset the information in the Class LlamaForCausalLM (such as position_ids) when you passed in two prompts, which caused this error.

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

No branches or pull requests

1 participant