Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CodeGen] Add CodeGen model for code generation #2641

Merged
merged 3 commits into from
Jun 28, 2022

Conversation

gongel
Copy link
Member

@gongel gongel commented Jun 24, 2022

PR types

New features

PR changes

Models

Description

  • Use example
from paddlenlp.transformers import CodeGenForCausalLM, CodeGenTokenizer

tokenizer = CodeGenTokenizer.from_pretrained('Salesforce/codegen-350M-mono')
model = CodeGenForCausalLM.from_pretrained('Salesforce/codegen-350M-mono')
# Note: left padding for batch input
inputs = tokenizer("def hello_world():", return_token_type_ids=False)
inputs = {k: paddle.to_tensor([v]) for (k, v) in inputs.items()}
output, score = model.generate(**inputs, max_length=128)
print(tokenizer.decode(output[0], skip_special_tokens=True))

@gongel gongel requested a review from guoshengCS June 24, 2022 10:31
Copy link
Contributor

@guoshengCS guoshengCS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@gongel gongel merged commit c19372b into PaddlePaddle:develop Jun 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants