-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into new-text2sql-metrics-scores
- Loading branch information
Showing
403 changed files
with
1,298 additions
and
461 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,34 @@ | ||
from unitxt import evaluate, load_dataset, settings | ||
from unitxt.inference import ( | ||
CrossProviderInferenceEngine, | ||
) | ||
|
||
with settings.context( | ||
allow_unverified_code=True, | ||
mock_inference_mode=True, | ||
): | ||
test_dataset = load_dataset( | ||
"benchmarks.torr", | ||
split="test", | ||
use_cache=True, | ||
) | ||
# Infer | ||
model = CrossProviderInferenceEngine( | ||
model="llama-3-8b-instruct", | ||
max_tokens=30, | ||
) | ||
""" | ||
We are using a CrossProviderInferenceEngine inference engine that supply api access to provider such as: | ||
watsonx, bam, openai, azure, aws and more. | ||
For the arguments these inference engines can receive, please refer to the classes documentation or read | ||
about the the open ai api arguments the CrossProviderInferenceEngine follows. | ||
""" | ||
|
||
predictions = model(test_dataset) | ||
results = evaluate(predictions=predictions, data=test_dataset) | ||
|
||
print("Global scores:") | ||
print(results.global_scores.summary) | ||
print("Subsets scores:") | ||
print(results.subsets_scores.summary) |
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,41 @@ | ||
from unitxt import add_to_catalog | ||
from unitxt.blocks import ( | ||
LoadHF, | ||
TaskCard, | ||
) | ||
from unitxt.operators import Copy, ExecuteExpression | ||
from unitxt.templates import NullTemplate | ||
|
||
for subset in [ | ||
"covidqa", | ||
"cuad", | ||
"delucionqa", | ||
"emanual", | ||
"expertqa", | ||
"finqa", | ||
"hagrid", | ||
"hotpotqa", | ||
"msmarco", | ||
"pubmedqa", | ||
"tatqa", | ||
"techqa", | ||
]: | ||
card = TaskCard( | ||
loader=LoadHF( | ||
path="rungalileo/ragbench", | ||
name=subset, | ||
split="test" | ||
), | ||
preprocess_steps=[ | ||
Copy(field="response", to_field="answer"), | ||
Copy(field="documents", to_field="contexts"), | ||
ExecuteExpression(expression="int(adherence_score)", to_field="number_val"), | ||
ExecuteExpression(expression="['yes' if adherence_score else 'no']", to_field="is_faithful"), | ||
], | ||
task="tasks.rag_eval.faithfulness.binary", | ||
templates={"default": NullTemplate()}, | ||
) | ||
|
||
add_to_catalog( | ||
card, f"cards.rag_eval.faithfulness.ragbench.{subset}", 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
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.