Skip to content

Commit

Permalink
Invert order of anchor/context in prompt template
Browse files Browse the repository at this point in the history
  • Loading branch information
plaguss committed Jun 7, 2024
1 parent f2140cd commit 3b7c221
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
## Anchor

{{ anchor }}
{% if context is not none -%}
## Context

{{ context }}
{%- endif %}

{% endif -%}

## Anchor

{{ anchor }}

6 changes: 4 additions & 2 deletions tests/unit/steps/tasks/test_sentence_transformers.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,10 @@ def test_format_input(
) -> None:
task = GenerateSentencePair(llm=DummyLLM(), action=action, triplet=triplet)
task.load()
content = "## Anchor\n\nThis is a unit test\n"
assert task.format_input({"anchor": "This is a unit test"}) == [
{"role": "system", "content": system_prompt},
{"role": "user", "content": "## Anchor\n\nThis is a unit test\n"},
{"role": "user", "content": content},
]

@pytest.mark.parametrize(
Expand Down Expand Up @@ -168,7 +169,8 @@ def test_format_input_with_context(
context=context,
)
task.load()
content = f"## Anchor\n\nThis is a unit test\n## Context\n\n{context}"
content = f"## Context\n\n{context}\n\n## Anchor\n\nThis is a unit test\n"
# content = f"## Anchor\n\nThis is a unit test\n## Context\n\n{context}"
assert task.format_input({"anchor": "This is a unit test"}) == [
{"role": "system", "content": system_prompt},
{"role": "user", "content": content},
Expand Down

0 comments on commit 3b7c221

Please sign in to comment.