We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 11741e5 commit 020d289Copy full SHA for 020d289
nemo/deploy/service/fastapi_interface_to_pytriton.py
@@ -14,7 +14,7 @@
14
import numpy as np
15
import requests
16
from fastapi import FastAPI, HTTPException
17
-from pydantic import BaseModel
+from pydantic import BaseModel, model_validator
18
from pydantic_settings import BaseSettings
19
20
from nemo.deploy.nlp import NemoQueryLLMPyTorch
@@ -81,6 +81,14 @@ class CompletionRequest(BaseModel):
81
top_k: int = 0
82
logprobs: int = None
83
84
+ @model_validator(mode='after')
85
+ def set_greedy_params(self):
86
+ """Validate parameters for greedy decoding."""
87
+ if self.temperature == 0 and self.top_p == 0:
88
+ logging.warning("Both temperature and top_p are 0. Setting top_k to 1 to ensure greedy sampling.")
89
+ self.top_k = 1
90
+ return self
91
+
92
93
@app.get("/v1/health")
94
def health_check():
0 commit comments