Skip to content

Commit

Permalink
Fix duplicating latest prompt (#5546)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #5546

The last prompt sent would be included in `getConversationHistory()` + adding it prior to sending it with the generate(). It looks like this got move during the rebasing.

To fix this we now call `getConversationHistory()` prior to adding the rawPrompt to a Message.

In regards to model response, I noticed that it did not really change the quality of the response. (tested with Llama 3.1)

Reviewed By: Riandy

Differential Revision: D62761977

fbshipit-source-id: 2f975983965fe837147f1ffb8b5dcfa8f2061895
  • Loading branch information
cmodi-meta authored and facebook-github-bot committed Sep 23, 2024
1 parent b361f91 commit 3b63839
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,14 @@ private void onModelRunStopped() {
mSendButton.setOnClickListener(
view -> {
addSelectedImagesToChatThread(mSelectedImageUri);
String finalPrompt;
String rawPrompt = mEditTextMessage.getText().toString();
if (ModelUtils.getModelCategory(mCurrentSettingsFields.getModelType())
== ModelUtils.VISION_MODEL) {
finalPrompt = mCurrentSettingsFields.getFormattedSystemAndUserPrompt(rawPrompt);
} else {
finalPrompt = getTotalFormattedPrompt(getConversationHistory(), rawPrompt);
}
// We store raw prompt into message adapter, because we don't want to show the extra
// tokens from system prompt
mMessageAdapter.add(new Message(rawPrompt, true, MessageType.TEXT, promptID));
Expand Down Expand Up @@ -692,14 +699,12 @@ public void run() {
if (ModelUtils.getModelCategory(mCurrentSettingsFields.getModelType())
== ModelUtils.VISION_MODEL) {
mModule.generateFromPos(
mCurrentSettingsFields.getFormattedSystemAndUserPrompt(rawPrompt),
finalPrompt,
ModelUtils.VISION_MODEL_SEQ_LEN,
startPos,
MainActivity.this,
false);
} else {
String finalPrompt =
getTotalFormattedPrompt(getConversationHistory(), rawPrompt);
ETLogging.getInstance().log("Running inference.. prompt=" + finalPrompt);
mModule.generate(
finalPrompt,
Expand Down

0 comments on commit 3b63839

Please sign in to comment.