Skip to content

Conversation

cmodi-meta
Copy link
Contributor

To allow the developer to set whether the response should echo (i.e. include) the input prompt.

  • echo = true then token_callback for output will also include input (i.e. Text Completion).
  • echo = false then token_callback for output will not include input (i.e. Chat generation).

We'll default to true since that will maintain the existing flow.

Copy link

pytorch-bot bot commented Aug 30, 2024

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/5011

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit d081b02 with merge base c83fd2e (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 30, 2024
@kirklandsign
Copy link
Contributor

linter 😶‍🌫️

Copy link
Contributor

@larryliu0820 larryliu0820 left a comment

Choose a reason for hiding this comment

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

Looks good!

@facebook-github-bot
Copy link
Contributor

@larryliu0820 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Riandy added a commit to Riandy/executorch that referenced this pull request Sep 5, 2024
Summary: Echo flag is added in the runner side via pytorch#5011 by Chirag. Now, we update the app side to leverage the new echo flag, so that we don't display the user prompt in response.

Differential Revision: D62250116
@cmodi-meta cmodi-meta changed the title Add Echo parameter to llama runner and jni+java layer Add Echo parameter to llama runner, jni+java layer, and demo app Sep 5, 2024
@facebook-github-bot
Copy link
Contributor

@larryliu0820 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Comment on lines 219 to 221
if (echo) {
wrapped_callback(ET_UNWRAP(tokenizer_->decode(cur_token, cur_token)));
}
Copy link
Contributor

@larryliu0820 larryliu0820 Sep 5, 2024

Choose a reason for hiding this comment

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

I think we should always call wrapped_callback, otherwise we are missing the first generated token.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

from my testing, this callback would just return a newline. We also tested this and the output works well.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm I'm saying it doesn't matter what that token is. Semantically it is the first token the model generates, by prefilling the prompt, so we should trigger callback on this one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

got it! @larryliu0820, I've removed the echo around the first token generation.

public void onResult(String result) {
mResultMessage.appendText(result);
run();
if(result.equals("\n\n")) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Riandy fyi with this check on the app side.

@facebook-github-bot
Copy link
Contributor

@larryliu0820 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

cmodi-meta and others added 6 commits September 6, 2024 11:17
@facebook-github-bot
Copy link
Contributor

@larryliu0820 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
@facebook-github-bot
Copy link
Contributor

@larryliu0820 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot facebook-github-bot merged commit fb86e61 into main Sep 6, 2024
41 of 42 checks passed
@facebook-github-bot facebook-github-bot deleted the echo-parameter branch September 6, 2024 21:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants