Spaces:
Paused
Paused
Commit
·
27b3d70
1
Parent(s):
38b2330
max new tokens
Browse files
ai_med_extract/api/routes.py
CHANGED
|
@@ -388,7 +388,7 @@ def register_routes(app, agents):
|
|
| 388 |
import torch
|
| 389 |
torch.set_num_threads(2)
|
| 390 |
inputs = pipeline.tokenizer([prompt], return_tensors="pt")
|
| 391 |
-
outputs = pipeline.model.generate(**inputs, max_new_tokens=
|
| 392 |
text = pipeline.tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 393 |
|
| 394 |
# Robust summary extraction with fallback
|
|
@@ -1250,7 +1250,7 @@ def register_routes(app, agents):
|
|
| 1250 |
if not pipeline:
|
| 1251 |
return jsonify({"error": "Model pipeline not available"}), 500
|
| 1252 |
inputs = pipeline.tokenizer([prompt], return_tensors="pt")
|
| 1253 |
-
outputs = pipeline.model.generate(**inputs, max_new_tokens=
|
| 1254 |
text = pipeline.tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 1255 |
new_summary = text.split("Now generate the complete, updated clinical summary with all four sections in a markdown format:")[-1].strip()
|
| 1256 |
# For other models, after extracting new_summary:
|
|
|
|
| 388 |
import torch
|
| 389 |
torch.set_num_threads(2)
|
| 390 |
inputs = pipeline.tokenizer([prompt], return_tensors="pt")
|
| 391 |
+
outputs = pipeline.model.generate(**inputs, max_new_tokens=4000, do_sample=False, pad_token_id=pipeline.tokenizer.eos_token_id or 32000)
|
| 392 |
text = pipeline.tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 393 |
|
| 394 |
# Robust summary extraction with fallback
|
|
|
|
| 1250 |
if not pipeline:
|
| 1251 |
return jsonify({"error": "Model pipeline not available"}), 500
|
| 1252 |
inputs = pipeline.tokenizer([prompt], return_tensors="pt")
|
| 1253 |
+
outputs = pipeline.model.generate(**inputs, max_new_tokens=4000, do_sample=False, pad_token_id=pipeline.tokenizer.eos_token_id or 32000)
|
| 1254 |
text = pipeline.tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 1255 |
new_summary = text.split("Now generate the complete, updated clinical summary with all four sections in a markdown format:")[-1].strip()
|
| 1256 |
# For other models, after extracting new_summary:
|