From 07aa1bbc56a0f0ecd0175aefaed98aed7d21ace3 Mon Sep 17 00:00:00 2001 From: Richard Edgar Date: Fri, 3 May 2024 10:45:52 -0400 Subject: [PATCH] [Models] Add Phi3 to tests (#776) Phi3 is now out, so start adding it into our testing frameworks --- .github/workflows/action_gpu_unit_tests.yml | 3 +++ .github/workflows/action_plain_unit_tests.yml | 2 ++ tests/conftest.py | 4 ++++ tests/models/test_transformers.py | 6 ++---- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/action_gpu_unit_tests.yml b/.github/workflows/action_gpu_unit_tests.yml index 4273db977..b4bcd7da3 100644 --- a/.github/workflows/action_gpu_unit_tests.yml +++ b/.github/workflows/action_gpu_unit_tests.yml @@ -50,6 +50,9 @@ jobs: pip install pytest pip install -e .[schemas,test] if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Other dependencies + run: | + pip install sentencepiece - name: GPU pip installs run: | pip install accelerate diff --git a/.github/workflows/action_plain_unit_tests.yml b/.github/workflows/action_plain_unit_tests.yml index 58e3c6450..a675a88fe 100644 --- a/.github/workflows/action_plain_unit_tests.yml +++ b/.github/workflows/action_plain_unit_tests.yml @@ -22,6 +22,7 @@ jobs: # - "transformers_mistral_7b" See Issue 713 - "hfllama7b" - "hfllama_mistral_7b" + - "phi3cpu-mini-4k-instruct" runs-on: ${{ inputs.os }} steps: @@ -44,6 +45,7 @@ jobs: if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - name: Install model-specific dependencies run: | + pip install sentencepiece pip install "llama-cpp-python!=0.2.58" - name: Run tests (except server) shell: bash diff --git a/tests/conftest.py b/tests/conftest.py index 30a5c60ef..40903a204 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -12,6 +12,10 @@ "phi2cpu": dict( name="transformers:microsoft/phi-2", kwargs={"trust_remote_code": True} ), + "phi3cpu-mini-4k-instruct": dict( + name="transformers:microsoft/Phi-3-mini-4k-instruct", + kwargs={"trust_remote_code": True}, + ), "hfllama7b": dict( name="huggingface_hubllama:TheBloke/Llama-2-7B-GGUF:llama-2-7b.Q5_K_M.gguf", kwargs={"verbose": True, "n_ctx": 4096}, diff --git a/tests/models/test_transformers.py b/tests/models/test_transformers.py index 5deaf8874..3a73e3127 100644 --- a/tests/models/test_transformers.py +++ b/tests/models/test_transformers.py @@ -1,6 +1,6 @@ import pytest -from guidance import gen, select +from guidance import gen, select, models, assistant, system, user from ..utils import get_model @@ -59,7 +59,6 @@ def test_transformer_smoke_select(model_name, model_kwargs): @pytest.mark.skip("Don't overload the build machines") def test_phi3_loading(): - from guidance import models lm = models.Transformers( r"microsoft/Phi-3-mini-4k-instruct", trust_remote_code=True @@ -70,8 +69,7 @@ def test_phi3_loading(): @pytest.mark.skip("Don't overload the build machines") def test_phi3_chat(): - # TODO: we currently use the wrong chat template for this model, need to update to match: https://huggingface.co/microsoft/Phi-3-mini-4k-instruct - from guidance import models, system, user, assistant + # TODO: Double check chat format: https://huggingface.co/microsoft/Phi-3-mini-4k-instruct lm = models.TransformersChat( r"microsoft/Phi-3-mini-4k-instruct", trust_remote_code=True