Skip to content

Conversation

@heimoshuiyu
Copy link
Contributor

@mayeaux
Copy link
Contributor

mayeaux commented Apr 24, 2023

Doesn't seem to work for me, I tried it with a movie that starts with music and it still fell into a bad hallucination/failure loop 🤷‍♂️

@Purfview
Copy link
Contributor

Purfview commented Sep 1, 2023

Works well, and the users reported positive experience with this PR.

@realtechspecs
Copy link

Doesn't seem to work for me, I tried it with a movie that starts with music and it still fell into a bad hallucination/failure loop 🤷‍♂️

Can you share the movie you tried it with

@doko-desuka
Copy link

doko-desuka commented Jun 27, 2025

A different style for that block but with the same behavior:

                max_repetitions = 1
                stripped_text = text.strip()
                recent_prompt_text = all_prompt_text[-max_repetitions:]
                if recent_prompt_text.count(stripped_text) < max_repetitions:
                    all_tokens.extend(tokens)
                    all_prompt_text.append(stripped_text)

...and max_repetitions could be made into a new transcription setting, for example.

But if someone only needs to check the latest text (i.e. max_repetitions=1), it can be reduced to this:

        last_decoded_text = None

        (...)

                # Don't accumulate tokens if they form the same text as the previous segment.
                stripped_text = text.strip()
                if last_decoded_text != stripped_text:
                    all_tokens.extend(tokens)
                    last_decoded_text = stripped_text

At first I thought what you wanted was already addressed by the repetition_penalty setting. But according to this great comment, that setting works on all tokens at once, it discourages the use of tokens even if the sentence is completely different. The (CPU) implementation is this btw.

So what you're doing is another type of penalty, discouraging repeating sentences/segment texts (formed by many tokens) rather than penalizing individual tokens. Very useful.

Edit: I guess kinda like a dynamic no_repeat_ngram_size, instead of avoiding ngrams of a specific size, you avoid anything that repeats.

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.

6 participants