winglian commited on
Commit
d199d6c
1 Parent(s): cb18856

automated testing in github actions

Browse files
.github/workflows/tests.yml ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: PyTest
2
+ on: push
3
+
4
+ jobs:
5
+ test:
6
+ runs-on: ubuntu-latest
7
+ timeout-minutes: 10
8
+
9
+ steps:
10
+ - name: Check out repository code
11
+ uses: actions/checkout@v2
12
+
13
+ - name: Setup Python
14
+ uses: actions/setup-python@v2
15
+ with:
16
+ python-version: "3.9"
17
+
18
+ - name: Install pytest
19
+ run: |
20
+ pip install --upgrade pytest
21
+
22
+ - name: Install dependencies
23
+ run: |
24
+ pip install -r requirements-tests.txt
25
+
26
+ - name: Run tests
27
+ run: |
28
+ pytest tests/
requirements-tests.txt ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ peft @ git+https://github.com/huggingface/peft.git
2
+ transformers @ git+https://github.com/huggingface/transformers.git
3
+ bitsandbytes>=0.39.0
4
+ attrdict
5
+ fire
6
+ PyYAML==6.0
7
+ black
8
+ datasets
9
+ accelerate>=0.19.0
10
+ sentencepiece
11
+ wandb
tests/test_prompters.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import unittest
2
+
3
+ from axolotl.prompters import AlpacaPrompter, PromptStyle
4
+
5
+
6
+ class AlpacaPrompterTest(unittest.TestCase):
7
+ def test_prompt_style_w_none(self):
8
+ prompter = AlpacaPrompter(prompt_style=None)
9
+ res = next(prompter.build_prompt("tell me a joke"))
10
+ # just testing that it uses instruct style
11
+ assert "### Instruction:" in res
12
+
13
+ def test_prompt_style_w_instruct(self):
14
+ prompter = AlpacaPrompter(prompt_style=PromptStyle.instruct.value)
15
+ res = next(prompter.build_prompt("tell me a joke about the following", "alpacas"))
16
+ assert "Below is an instruction" in res
17
+ assert "### Instruction:" in res
18
+ assert "### Input:" in res
19
+ assert "alpacas" in res
20
+ assert "### Response:" in res
21
+ assert "USER:" not in res
22
+ assert "ASSISTANT:" not in res
23
+ res = next(prompter.build_prompt("tell me a joke about the following"))
24
+ assert "Below is an instruction" in res
25
+ assert "### Instruction:" in res
26
+ assert "### Input:" not in res
27
+ assert "### Response:" in res
28
+ assert "USER:" not in res
29
+ assert "ASSISTANT:" not in res
30
+
31
+ def test_prompt_style_w_chat(self):
32
+ prompter = AlpacaPrompter(prompt_style=PromptStyle.chat.value)
33
+ res = next(prompter.build_prompt("tell me a joke about the following", "alpacas"))
34
+ assert "Below is an instruction" in res
35
+ assert "### Instruction:" not in res
36
+ assert "### Input:" not in res
37
+ assert "alpacas" in res
38
+ assert "### Response:" not in res
39
+ assert "USER:" in res
40
+ assert "ASSISTANT:" in res
41
+ res = next(prompter.build_prompt("tell me a joke about the following"))
42
+ assert "Below is an instruction" in res
43
+ assert "### Instruction:" not in res
44
+ assert "### Input:" not in res
45
+ assert "### Response:" not in res
46
+ assert "USER:" in res
47
+ assert "ASSISTANT:" in res
48
+
49
+