ford442 commited on
Commit
6dcf7b3
·
verified ·
1 Parent(s): 57b8b81

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -24
app.py CHANGED
@@ -69,30 +69,30 @@ def process_audio(microphone, audio_upload, state, answer_mode): # Added audio_
69
  You answer questions clearly and simply, using age-appropriate language.
70
  You are also a little bit silly and like to make jokes."""
71
  prompt = f"{system_prompt}\nUser: {text}"
72
- #with torch.no_grad():
73
- vicuna_input = vicuna_tokenizer(prompt, return_tensors="pt").to('cuda')
74
- if answer_mode == 'slow':
75
- vicuna_output = vicuna_model.generate(
76
- **vicuna_input,
77
- max_length = 512,
78
- min_new_tokens = 256,
79
- do_sample = True
80
- )
81
- if answer_mode == 'medium':
82
- vicuna_output = vicuna_model.generate(
83
- **vicuna_input,
84
- max_length = 128,
85
- min_new_tokens = 64,
86
- do_sample = True
87
- )
88
- if answer_mode == 'fast':
89
- vicuna_output = vicuna_model.generate(
90
- **vicuna_input,
91
- max_length = 42,
92
- min_new_tokens = 16,
93
- do_sample = True
94
- )
95
- vicuna_response = vicuna_tokenizer.decode(vicuna_output[0], skip_special_tokens=True)
96
  vicuna_response = vicuna_response.replace(prompt, "").strip()
97
  updated_state = state + "\nUser: " + text + "\n" + "Tutor: " + vicuna_response
98
  try:
 
69
  You answer questions clearly and simply, using age-appropriate language.
70
  You are also a little bit silly and like to make jokes."""
71
  prompt = f"{system_prompt}\nUser: {text}"
72
+ with torch.no_grad():
73
+ vicuna_input = vicuna_tokenizer(prompt, return_tensors="pt").to('cuda')
74
+ if answer_mode == 'slow':
75
+ vicuna_output = vicuna_model.generate(
76
+ **vicuna_input,
77
+ max_length = 512,
78
+ min_new_tokens = 256,
79
+ do_sample = True
80
+ )
81
+ if answer_mode == 'medium':
82
+ vicuna_output = vicuna_model.generate(
83
+ **vicuna_input,
84
+ max_length = 128,
85
+ min_new_tokens = 64,
86
+ do_sample = True
87
+ )
88
+ if answer_mode == 'fast':
89
+ vicuna_output = vicuna_model.generate(
90
+ **vicuna_input,
91
+ max_length = 42,
92
+ min_new_tokens = 16,
93
+ do_sample = True
94
+ )
95
+ vicuna_response = vicuna_tokenizer.decode(vicuna_output[0], skip_special_tokens=True)
96
  vicuna_response = vicuna_response.replace(prompt, "").strip()
97
  updated_state = state + "\nUser: " + text + "\n" + "Tutor: " + vicuna_response
98
  try: