Update handler.py
Browse files- handler.py +1 -3
handler.py
CHANGED
|
@@ -42,7 +42,6 @@ class EndpointHandler:
|
|
| 42 |
|
| 43 |
# compute decoder_input_ids for french
|
| 44 |
forced_ids = self.processor.get_decoder_prompt_ids(language="french", task="transcribe")
|
| 45 |
-
# convert to tensor [ [id1,id2,...] ]
|
| 46 |
self.french_decoder_input_ids = torch.tensor(
|
| 47 |
[[tok_id for _, tok_id in forced_ids]],
|
| 48 |
device="cuda" if torch.cuda.is_available() else "cpu"
|
|
@@ -98,8 +97,7 @@ class EndpointHandler:
|
|
| 98 |
with torch.no_grad(), torch.inference_mode(), torch.autocast(device_type="cuda", dtype=torch.float16):
|
| 99 |
predicted_ids = self.model.generate(
|
| 100 |
**model_inputs,
|
| 101 |
-
decoder_input_ids=self.french_decoder_input_ids, # ✅
|
| 102 |
-
forced_decoder_ids=None, # ✅ évite le conflit
|
| 103 |
max_length=max_length,
|
| 104 |
num_beams=num_beams,
|
| 105 |
temperature=temperature,
|
|
|
|
| 42 |
|
| 43 |
# compute decoder_input_ids for french
|
| 44 |
forced_ids = self.processor.get_decoder_prompt_ids(language="french", task="transcribe")
|
|
|
|
| 45 |
self.french_decoder_input_ids = torch.tensor(
|
| 46 |
[[tok_id for _, tok_id in forced_ids]],
|
| 47 |
device="cuda" if torch.cuda.is_available() else "cpu"
|
|
|
|
| 97 |
with torch.no_grad(), torch.inference_mode(), torch.autocast(device_type="cuda", dtype=torch.float16):
|
| 98 |
predicted_ids = self.model.generate(
|
| 99 |
**model_inputs,
|
| 100 |
+
decoder_input_ids=self.french_decoder_input_ids, # ✅ seul forçage
|
|
|
|
| 101 |
max_length=max_length,
|
| 102 |
num_beams=num_beams,
|
| 103 |
temperature=temperature,
|