Skip to content

Commit

Permalink
Merge pull request #623 from JohnSnowLabs/fix/hf-datasets-summarization
Browse files Browse the repository at this point in the history
Fix/hf datasets summarization default prompt
  • Loading branch information
JulesBelveze authored Jul 15, 2023
2 parents c3457c0 + 2bd9953 commit 6990ba1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
15 changes: 9 additions & 6 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,22 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Cache poetry install
uses: actions/cache@v2
with:
path: ~/.local
key: poetry-1.3.1

- uses: snok/install-poetry@v1
with:
version: 1.3.1
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true

- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}

- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: |
poetry install --with dev --all-extras
Expand Down
2 changes: 1 addition & 1 deletion langtest/utils/custom_types/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"quac": "You are an intelligent bot specialized in question answering. Your goal is to provide accurate and concise answers to all the questions without stopping in between. Read the following context and answer each question based on the given information.\n\nContext: {context}\n\nQuestions:\n{question}",
"narrativeqa": "Context: {context} \nQuestion: {question}\n I've provided a question and context. Answer the given closed-book question based on the provided context. Only answer with words in the context. Answer:",
"hellaswag": "You are an AI agent that completes sentences and cannot do anything else. You do not repeat the sentence and only continue for one sentence. Complete the following sentence: \n{context}{question}",
"sum_prompt": "You are an intelligent Context summarizer. Please read the following context carefully. After understanding its content, create a concise summary, capturing the essential themes and key details. Please ensure that the summary does not end abruptly and remains within the max_tokens word limit. Context: {context}\n\n Summary: ",
"default_summarization_prompt": "You are an intelligent Context summarizer. Please read the following context carefully. After understanding its content, create a concise summary, capturing the essential themes and key details. Please ensure that the summary does not end abruptly and remains within the max_tokens word limit. Context: {context}\n\n Summary: ",
"bbq": "Read the following context carefully and provide a concise answer based solely on the information given. Strictly, do not introduce any new information or make any assumptions. \n\nContext: {context}\nQuestion: {question}\n",
}

Expand Down
7 changes: 6 additions & 1 deletion langtest/utils/custom_types/sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,12 @@ def run(self, model, **kwargs):
Returns:
bool: True if the sample ran successfully, False otherwise.
"""
dataset_name = self.dataset_name.split("-")[0].lower()
dataset_name = (
self.dataset_name.split("-")[0].lower()
if self.dataset_name
else "default_summarization_prompt"
)

prompt_template = kwargs.get(
"user_prompt", default_user_prompt.get(dataset_name, "")
)
Expand Down

0 comments on commit 6990ba1

Please sign in to comment.