Spaces:
Paused
Paused
Upload 2 files
Browse files- app.py +2 -2
- inflections_funcs.py +2 -2
app.py
CHANGED
|
@@ -69,7 +69,7 @@ def generate_beam_html(index, all_beams_data, dark_mode):
|
|
| 69 |
@spaces.GPU
|
| 70 |
def predict(prompt, dark_mode, temperature):
|
| 71 |
"""
|
| 72 |
-
Generates responses for
|
| 73 |
"""
|
| 74 |
# Generate beams
|
| 75 |
generated_dicts, transcription = make_beams(model, processor, prompt, temperature=temperature)
|
|
@@ -112,7 +112,7 @@ def switch_beam(current_index, all_beams_data, dark_mode):
|
|
| 112 |
if all_beams_data is None:
|
| 113 |
return None, None, 0
|
| 114 |
|
| 115 |
-
new_index = (current_index + 1) %
|
| 116 |
main_html, detail_html = generate_beam_html(new_index, all_beams_data, dark_mode)
|
| 117 |
return main_html, detail_html, new_index
|
| 118 |
|
|
|
|
| 69 |
@spaces.GPU
|
| 70 |
def predict(prompt, dark_mode, temperature):
|
| 71 |
"""
|
| 72 |
+
Generates responses for 3 beams and returns the first beam's visualization and visibility for controls.
|
| 73 |
"""
|
| 74 |
# Generate beams
|
| 75 |
generated_dicts, transcription = make_beams(model, processor, prompt, temperature=temperature)
|
|
|
|
| 112 |
if all_beams_data is None:
|
| 113 |
return None, None, 0
|
| 114 |
|
| 115 |
+
new_index = (current_index + 1) % 3
|
| 116 |
main_html, detail_html = generate_beam_html(new_index, all_beams_data, dark_mode)
|
| 117 |
return main_html, detail_html, new_index
|
| 118 |
|
inflections_funcs.py
CHANGED
|
@@ -19,7 +19,7 @@ def start_model(model_id: str = "google/gemma-4-31B-it"):
|
|
| 19 |
|
| 20 |
def make_beams(model: AutoModelForCausalLM, processor: AutoProcessor, initial_prompt: str, temperature: float = 1.0) -> Tuple[Any, List[str]]:
|
| 21 |
'''
|
| 22 |
-
Generates
|
| 23 |
'''
|
| 24 |
messages = [
|
| 25 |
{"role": "system", "content": "You are a helpful assistant."},
|
|
@@ -39,7 +39,7 @@ def make_beams(model: AutoModelForCausalLM, processor: AutoProcessor, initial_pr
|
|
| 39 |
generated_dicts = model.generate(**inputs,
|
| 40 |
max_new_tokens=1024,
|
| 41 |
num_beams=1, # Disable beam search for pure sampling
|
| 42 |
-
num_return_sequences=
|
| 43 |
return_dict_in_generate=True,
|
| 44 |
output_scores=True,
|
| 45 |
temperature=temperature if temperature > 0 else 0.1, # Ensure T > 0 for sampling
|
|
|
|
| 19 |
|
| 20 |
def make_beams(model: AutoModelForCausalLM, processor: AutoProcessor, initial_prompt: str, temperature: float = 1.0) -> Tuple[Any, List[str]]:
|
| 21 |
'''
|
| 22 |
+
Generates 3 diverse responses in response to a prompt.
|
| 23 |
'''
|
| 24 |
messages = [
|
| 25 |
{"role": "system", "content": "You are a helpful assistant."},
|
|
|
|
| 39 |
generated_dicts = model.generate(**inputs,
|
| 40 |
max_new_tokens=1024,
|
| 41 |
num_beams=1, # Disable beam search for pure sampling
|
| 42 |
+
num_return_sequences=3, # Generate 3 independent diverse samples
|
| 43 |
return_dict_in_generate=True,
|
| 44 |
output_scores=True,
|
| 45 |
temperature=temperature if temperature > 0 else 0.1, # Ensure T > 0 for sampling
|