forked from vllm-project/vllm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Frontend] Separate pooling APIs in offline inference (vllm-project#1…
…1129) Signed-off-by: DarkLight1337 <[email protected]>
- Loading branch information
1 parent
f93bf2b
commit eeec9e3
Showing
21 changed files
with
659 additions
and
294 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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from vllm import LLM | ||
|
||
# Sample prompts. | ||
prompts = [ | ||
"Hello, my name is", | ||
"The president of the United States is", | ||
"The capital of France is", | ||
"The future of AI is", | ||
] | ||
|
||
# Create an LLM. | ||
# You should pass task="classify" for classification models | ||
model = LLM( | ||
model="jason9693/Qwen2.5-1.5B-apeach", | ||
task="classify", | ||
enforce_eager=True, | ||
) | ||
|
||
# Generate logits. The output is a list of ClassificationRequestOutputs. | ||
outputs = model.classify(prompts) | ||
|
||
# Print the outputs. | ||
for prompt, output in zip(prompts, outputs): | ||
probs = output.outputs.probs | ||
probs_trimmed = ((str(probs[:16])[:-1] + | ||
", ...]") if len(probs) > 16 else probs) | ||
print(f"Prompt: {prompt!r} | " | ||
f"Class Probabilities: {probs_trimmed} (size={len(probs)})") |
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from vllm import LLM | ||
|
||
# Sample prompts. | ||
text_1 = "What is the capital of France?" | ||
texts_2 = [ | ||
"The capital of Brazil is Brasilia.", "The capital of France is Paris." | ||
] | ||
|
||
# Create an LLM. | ||
# You should pass task="score" for cross-encoder models | ||
model = LLM( | ||
model="BAAI/bge-reranker-v2-m3", | ||
task="score", | ||
enforce_eager=True, | ||
) | ||
|
||
# Generate scores. The output is a list of ScoringRequestOutputs. | ||
outputs = model.score(text_1, texts_2) | ||
|
||
# Print the outputs. | ||
for text_2, output in zip(texts_2, outputs): | ||
score = output.outputs.score | ||
print(f"Pair: {[text_1, text_2]!r} | Score: {score}") |
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
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
Oops, something went wrong.