Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/unitxt/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -1461,7 +1461,18 @@ def _infer(
options=args,
)
results.append(response)

if return_meta_data:
return [
TextGenerationInferenceOutput(
prediction=element["message"]["content"],
generated_text=element["message"]["content"],
input_tokens=element.get("prompt_eval_count", 0),
output_tokens=element.get("eval_count", 0),
model_name=self.model,
inference_type=self.label,
)
for element in results
]
return [element["message"]["content"] for element in results]


Expand Down
8 changes: 4 additions & 4 deletions tests/inference/test_inference_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def test_llava_inference_engine(self):

def test_watsonx_inference(self):
model = WMLInferenceEngineGeneration(
model_name="google/flan-t5-xl",
model_name="ibm/granite-3-8b-instruct",
data_classification_policy=["public"],
random_seed=111,
min_new_tokens=1,
Expand Down Expand Up @@ -193,7 +193,7 @@ def test_watsonx_inference_with_external_client(self):
from ibm_watsonx_ai.client import APIClient, Credentials

model = WMLInferenceEngineGeneration(
model_name="google/flan-t5-xl",
model_name="ibm/granite-3-8b-instruct",
data_classification_policy=["public"],
random_seed=111,
min_new_tokens=1,
Expand Down Expand Up @@ -279,7 +279,7 @@ def test_option_selecting_by_log_prob_inference_engines(self):
]

watsonx_engine = WMLInferenceEngineGeneration(
model_name="meta-llama/llama-3-2-1b-instruct"
model_name="ibm/granite-3-8b-instruct"
)

for engine in [watsonx_engine]:
Expand Down Expand Up @@ -383,7 +383,7 @@ def test_lite_llm_inference_engine(self):

def test_lite_llm_inference_engine_without_task_data_not_failing(self):
LiteLLMInferenceEngine(
model="watsonx/meta-llama/llama-3-2-1b-instruct",
model="watsonx/meta-llama/llama-3-2-11b-vision-instruct",
max_tokens=2,
temperature=0,
top_p=1,
Expand Down
2 changes: 1 addition & 1 deletion tests/library/test_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -2708,7 +2708,7 @@ def test_perplexity(self):
metric=perplexity_question, predictions=prediction, references=references
)
self.assertAlmostEqual(
first_instance_target, outputs[0]["score"]["instance"]["score"]
first_instance_target, outputs[0]["score"]["instance"]["score"], places=5
)

def test_fuzzyner(self):
Expand Down