unitorch.cli.models.gemma¤
GemmaProcessor¤
Tip
core/process/gemma is the section for configuration of GemmaProcessor.
Bases: GemmaProcessor
Processor for Gemma decoder-only generation tasks.
Source code in src/unitorch/cli/models/gemma/processing.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | |
from_config
classmethod
¤
from_config(config, **kwargs)
Source code in src/unitorch/cli/models/gemma/processing.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | |
_chat_template ¤
_chat_template(messages: List[Dict[str, Any]])
Source code in src/unitorch/cli/models/gemma/processing.py
65 66 67 68 69 70 | |
_generation_inputs ¤
_generation_inputs(
text: str, max_seq_length: Optional[int] = None
)
Source code in src/unitorch/cli/models/gemma/processing.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 | |
_generation_labels ¤
_generation_labels(
text: str, max_gen_seq_length: Optional[int] = None
)
Source code in src/unitorch/cli/models/gemma/processing.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 | |
_generation ¤
_generation(
text: str,
text_pair: str,
max_seq_length: Optional[int] = None,
max_gen_seq_length: Optional[int] = None,
)
Source code in src/unitorch/cli/models/gemma/processing.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | |
_messages_generation ¤
_messages_generation(
messages: List[Dict[str, Any]],
max_seq_length: Optional[int] = None,
)
Source code in src/unitorch/cli/models/gemma/processing.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | |
_detokenize ¤
_detokenize(outputs: GenerationOutputs)
Source code in src/unitorch/cli/models/gemma/processing.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | |
GemmaVLProcessor¤
Tip
core/process/gemma_vl is the section for configuration of GemmaVLProcessor.
Bases: GemmaVLProcessor
Processor for Gemma multimodal generation tasks.
Source code in src/unitorch/cli/models/gemma/processing_vl.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | |
from_config
classmethod
¤
from_config(config, **kwargs)
Source code in src/unitorch/cli/models/gemma/processing_vl.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | |
_chat_template ¤
_chat_template(messages: List[Dict[str, Any]])
Source code in src/unitorch/cli/models/gemma/processing_vl.py
77 78 79 80 81 82 | |
_generation_inputs ¤
_generation_inputs(
text: str,
images: Union[Image, str, List[Image], List[str]],
max_seq_length: Optional[int] = None,
)
Source code in src/unitorch/cli/models/gemma/processing_vl.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |
_generation_labels ¤
_generation_labels(
text: str, max_gen_seq_length: Optional[int] = None
)
Source code in src/unitorch/cli/models/gemma/processing_vl.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 | |
_generation ¤
_generation(
text: str,
images: Union[Image, str, List[Image], List[str]],
text_pair: str,
max_seq_length: Optional[int] = None,
max_gen_seq_length: Optional[int] = None,
)
Source code in src/unitorch/cli/models/gemma/processing_vl.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | |
_messages_generation ¤
_messages_generation(
messages: List[Dict[str, Any]],
images: Union[Image, str, List[Image], List[str]],
max_seq_length: Optional[int] = None,
)
Source code in src/unitorch/cli/models/gemma/processing_vl.py
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | |
_detokenize ¤
_detokenize(outputs: GenerationOutputs)
Source code in src/unitorch/cli/models/gemma/processing_vl.py
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | |
GemmaForGeneration¤
Tip
core/model/generation/gemma is the section for configuration of GemmaForGeneration.
Bases: GemmaForGeneration
Gemma model for text generation.
Source code in src/unitorch/cli/models/gemma/modeling.py
28 29 30 31 32 33 34 35 36 | |
from_config
classmethod
¤
from_config(config, **kwargs)
Source code in src/unitorch/cli/models/gemma/modeling.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | |
forward ¤
forward(
input_ids: Tensor,
attention_mask: Optional[Tensor] = None,
)
Source code in src/unitorch/cli/models/gemma/modeling.py
90 91 92 93 94 95 96 97 98 99 100 101 102 103 | |
generate ¤
generate(
input_ids: Tensor,
attention_mask: Optional[Tensor] = None,
num_beams: Optional[int] = 5,
decoder_start_token_id: Optional[int] = 2,
decoder_end_token_id: Optional[
Union[int, List[int]]
] = 1,
decoder_pad_token_id: Optional[int] = 0,
num_return_sequences: Optional[int] = 1,
min_gen_seq_length: Optional[int] = 0,
max_gen_seq_length: Optional[int] = 512,
repetition_penalty: Optional[float] = 1.0,
no_repeat_ngram_size: Optional[int] = 0,
early_stopping: Optional[bool] = True,
length_penalty: Optional[float] = 1.0,
num_beam_groups: Optional[int] = 1,
diversity_penalty: Optional[float] = 0.0,
do_sample: Optional[bool] = False,
temperature: Optional[float] = 1.0,
top_k: Optional[int] = 50,
top_p: Optional[float] = 1.0,
)
Source code in src/unitorch/cli/models/gemma/modeling.py
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | |
GemmaVLForGeneration¤
Tip
core/model/generation/gemma_vl is the section for configuration of GemmaVLForGeneration.
Bases: GemmaVLForGeneration
Gemma multimodal model for image-grounded generation.
Source code in src/unitorch/cli/models/gemma/modeling_vl.py
28 29 30 31 32 33 34 35 36 | |
from_config
classmethod
¤
from_config(config, **kwargs)
Source code in src/unitorch/cli/models/gemma/modeling_vl.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | |
forward ¤
forward(
input_ids: Tensor,
pixel_values: Optional[Tensor] = None,
image_position_ids: Optional[Tensor] = None,
attention_mask: Optional[Tensor] = None,
mm_token_type_ids: Optional[Tensor] = None,
)
Source code in src/unitorch/cli/models/gemma/modeling_vl.py
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | |
generate ¤
generate(
input_ids: Tensor,
pixel_values: Optional[Tensor] = None,
image_position_ids: Optional[Tensor] = None,
attention_mask: Optional[Tensor] = None,
mm_token_type_ids: Optional[Tensor] = None,
num_beams: Optional[int] = 5,
decoder_start_token_id: Optional[int] = 2,
decoder_end_token_id: Optional[
Union[int, List[int]]
] = 1,
decoder_pad_token_id: Optional[int] = 0,
num_return_sequences: Optional[int] = 1,
min_gen_seq_length: Optional[int] = 0,
max_gen_seq_length: Optional[int] = 512,
repetition_penalty: Optional[float] = 1.0,
no_repeat_ngram_size: Optional[int] = 0,
early_stopping: Optional[bool] = True,
length_penalty: Optional[float] = 1.0,
num_beam_groups: Optional[int] = 1,
diversity_penalty: Optional[float] = 0.0,
do_sample: Optional[bool] = False,
temperature: Optional[float] = 1.0,
top_k: Optional[int] = 50,
top_p: Optional[float] = 1.0,
)
Source code in src/unitorch/cli/models/gemma/modeling_vl.py
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | |