Upload 2 files
Browse files- inflections_funcs.py +4 -2
inflections_funcs.py
CHANGED
|
@@ -17,7 +17,7 @@ def start_model(model_id: str = "google/gemma-4-31B-it"):
|
|
| 17 |
print(f'Model {model_id} has been installed.')
|
| 18 |
return model, processor
|
| 19 |
|
| 20 |
-
def make_beams(model: AutoModelForCausalLM, processor: AutoProcessor, initial_prompt: str) -> Tuple[Any, List[str]]:
|
| 21 |
'''
|
| 22 |
Generates 5 beams in response to a prompt.
|
| 23 |
'''
|
|
@@ -41,7 +41,9 @@ def make_beams(model: AutoModelForCausalLM, processor: AutoProcessor, initial_pr
|
|
| 41 |
num_beams=5, # Enables beam search with 5 active beams
|
| 42 |
num_return_sequences=5, # Returns the top result
|
| 43 |
return_dict_in_generate=True,
|
| 44 |
-
output_scores=True
|
|
|
|
|
|
|
| 45 |
|
| 46 |
transcription = processor.batch_decode(generated_dicts.sequences, skip_special_tokens=True)
|
| 47 |
|
|
|
|
| 17 |
print(f'Model {model_id} has been installed.')
|
| 18 |
return model, processor
|
| 19 |
|
| 20 |
+
def make_beams(model: AutoModelForCausalLM, processor: AutoProcessor, initial_prompt: str, temperature: float = 1.0) -> Tuple[Any, List[str]]:
|
| 21 |
'''
|
| 22 |
Generates 5 beams in response to a prompt.
|
| 23 |
'''
|
|
|
|
| 41 |
num_beams=5, # Enables beam search with 5 active beams
|
| 42 |
num_return_sequences=5, # Returns the top result
|
| 43 |
return_dict_in_generate=True,
|
| 44 |
+
output_scores=True,
|
| 45 |
+
temperature=temperature,
|
| 46 |
+
do_sample=True if temperature > 0 else False)
|
| 47 |
|
| 48 |
transcription = processor.batch_decode(generated_dicts.sequences, skip_special_tokens=True)
|
| 49 |
|