关于forward里的data,kwargs细节咨询

#11
by fridayfairy - opened

给的demo里,使用的是chat接口。请问源码里的forward接口该如何使用?里面的data kwargs需要怎么配置

OpenBMB org
    if sampling:
        generation_config = {
            "top_p": 0.8,
            "top_k": 100,
            "temperature": 0.7,
            "do_sample": True,
            "repetition_penalty": 1.05
        }
    else:
        generation_config = {
            "num_beams": 3,
            "repetition_penalty": 1.2,
        }

    generation_config.update(
        (k, kwargs[k]) for k in generation_config.keys() & kwargs.keys()
    )

    with torch.inference_mode():
        res, vision_hidden_states = self.generate(
            input_id_list=[input_ids],
            max_inp_length=max_inp_length,
            img_list=[images],
            tgt_sizes=[tgt_sizes],
            tokenizer=tokenizer,
            max_new_tokens=max_new_tokens,
            vision_hidden_states=vision_hidden_states,
            return_vision_hidden_states=True,
            **generation_config
        )
    answer = res[0]

    return answer 

请问是在寻找这里嘛

fridayfairy changed discussion status to closed

Sign up or log in to comment