Skip to content

Commit

Permalink
add testing scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
lwaekfjlk committed Oct 11, 2023
1 parent b3eb7b9 commit 13e2973
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions llm_deploy/vllm_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
from vllm import LLM
from vllm import LLM, SamplingParams
from vllm.model_executor.adapters import lora

prompts = ["Hello, my name is", "The capital of France is"] # Sample prompts.
llm = LLM(model="../llm_ft/vicuna-7b-1.5") # Create an LLM.
outputs = llm.generate(prompts) # Generate texts from the prompts.
print(outputs)
# Create an LLM.
llm = LLM(model="../llm_ft/vicuna-7b-1.5", gpu_memory_utilization=0.05)

# Add LoRA adapter
lora.LoRAModel.from_pretrained(llm.llm_engine.workers[0].model, "../llm_ft/checkpoints/checkpoint-1200")

prompts = [
"Hello, my name is",
"The capital of France is",
"The future of AI is",
]

sampling_params = SamplingParams(temperature=0, top_k=-1)

outputs = llm.generate(prompts, sampling_params)

for output in outputs:
prompt = output.prompt
generated_text = output.outputs[0].text
print(f"Prompt: {prompt!r}, Generated text: {generated_text!r}")

0 comments on commit 13e2973

Please sign in to comment.