-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bcd8b01
commit 7b89e05
Showing
4 changed files
with
58 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,24 @@ | ||
import os | ||
from pydantic import BaseModel | ||
from vllm import LLM, SamplingParams | ||
|
||
from custom.models import fn | ||
|
||
|
||
#os.environ['CUDA_VISIBLE_DEVICES']="0,1,2,3,4,5" | ||
|
||
class GenerateRequest(BaseModel): | ||
prompt: str | ||
|
||
|
||
# class LLMActor: | ||
# def __init__(self): | ||
# # Initialize the LLM inside the actor to avoid serialization | ||
# self.llm = LLM( | ||
# model="/models/Qwen2.5-0.5B-Instruct", | ||
# tensor_parallel_size=1, | ||
# gpu_memory_utilization=0.5 | ||
# ) | ||
|
||
# def generate(self, prompt: str) -> str: | ||
# sampling_params = SamplingParams( | ||
# temperature=0.7, | ||
# top_p=0.95, | ||
# max_tokens=1000 | ||
# ) | ||
# result = self.llm.generate([prompt], sampling_params=sampling_params) | ||
# return result[0].outputs[0].text | ||
|
||
#llm = LLM(model="/models/Qwen2.5-0.5B-Instruct", tensor_parallel_size=1, gpu_memory_utilization=0.5) | ||
|
||
#actor = LLMActor() | ||
|
||
#prompt="introduce Bruce Lee" | ||
def model_A(prompt): | ||
#prompt="introduce Bruce Lee" | ||
llm = LLM(model="/models/Qwen2.5-0.5B-Instruct", tensor_parallel_size=1, gpu_memory_utilization=0.5) | ||
llm = LLM( | ||
model="/models/Qwen2.5-0.5B-Instruct", | ||
tensor_parallel_size=1, | ||
gpu_memory_utilization=0.5, | ||
) | ||
sampling_params = SamplingParams(temperature=0.7, top_p=0.95, max_tokens=1000) | ||
|
||
result = llm.generate([prompt], sampling_params=sampling_params) | ||
return result[0].outputs[0].text | ||
return fn(result[0].outputs[0].text) | ||
|
||
|
||
def model_B(input_data): | ||
res = input_data + "__add_model_B" | ||
return res | ||
|
||
|
||
if __name__ == "__main__": | ||
print(model_A()) | ||
prompt="introduce Bruce Lee" | ||
print(model_A(prompt)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,4 +30,4 @@ deploy: | |
name: generate | ||
port: 8000 | ||
request: | ||
key: prompt | ||
prompt: str |