NLP/error
[error] PeftModelForCausalLM.generate() takes 1 positional argument and 2 were given
HEY, GERONIMO
2023. 9. 19. 18:00
해결책
beam_output = model.generate(
input_ids=input_ids, # 정확히 input_ids 인자라고 알려줘야 한다
do_sample=True,
top_k=10,
max_new_tokens=32,
min_new_tokens=16,
output_scores=True,
num_beams=BEAM_SIZE,
repetition_penalty=10.0,
return_dict_in_generate=True,
num_return_sequences=BEAM_SIZE,
)
- input_ids=input_ids 라고 정확히 이야기해야 한다
문제점
beam_output = model.generate(
input_ids, # 기존 모델은 이렇게 명시하지 않아도 암묵적으로 수행했다
do_sample=True,
top_k=10,
max_new_tokens=32,
min_new_tokens=16,
output_scores=True,
num_beams=BEAM_SIZE,
repetition_penalty=10.0,
return_dict_in_generate=True,
num_return_sequences=BEAM_SIZE,
)
- PEFT 를 사용하지 않는 모델은 input_ids 를 굳이 정확하게 넣어주지 않아도 첫번째에 위치하면 알아서 인자로 인식했다
- PEFT 를 사용한 모델은 정확히 input_ids, attention_mask 등 어떤 인자에 위치하는지 알려줘야 한다
참고
https://github.com/huggingface/peft/issues/708
PeftModelForCausalLM.generate() takes 1 positional argument and 2 were given · Issue #708 · huggingface/peft
System Info peft: 0.3.0 accelerate: 0.20.3 transformers: 4.31.0.dev0 Hello! I am having trouble with the following code: import torch from transformers import LlamaForCausalLM, GenerationConfig, Ll...
github.com