-
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.
Signed-off-by: elronbandel <[email protected]>
- Loading branch information
1 parent
2d46594
commit de868ab
Showing
6 changed files
with
155 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import unitxt | ||
from unitxt import evaluate, get_from_catalog, load_dataset | ||
from unitxt.text_utils import print_dict | ||
|
||
with unitxt.settings.context( | ||
default_inference_api="watsonx", # option a to define your home api | ||
default_format="formats.chat_api", | ||
disable_hf_datasets_cache=False, | ||
): | ||
data = load_dataset("benchmarks.glue[max_samples_per_subset=5]", split="test") | ||
|
||
model = get_from_catalog( | ||
"engines.model.llama_3_8b_instruct[api=watsonx]" | ||
) # option b to define your home api | ||
|
||
predictions = model.infer(data) | ||
|
||
evaluated_dataset = evaluate(predictions=predictions, data=data) | ||
|
||
print_dict( | ||
evaluated_dataset[0], | ||
keys_to_print=[ | ||
"source", | ||
"prediction", | ||
"subset", | ||
], | ||
) | ||
print_dict( | ||
evaluated_dataset[0]["score"]["subsets"], | ||
) |
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,16 @@ | ||
from unitxt.catalog import add_to_catalog | ||
from unitxt.inference import MultiAPIInferenceEngine | ||
|
||
engine = MultiAPIInferenceEngine( | ||
model="llama-3-8b-instruct", | ||
api_model_map={ | ||
"watsonx": { | ||
"llama-3-8b-instruct": "watsonx/meta-llama/llama-3-8b-instruct", | ||
}, | ||
"together-ai": { | ||
"llama-3-8b-instruct": "together_ai/togethercomputer/llama-3-8b-instruct" | ||
}, | ||
}, | ||
) | ||
|
||
add_to_catalog(engine, "engines.model.llama_3_8b_instruct", overwrite=True) |
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,12 @@ | ||
{ | ||
"__type__": "multi_api_inference_engine", | ||
"model": "llama-3-8b-instruct", | ||
"api_model_map": { | ||
"watsonx": { | ||
"llama-3-8b-instruct": "watsonx/meta-llama/llama-3-8b-instruct" | ||
}, | ||
"together-ai": { | ||
"llama-3-8b-instruct": "together_ai/togethercomputer/llama-3-8b-instruct" | ||
} | ||
} | ||
} |
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