mirror of
https://github.com/mudler/LocalAI.git
synced 2024-06-07 19:40:48 +00:00
fix(vllm): set default top_p with vllm (#1078)
**Description** This PR fixes vllm when called with a request with an empty top_p Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
parent
3a69bd3ef5
commit
453e9c5da9
@ -49,11 +49,13 @@ class BackendServicer(backend_pb2_grpc.BackendServicer):
|
|||||||
return backend_pb2.Result(message="Model loaded successfully", success=True)
|
return backend_pb2.Result(message="Model loaded successfully", success=True)
|
||||||
|
|
||||||
def Predict(self, request, context):
|
def Predict(self, request, context):
|
||||||
|
if request.TopP == 0:
|
||||||
|
request.TopP = 0.9
|
||||||
|
|
||||||
sampling_params = SamplingParams(temperature=request.Temperature, top_p=request.TopP)
|
sampling_params = SamplingParams(temperature=request.Temperature, top_p=request.TopP)
|
||||||
outputs = self.llm.generate([request.Prompt], sampling_params)
|
outputs = self.llm.generate([request.Prompt], sampling_params)
|
||||||
|
|
||||||
generated_text = outputs[0].outputs[0].text
|
generated_text = outputs[0].outputs[0].text
|
||||||
|
|
||||||
# Remove prompt from response if present
|
# Remove prompt from response if present
|
||||||
if request.Prompt in generated_text:
|
if request.Prompt in generated_text:
|
||||||
generated_text = generated_text.replace(request.Prompt, "")
|
generated_text = generated_text.replace(request.Prompt, "")
|
||||||
|
Loading…
Reference in New Issue
Block a user