-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature method run multi prompts #33
Merged
Merged
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d20c6d9
feat: created eval_on_prompts_file() to run and compare multiple prom…
anujsinha3 905ae5f
feat: created eval_on_prompts_file() to run and compare multiple prom…
anujsinha3 588b85f
refactor: update function name
anujsinha3 ec4dbbf
test: add test for multi-prompts prediction
anujsinha3 3a48d6c
test: add tests for utility function
anujsinha3 9d5dc0f
refactor: change the return type for eval_prompts()
anujsinha3 667e77e
refactor: use @dataclass annotation
anujsinha3 1f8c14a
refactor: default bleu_score and meteor_Score as None
anujsinha3 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,32 @@ | ||
from pathlib import Path | ||
|
||
from autora.doc.util import get_eval_result_from_prediction, get_prompts_from_file, load_file | ||
|
||
|
||
def test_load_file() -> None: | ||
prompts_file_path = Path(__file__).parent.joinpath("../data/autora/prompts/all_prompt.json").resolve() | ||
data = load_file(str(prompts_file_path)) | ||
assert type(data) == list | ||
|
||
|
||
def test_get_prompts_from_file() -> None: | ||
prompts_file_path = Path(__file__).parent.joinpath("../data/autora/prompts/all_prompt.json").resolve() | ||
prompts_list = get_prompts_from_file(str(prompts_file_path)) | ||
|
||
assert len(prompts_list) == 3, "Expected 3 outputs" | ||
for prompt in prompts_list: | ||
assert type(prompt) == str | ||
|
||
|
||
def test_get_eval_result_from_prediction() -> None: | ||
prediction = (["response1", "response2"], 0.8, 0.7) | ||
prompt = "prompt1" | ||
result = get_eval_result_from_prediction(prediction, prompt) | ||
expected_result = { | ||
"prediction": ["response1", "response2"], | ||
"bleu": 0.8, | ||
"meteor": 0.7, | ||
"prompt": "prompt1", | ||
} | ||
assert type(result) == dict # Assert result is a dictionary | ||
assert result == expected_result # Assert specific keys and values |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was about to ask you to add a doc-comment for this function. In particular because it's hard to tell what the
List[Dict[str,str]]
will contain. But I think a better option is to create a type (a dataclass?) for the return type, e.g. anEvalResult
class.