Unable to distinguish my language field,all is python

#6
by xijiang - opened

prompt = "# language: Python\n# write a bubble sort function\n"
inputs = tokenizer.encode(prompt, return_tensors="pt").to(model.device)
generate_args = {"max_length": 256, "eos_token_id": 2, "pad_token_id": 2}
outputs = model.generate(inputs, **generate_args)
print(tokenizer.decode(outputs[0]))

language: Python

write a bubble sort function

def bubble_sort(list):
for i in range(len(list) - 1):
for j in range(len(list) - 1):
if list[j] > list[j + 1]:
list[j], list[j + 1] = list[j + 1], list[j]
return list

print(bubble_sort([5, 2, 4, 6, 1, 3]))

prompt = "# language: C++\n# write a bubble sort function\n"
inputs = tokenizer.encode(prompt, return_tensors="pt").to(model.device)
generate_args = {"max_length": 256, "eos_token_id": 2, "pad_token_id": 2}
outputs = model.generate(inputs, **generate_args)
print(tokenizer.decode(outputs[0]))

language: C++

write a bubble sort function

def bubble_sort(list):
for i in range(len(list) - 1):
for j in range(len(list) - 1):
if list[j] > list[j + 1]:
list[j], list[j + 1] = list[j + 1], list[j]
return list

print(bubble_sort([5, 2, 1, 8, 4]))

Knowledge Engineering Group (KEG) & Data Mining at Tsinghua University org

Hi, the prompts are incorrect. The open-source CodeGeeX2-6B is a foundation code model, it should be used according to the coding conventions of a specific language. For instance, C++ should use the comment symbol "//". The language tag should be "// language: C++", and the prompt should be "// [prompt]". In your example, you used "#", which is a comment symbol unique to Python, so it naturally generated Python code.

Hi, the prompts are incorrect. The open-source CodeGeeX2-6B is a foundation code model, it should be used according to the coding conventions of a specific language. For instance, C++ should use the comment symbol "//". The language tag should be "// language: C++", and the prompt should be "// [prompt]". In your example, you used "#", which is a comment symbol unique to Python, so it naturally generated Python code.

Thanks I got it

Sign up or log in to comment