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

examples: add repetition penalty #104

Closed
wants to merge 1 commit into from

Conversation

lxe
Copy link

@lxe lxe commented Apr 23, 2023

Fixes #55

Spot check:

 ../ggml/build/bin/gpt-2 --repeat_penalty 1.0 -p "The following is a short poem about cheese:" -m ./ggml-model-q4_0.bin
...
The following is a short poem about cheese:

It's good for your heart,
It's good for your health,
It's good for your feet and your heart.

It's good for your health
It's good for your heart
It's good for your feet
It's good for your feet.

If you eat the cheese,
It's good for your heart,
It's good for your feet and your heart.

It's good for your health,
It's good for your feet
It's good for your feet.

It's good for your feet,
It's good for your heart
It's good for your feet.

It's good for your feet,
It's good for your heart
It's good for your feet.<|endoftext|>
 ../ggml/build/bin/gpt-2 --repeat_penalty 1.2 -p "The following is a short poem about cheese:" -m ./ggml-model-q4_0.bin
...
The following is a short poem about cheese:

It's a beautiful day
With bright sunshine
And sweet cheese on my tongue
And a slice of my bread
That I have been longing for
Long past.
It's a beautiful day,
A beautiful day
With bright sunshine
And sweet cheese on my tongue.<|endoftext|>

@lxe lxe force-pushed the examples-repetition-penalty branch from 4ef3dea to de075ce Compare April 23, 2023 22:36
@lxe lxe force-pushed the examples-repetition-penalty branch from de075ce to ca6d016 Compare April 23, 2023 22:40
logits_id.push_back(std::make_pair(logits[i]*scale*repetition_penalty, i));
} else {
logits_id.push_back(std::make_pair(logits[i]*scale/repetition_penalty, i));
}
Copy link
Owner

Choose a reason for hiding this comment

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

Hm, I think we want to check if the token is repeated first?

Copy link
Author

Choose a reason for hiding this comment

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

I think I missed an outermost loop. Checking.

@ekryski
Copy link

ekryski commented May 12, 2023

While I'm eager to play with some of this with some of the other models, it's probably better to just combine llama.cpp + ggml into a better structure rather than duplicate solutions in both spots. I'd help but my C foo is terrible. 😞

So instead I'm cheerleading! 😀

@ggerganov
Copy link
Owner

Repeat penalty is now available in common

@ggerganov ggerganov closed this May 27, 2023
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.

Repetition penalty?
3 participants