-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from Health-Informatics-UoN/bugfix/eot_token
Bugfix/eot token
- Loading branch information
Showing
4 changed files
with
79 additions
and
8 deletions.
There are no files selected for viewing
Empty file.
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,57 @@ | ||
import pytest | ||
from components.prompt import Prompts | ||
|
||
@pytest.fixture | ||
def llama_3_simple_prompt_builder(): | ||
return Prompts( | ||
model_name="llama-3-8b", | ||
prompt_type="simple", | ||
).get_prompt() | ||
|
||
@pytest.fixture | ||
def llama_3_rag_prompt_builder(): | ||
return Prompts( | ||
model_name="llama-3-8b", | ||
prompt_type="top_n_RAG", | ||
).get_prompt() | ||
|
||
@pytest.fixture | ||
def llama_3_1_simple_prompt_builder(): | ||
return Prompts( | ||
model_name="llama-3.1-8b", | ||
prompt_type="simple", | ||
eot_token="<|eot_id|>" | ||
).get_prompt() | ||
|
||
@pytest.fixture | ||
def llama_3_1_rag_prompt_builder(): | ||
return Prompts( | ||
model_name="llama-3.1-8b", | ||
prompt_type="top_n_RAG", | ||
eot_token="<|eot_id|>" | ||
).get_prompt() | ||
|
||
@pytest.fixture | ||
def mock_rag_results(): | ||
return [ | ||
{'content': 'apple'} | ||
] | ||
|
||
def test_simple_prompt_returned(llama_3_simple_prompt_builder): | ||
assert "banana" in llama_3_simple_prompt_builder.run(informal_name="banana")["prompt"] | ||
|
||
def test_rag_prompt_returned(llama_3_rag_prompt_builder, mock_rag_results): | ||
result = llama_3_rag_prompt_builder.run(informal_name="banana", vec_results=mock_rag_results)["prompt"] | ||
assert "banana" in result | ||
assert "apple" in result | ||
|
||
def test_simple_prompt_with_eot(llama_3_1_simple_prompt_builder): | ||
result = llama_3_1_simple_prompt_builder.run(informal_name="banana")["prompt"] | ||
assert "banana" in result | ||
assert "<|eot_id|>" in result | ||
|
||
def test_rag_prompt_with_eot(llama_3_1_rag_prompt_builder, mock_rag_results): | ||
result = llama_3_1_rag_prompt_builder.run(informal_name="banana", vec_results=mock_rag_results)["prompt"] | ||
assert "banana" in result | ||
assert "apple" in result | ||
assert "<|eot_id|>" in result |