dpfried / incoder

Generative model for code infilling and synthesis
291 stars 25 forks source link

How to use incoder for code infilling task #18

Closed Ghy0202 closed 10 months ago

Ghy0202 commented 11 months ago

Hello😃 A Great job! I am reaching out to inquire about the possibility of using the pre-trained incoder model provided by your team for code infilling tasks~ However, I have been unable to locate any relevant example code or documentation regarding the usage of the pre-trained incoder model for code infilling. I'm not sure how to get a correctly formatted input〒▽〒 I expected the input like:

fn main(){
let a = 10;
    let b = 20;
    let result: i32;
asm!(
<FILL HERE>
)
}

and the output will be like:

fn main(){
let a = 10;
    let b = 20;
    let result: i32;
asm!(
"add {0}, {1}", // Add the values of a and b
            out(reg) result,
            in(reg) a,
            in(reg) b
)
}
dpfried commented 10 months ago

Hi, sorry for the slow response!

If I remember correctly, you'll basically want to prompt the model with:

code prefix<|mask:0|>code suffix<|mask:0|>

We have some example code here: https://github.com/dpfried/incoder/blob/main/example_usage.py in the infill method that you could take a look at to verify this.

Ghy0202 commented 10 months ago

Hi, sorry for the slow response!

If I remember correctly, you'll basically want to prompt the model with:

code prefix<|mask:0|>code suffix<|mask:0|>

We have some example code here: https://github.com/dpfried/incoder/blob/main/example_usage.py in the infill method that you could take a look at to verify this.

Thank you! I solved the problem.😃~~