Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
b35aa4c
added classes to get started with constrained beam search
cwkeam Jan 9, 2022
a2ba6c4
in progress, think i can directly force tokens now but not yet with t…
cwkeam Jan 15, 2022
c36eaa2
think now i have total control, now need to code the bank selection
cwkeam Jan 19, 2022
13c1808
technically works as desired, need to optimize and fix design choices…
cwkeam Jan 20, 2022
8363aa5
Merge branch 'huggingface:master' into master
cwkeam Jan 23, 2022
8a0d871
complete PR #1 without disjunctive decoding
cwkeam Jan 23, 2022
3776c25
Merge branch 'master' of https://github.com/cwkeam/transformers
cwkeam Jan 23, 2022
125a9aa
removed incorrect tests
cwkeam Jan 23, 2022
9fcba0d
Delete k.txt
cwkeam Jan 23, 2022
3773495
Delete test.py
cwkeam Jan 23, 2022
d214c83
Delete test.sh
cwkeam Jan 23, 2022
2625580
revert changes to test scripts
cwkeam Jan 23, 2022
f34c3aa
Merge branch 'master' of https://github.com/cwkeam/transformers
cwkeam Jan 23, 2022
859262a
Merge branch 'master' into master
cwkeam Jan 29, 2022
97dc8cc
genutils
cwkeam Jan 29, 2022
b5ce4f4
Merge branch 'master' of https://github.com/cwkeam/transformers
cwkeam Jan 29, 2022
91a6403
full implementation with testing, no disjunctive yet
cwkeam Jan 31, 2022
10f0679
shifted docs
cwkeam Jan 31, 2022
e6b60f3
Merge branch 'huggingface:master' into constrained_beam_search
cwkeam Jan 31, 2022
db9e964
passing all tests realistically ran locally
cwkeam Jan 31, 2022
8242282
removing accidentally included print statements
cwkeam Jan 31, 2022
88945d5
fixed source of error in initial PR test
cwkeam Jan 31, 2022
73f3acd
fixing the get_device() vs device trap
cwkeam Jan 31, 2022
42efa23
fixed documentation docstrings about constrained_beam_search
cwkeam Jan 31, 2022
fb2195a
fixed tests having failing for Speech2TextModel's floating point inputs
cwkeam Jan 31, 2022
f522031
fix cuda long tensor
patrickvonplaten Jan 31, 2022
d50fc39
Merge branch 'constrained_beam_search' of https://github.com/cwkeam/t…
patrickvonplaten Jan 31, 2022
12ac97d
added examples and testing for them and founx & fixed a bug in beam_s…
cwkeam Feb 3, 2022
ea5fe70
merge fix
cwkeam Feb 3, 2022
2169a9f
deleted accidentally added test halting code with assert False
cwkeam Feb 3, 2022
77660bd
code reformat
cwkeam Feb 3, 2022
b21aae0
Update tests/test_generation_utils.py
cwkeam Feb 4, 2022
0050621
Update tests/test_generation_utils.py
cwkeam Feb 4, 2022
3e35647
Update tests/test_generation_utils.py
cwkeam Feb 4, 2022
edd8681
Update tests/test_generation_utils.py
cwkeam Feb 4, 2022
71125d0
Merge branch 'huggingface:master' into constrained_beam_search
cwkeam Feb 4, 2022
e1f6419
Update tests/test_generation_utils.py
patrickvonplaten Feb 7, 2022
ba7a310
fixing based on comments on PR
cwkeam Feb 8, 2022
77a18ae
took out the testing code that should but work fails without the beam…
cwkeam Feb 8, 2022
7a78633
fixing comments issues
cwkeam Feb 9, 2022
bbd9e88
docstrings for ConstraintListState
cwkeam Feb 9, 2022
17ab474
typo in PhrsalConstraint docstring
cwkeam Feb 9, 2022
aab1d9e
Merge branch 'huggingface:master' into constrained_beam_search
cwkeam Feb 9, 2022
88e938d
docstrings improvements
cwkeam Feb 9, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions docs/source/internal/generation_utils.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ This page lists all the utility functions used by [`~generation_utils.Generation
[`~generation_utils.GenerationMixin.greedy_search`],
[`~generation_utils.GenerationMixin.sample`],
[`~generation_utils.GenerationMixin.beam_search`],
[`~generation_utils.GenerationMixin.beam_sample`], and
[`~generation_utils.GenerationMixin.group_beam_search`].
[`~generation_utils.GenerationMixin.beam_sample`],
[`~generation_utils.GenerationMixin.group_beam_search`], and
[`~generation_utils.GenerationMixin.constrained_beam_search`].

Most of those are only useful if you are studying the code of the generate methods in the library.

Expand Down Expand Up @@ -190,6 +191,16 @@ A [`StoppingCriteria`] can be used to change when to stop generation (other than
[[autodoc]] MaxTimeCriteria
- __call__

## Constraints

A [`Constraint`] can be used to force the generation to include specific tokens or sequences in the output.

[[autodoc]] Constraint

[[autodoc]] PhrasalConstraint

[[autodoc]] ConstraintListState

## BeamSearch

[[autodoc]] BeamScorer
Expand All @@ -200,6 +211,10 @@ A [`StoppingCriteria`] can be used to change when to stop generation (other than
- process
- finalize

[[autodoc]] ConstrainedBeamSearchScorer
- process
- finalize

## Utilities

[[autodoc]] top_k_top_p_filtering
Expand Down
10 changes: 8 additions & 2 deletions src/transformers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,12 @@
"TextDatasetForNextSentencePrediction",
]
_import_structure["deepspeed"] = []
_import_structure["generation_beam_search"] = ["BeamScorer", "BeamSearchScorer"]
_import_structure["generation_beam_constraints"] = [
"Constraint",
"ConstraintListState",
"PhrasalConstraint",
]
_import_structure["generation_beam_search"] = ["BeamScorer", "BeamSearchScorer", "ConstrainedBeamSearchScorer"]
_import_structure["generation_logits_process"] = [
"ForcedBOSTokenLogitsProcessor",
"ForcedEOSTokenLogitsProcessor",
Expand Down Expand Up @@ -2748,7 +2753,8 @@
TextDataset,
TextDatasetForNextSentencePrediction,
)
from .generation_beam_search import BeamScorer, BeamSearchScorer
from .generation_beam_constraints import Constraint, ConstraintListState, PhrasalConstraint
from .generation_beam_search import BeamScorer, BeamSearchScorer, ConstrainedBeamSearchScorer
from .generation_logits_process import (
ForcedBOSTokenLogitsProcessor,
ForcedEOSTokenLogitsProcessor,
Expand Down
Loading