File tree Expand file tree Collapse file tree 5 files changed +16
-6
lines changed
examples/offline_inference/basic Expand file tree Collapse file tree 5 files changed +16
-6
lines changed Original file line number Diff line number Diff line change 18
18
# that contain the prompt, generated text, and other information.
19
19
outputs = llm .generate (prompts , sampling_params )
20
20
# Print the outputs.
21
+ print ("\n Generated Outputs:\n " + "-" * 60 )
21
22
for output in outputs :
22
23
prompt = output .prompt
23
24
generated_text = output .outputs [0 ].text
24
- print (f"Prompt: { prompt !r} , Generated text: { generated_text !r} " )
25
+ print (f"Prompt: { prompt !r} " )
26
+ print (f"Output: { generated_text !r} " )
27
+ print ("-" * 60 )
Original file line number Diff line number Diff line change @@ -27,12 +27,13 @@ def main(args: dict):
27
27
sampling_params .top_k = top_k
28
28
29
29
def print_outputs (outputs ):
30
+ print ("\n Generated Outputs:\n " + "-" * 80 )
30
31
for output in outputs :
31
32
prompt = output .prompt
32
33
generated_text = output .outputs [0 ].text
33
- print (f"Prompt: { prompt !r} " )
34
+ print (f"Prompt: { prompt !r} \n " )
34
35
print (f"Generated text: { generated_text !r} " )
35
- print ("-" * 80 )
36
+ print ("-" * 80 )
36
37
37
38
print ("=" * 80 )
38
39
Original file line number Diff line number Diff line change @@ -23,12 +23,14 @@ def main(args: Namespace):
23
23
outputs = model .classify (prompts )
24
24
25
25
# Print the outputs.
26
+ print ("\n Generated Outputs:\n " + "-" * 60 )
26
27
for prompt , output in zip (prompts , outputs ):
27
28
probs = output .outputs .probs
28
29
probs_trimmed = ((str (probs [:16 ])[:- 1 ] +
29
30
", ...]" ) if len (probs ) > 16 else probs )
30
- print (f"Prompt: { prompt !r} | "
31
+ print (f"Prompt: { prompt !r} \n "
31
32
f"Class Probabilities: { probs_trimmed } (size={ len (probs )} )" )
33
+ print ("-" * 60 )
32
34
33
35
34
36
if __name__ == "__main__" :
Original file line number Diff line number Diff line change @@ -23,12 +23,14 @@ def main(args: Namespace):
23
23
outputs = model .embed (prompts )
24
24
25
25
# Print the outputs.
26
+ print ("\n Generated Outputs:\n " + "-" * 60 )
26
27
for prompt , output in zip (prompts , outputs ):
27
28
embeds = output .outputs .embedding
28
29
embeds_trimmed = ((str (embeds [:16 ])[:- 1 ] +
29
30
", ...]" ) if len (embeds ) > 16 else embeds )
30
- print (f"Prompt: { prompt !r} | "
31
+ print (f"Prompt: { prompt !r} \n "
31
32
f"Embeddings: { embeds_trimmed } (size={ len (embeds )} )" )
33
+ print ("-" * 60 )
32
34
33
35
34
36
if __name__ == "__main__" :
Original file line number Diff line number Diff line change @@ -22,9 +22,11 @@ def main(args: Namespace):
22
22
outputs = model .score (text_1 , texts_2 )
23
23
24
24
# Print the outputs.
25
+ print ("\n Generated Outputs:\n " + "-" * 60 )
25
26
for text_2 , output in zip (texts_2 , outputs ):
26
27
score = output .outputs .score
27
- print (f"Pair: { [text_1 , text_2 ]!r} | Score: { score } " )
28
+ print (f"Pair: { [text_1 , text_2 ]!r} \n Score: { score } " )
29
+ print ("-" * 60 )
28
30
29
31
30
32
if __name__ == "__main__" :
You can’t perform that action at this time.
0 commit comments