|
11 | 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12 | 12 | # See the License for the specific language governing permissions and
|
13 | 13 | # limitations under the License.
|
14 |
| -from .configuration_utils import GenerationConfig |
15 |
| -from .logits_process import ( |
16 |
| - ForcedBOSTokenLogitsProcessor, |
17 |
| - ForcedEOSTokenLogitsProcessor, |
18 |
| - HammingDiversityLogitsProcessor, |
19 |
| - LogitsProcessor, |
20 |
| - LogitsProcessorList, |
21 |
| - MinLengthLogitsProcessor, |
22 |
| - RepetitionPenaltyLogitsProcessor, |
23 |
| - TopKProcess, |
24 |
| - TopPProcess, |
25 |
| -) |
26 |
| -from .stopping_criteria import ( |
27 |
| - MaxLengthCriteria, |
28 |
| - MaxTimeCriteria, |
29 |
| - StoppingCriteria, |
30 |
| - StoppingCriteriaList, |
31 |
| - validate_stopping_criteria, |
32 |
| -) |
33 |
| -from .streamers import BaseStreamer, TextIteratorStreamer, TextStreamer |
34 |
| -from .utils import BeamSearchScorer, GenerationMixin, get_unfinished_flag |
| 14 | + |
| 15 | +import sys |
| 16 | +from typing import TYPE_CHECKING |
| 17 | + |
| 18 | +from ..utils.lazy_import import _LazyModule |
| 19 | + |
| 20 | +import_structure = { |
| 21 | + "utils": [ |
| 22 | + "GenerationMixin", |
| 23 | + "MinLengthLogitsProcessor", |
| 24 | + "convert_dtype", |
| 25 | + "get_unfinished_flag", |
| 26 | + "LogitsProcessor", |
| 27 | + "BeamHypotheses", |
| 28 | + "RepetitionPenaltyLogitsProcessor", |
| 29 | + "LogitsProcessorList", |
| 30 | + "TopKProcess", |
| 31 | + "map_structure", |
| 32 | + "BeamSearchScorer", |
| 33 | + "TopPProcess", |
| 34 | + "get_scale_by_dtype", |
| 35 | + "validate_stopping_criteria", |
| 36 | + ], |
| 37 | + "model_outputs": ["ModelOutput"], |
| 38 | + "configuration_utils": ["GenerationConfig", "resolve_hf_generation_config_path"], |
| 39 | + "logits_process": [ |
| 40 | + "MinLengthLogitsProcessor", |
| 41 | + "SequenceBiasLogitsProcessor", |
| 42 | + "NoRepeatNGramLogitsProcessor", |
| 43 | + "PrefixConstrainedLogitsProcessor", |
| 44 | + "TopPProcess", |
| 45 | + "LogitsWarper", |
| 46 | + "HammingDiversityLogitsProcessor", |
| 47 | + "ForcedEOSTokenLogitsProcessor", |
| 48 | + "ForcedBOSTokenLogitsProcessor", |
| 49 | + "LogitsProcessor", |
| 50 | + "RepetitionPenaltyLogitsProcessor", |
| 51 | + "TemperatureLogitsWarper", |
| 52 | + "TopKProcess", |
| 53 | + "_get_ngrams", |
| 54 | + "_get_generated_ngrams", |
| 55 | + "LogitsProcessorList", |
| 56 | + "NoBadWordsLogitsProcessor", |
| 57 | + "_calc_banned_ngram_tokens", |
| 58 | + ], |
| 59 | + "stopping_criteria": [ |
| 60 | + "validate_stopping_criteria", |
| 61 | + "StoppingCriteria", |
| 62 | + "MaxLengthCriteria", |
| 63 | + "StoppingCriteriaList", |
| 64 | + "MaxTimeCriteria", |
| 65 | + ], |
| 66 | + "streamers": ["BaseStreamer", "TextIteratorStreamer", "TextStreamer"], |
| 67 | +} |
| 68 | + |
| 69 | +if TYPE_CHECKING: |
| 70 | + from .configuration_utils import GenerationConfig |
| 71 | + from .logits_process import ( |
| 72 | + ForcedBOSTokenLogitsProcessor, |
| 73 | + ForcedEOSTokenLogitsProcessor, |
| 74 | + HammingDiversityLogitsProcessor, |
| 75 | + LogitsProcessor, |
| 76 | + LogitsProcessorList, |
| 77 | + MinLengthLogitsProcessor, |
| 78 | + RepetitionPenaltyLogitsProcessor, |
| 79 | + TopKProcess, |
| 80 | + TopPProcess, |
| 81 | + ) |
| 82 | + from .stopping_criteria import ( |
| 83 | + MaxLengthCriteria, |
| 84 | + MaxTimeCriteria, |
| 85 | + StoppingCriteria, |
| 86 | + StoppingCriteriaList, |
| 87 | + validate_stopping_criteria, |
| 88 | + ) |
| 89 | + from .streamers import BaseStreamer, TextIteratorStreamer, TextStreamer |
| 90 | + from .utils import BeamSearchScorer, GenerationMixin, get_unfinished_flag |
| 91 | +else: |
| 92 | + sys.modules[__name__] = _LazyModule( |
| 93 | + __name__, |
| 94 | + globals()["__file__"], |
| 95 | + import_structure, |
| 96 | + module_spec=__spec__, |
| 97 | + ) |
0 commit comments