salesforce / CodeT5

Home of CodeT5: Open Code LLMs for Code Understanding and Generation
https://arxiv.org/abs/2305.07922
BSD 3-Clause "New" or "Revised" License
2.66k stars 391 forks source link

How to infer from multiple code spans? #81

Closed sqhan-Husky closed 1 year ago

sqhan-Husky commented 1 year ago

Hello, thank you for the great work. l have a question about how to infer from multiple code spans related to the updation on Sep 24, 2021. The case you shown is that"def greet(user): print(f'hello <extra_id_0>!')" and the prediction is "{user.username}". What if l want to predict multiple spans in one code input?

For example, l learned from T5 that a pair of input and its label can be:

input_ids = "The <extra_id_0> walks in <extra_id_1> park"
labels = "<extra_id_0> cute dog <extra_id_1> the <extra_id_2>"

However, this way seems to be failed in CodeT5. When l input "def greet(user): <extra_id_0>(f'hello <extra_id_1>!')", the prediction outputs "user = user print" , without any identification of which span the output belongs to.

Can you show us some examples of the input and the corresponding label with multiple spans in one code input?

sqhan-Husky commented 1 year ago

I find that the parameter skip_special_tokens can output the split identification of <extra_id_x>,and currently the output is <pad><s><extra_id_0>user = user print<extra_id_1>world!') print ( f'hello world!{user. The length of the output is truncated by the setting of max_length, and it cannot predict a correct ending label of the output. If l set the max_length to 100, the output is <pad><s><extra_id_0>user = user print<extra_id_1>world!') print ( f'hello world!{user}')print(f'hello world!{user}')print(f'hello world!{user}')print(f'hello world!{user}')print(f'hello world!{user}')print(f'hello world!{user}')print(f'hello world!{user}')print(f'hello world!{user}')print.

Why this output?