Spaces:
Sleeping
Sleeping
Commit
·
83e9505
1
Parent(s):
353f607
added real test cases
Browse files- .github/workflows/test.yaml +0 -0
- .github/workflows/unit-test.yaml +27 -0
- space/app.py → interface.py +0 -0
- setup.py +13 -18
- tests/test_datasets.py +7 -0
- tests/test_demo.py +0 -25
- tests/test_pretrained.py +11 -0
- tests/test_tokenizer.py +15 -0
- tests/test_transformer.py +12 -0
- yume/__init__.py +1 -1
- yume/config.py +20 -2
- yume/models.py +23 -1
- yume/tokenizer.py +3 -1
- yume/utils.py +8 -2
- yume/yume.py +2 -0
.github/workflows/test.yaml
DELETED
File without changes
|
.github/workflows/unit-test.yaml
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: Unit Tests
|
2 |
+
|
3 |
+
on:
|
4 |
+
push:
|
5 |
+
branches:
|
6 |
+
- "main"
|
7 |
+
|
8 |
+
jobs:
|
9 |
+
test:
|
10 |
+
runs-on: ubuntu-latest
|
11 |
+
|
12 |
+
steps:
|
13 |
+
- name: Checkout code
|
14 |
+
uses: actions/checkout@v2
|
15 |
+
|
16 |
+
- name: Setup Python
|
17 |
+
uses: actions/setup-python@v2
|
18 |
+
with:
|
19 |
+
python-version: 3.x
|
20 |
+
|
21 |
+
- name: Install dependencies
|
22 |
+
run: |
|
23 |
+
pip install -r ./requirements.txt
|
24 |
+
|
25 |
+
- name: Run tests
|
26 |
+
run: |
|
27 |
+
python -m unittest ./tests
|
space/app.py → interface.py
RENAMED
File without changes
|
setup.py
CHANGED
@@ -1,26 +1,21 @@
|
|
1 |
from setuptools import setup, find_packages
|
2 |
|
3 |
-
with open(
|
4 |
requirements = f.read().splitlines()
|
5 |
|
6 |
setup(
|
7 |
-
name=
|
8 |
-
version=
|
9 |
packages=find_packages(),
|
10 |
install_requires=requirements,
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
classifiers=[
|
22 |
-
'Programming Language :: Python :: 3',
|
23 |
-
'License :: OSI Approved :: MIT License',
|
24 |
-
'Operating System :: OS Independent',
|
25 |
-
],
|
26 |
)
|
|
|
1 |
from setuptools import setup, find_packages
|
2 |
|
3 |
+
with open("requirements.txt") as f:
|
4 |
requirements = f.read().splitlines()
|
5 |
|
6 |
setup(
|
7 |
+
name="yume",
|
8 |
+
version="0.1",
|
9 |
packages=find_packages(),
|
10 |
install_requires=requirements,
|
11 |
+
author="Zai",
|
12 |
+
author_email="zaiyellyintaung@gmail.com",
|
13 |
+
description="LLM trained with Animanga dataset",
|
14 |
+
long_description="Inspired by Andrej Karpathy trained with japanese animanga dataset",
|
15 |
+
url="https://github.com/zaibutcooler/yume",
|
16 |
+
# classifiers=[
|
17 |
+
# 'Programming Language :: Python :: 3',
|
18 |
+
# 'License :: OSI Approved :: MIT License',
|
19 |
+
# 'Operating System :: OS Independent',
|
20 |
+
# ],
|
|
|
|
|
|
|
|
|
|
|
21 |
)
|
tests/test_datasets.py
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import unittest
|
2 |
+
|
3 |
+
class TestDatasets(unittest.TestCase):
|
4 |
+
pass
|
5 |
+
|
6 |
+
if __name__ == '__main__':
|
7 |
+
unittest.main()
|
tests/test_demo.py
DELETED
@@ -1,25 +0,0 @@
|
|
1 |
-
# test_demo.py
|
2 |
-
import unittest
|
3 |
-
|
4 |
-
def add_numbers(a, b):
|
5 |
-
return a + b
|
6 |
-
|
7 |
-
def multiply_numbers(a, b):
|
8 |
-
return a * b
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
class TestDemoFunctions(unittest.TestCase):
|
13 |
-
|
14 |
-
def test_add_numbers(self):
|
15 |
-
self.assertEqual(add_numbers(2, 3), 5)
|
16 |
-
self.assertEqual(add_numbers(-1, 1), 0)
|
17 |
-
# Add more test cases as needed
|
18 |
-
|
19 |
-
def test_multiply_numbers(self):
|
20 |
-
self.assertEqual(multiply_numbers(2, 3), 6)
|
21 |
-
self.assertEqual(multiply_numbers(-1, 1), -1)
|
22 |
-
# Add more test cases as needed
|
23 |
-
|
24 |
-
if __name__ == '__main__':
|
25 |
-
unittest.main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tests/test_pretrained.py
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import unittest
|
2 |
+
|
3 |
+
class TestPretrained(unittest.TestCase):
|
4 |
+
def test_download():
|
5 |
+
pass
|
6 |
+
|
7 |
+
def test_generation():
|
8 |
+
pass
|
9 |
+
|
10 |
+
if __name__ == '__main__':
|
11 |
+
unittest.main()
|
tests/test_tokenizer.py
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import unittest
|
2 |
+
|
3 |
+
class TestTokenizer(unittest.TestCase):
|
4 |
+
def test_encode():
|
5 |
+
pass
|
6 |
+
|
7 |
+
def test_decode():
|
8 |
+
pass
|
9 |
+
|
10 |
+
def test_equal_result():
|
11 |
+
pass
|
12 |
+
|
13 |
+
|
14 |
+
if __name__ == '__main__':
|
15 |
+
unittest.main()
|
tests/test_transformer.py
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import unittest
|
2 |
+
|
3 |
+
class TestTransformer(unittest.TestCase):
|
4 |
+
def test_loading_model():
|
5 |
+
pass
|
6 |
+
|
7 |
+
def test_parameters():
|
8 |
+
pass
|
9 |
+
|
10 |
+
|
11 |
+
if __name__ == '__main__':
|
12 |
+
unittest.main()
|
yume/__init__.py
CHANGED
@@ -1 +1 @@
|
|
1 |
-
from yume import Yume
|
|
|
1 |
+
from yume import Yume
|
yume/config.py
CHANGED
@@ -1,5 +1,23 @@
|
|
|
|
1 |
class Config:
|
2 |
-
def __init__(self
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
config = Config()
|
|
|
1 |
+
|
2 |
class Config:
|
3 |
+
def __init__(self,num_epoch:int,
|
4 |
+
block_sized = 1024,
|
5 |
+
vocab_sized = 50304,
|
6 |
+
n_layer = 12,
|
7 |
+
n_head = 12,
|
8 |
+
n_embd = 768,
|
9 |
+
dropout = 0.0,
|
10 |
+
bias = True,
|
11 |
+
|
12 |
+
) -> None:
|
13 |
+
self.num_epoch = num_epoch
|
14 |
+
self.block_sized = 1024
|
15 |
+
self.vocab_sized = 50304
|
16 |
+
self.n_layerd = 12
|
17 |
+
self.n_headd = 12
|
18 |
+
self.n_embdd = 768
|
19 |
+
self.dropout = 0.0
|
20 |
+
self.bias = True
|
21 |
+
|
22 |
|
23 |
config = Config()
|
yume/models.py
CHANGED
@@ -2,7 +2,29 @@ import torch
|
|
2 |
from torch import nn
|
3 |
import torch.nn.functional as F
|
4 |
|
5 |
-
class
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
def __init__(self, config):
|
7 |
super().__init__()
|
8 |
|
|
|
2 |
from torch import nn
|
3 |
import torch.nn.functional as F
|
4 |
|
5 |
+
class SelfAttention(nn.Module):
|
6 |
+
def __init__(self, ) -> None:
|
7 |
+
super().__init__()
|
8 |
+
|
9 |
+
def forward(self):
|
10 |
+
pass
|
11 |
+
|
12 |
+
class MLP(nn.Module):
|
13 |
+
def __init__(self, ) -> None:
|
14 |
+
super().__init__()
|
15 |
+
|
16 |
+
def forward(self):
|
17 |
+
pass
|
18 |
+
|
19 |
+
class Block(nn.Module):
|
20 |
+
def __init__(self, ) -> None:
|
21 |
+
super().__init__()
|
22 |
+
|
23 |
+
def forward(self):
|
24 |
+
pass
|
25 |
+
|
26 |
+
|
27 |
+
class GPT(nn.Module):
|
28 |
def __init__(self, config):
|
29 |
super().__init__()
|
30 |
|
yume/tokenizer.py
CHANGED
@@ -1,3 +1,5 @@
|
|
1 |
class Tokenizer:
|
2 |
def __init__(self):
|
3 |
-
pass
|
|
|
|
|
|
1 |
class Tokenizer:
|
2 |
def __init__(self):
|
3 |
+
pass
|
4 |
+
|
5 |
+
|
yume/utils.py
CHANGED
@@ -1,2 +1,8 @@
|
|
1 |
-
def
|
2 |
-
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
def encode(text):
|
2 |
+
pass
|
3 |
+
|
4 |
+
def decode(text):
|
5 |
+
pass
|
6 |
+
|
7 |
+
def transform_data(data):
|
8 |
+
pass
|
yume/yume.py
CHANGED
@@ -2,12 +2,14 @@ import torch
|
|
2 |
from torch import nn
|
3 |
import torch.nn.functional as F
|
4 |
from config import Config
|
|
|
5 |
|
6 |
config = Config()
|
7 |
|
8 |
class Yume:
|
9 |
def __init__(self, config):
|
10 |
super().__init__()
|
|
|
11 |
|
12 |
def train(self):
|
13 |
pass
|
|
|
2 |
from torch import nn
|
3 |
import torch.nn.functional as F
|
4 |
from config import Config
|
5 |
+
from .models import GPT
|
6 |
|
7 |
config = Config()
|
8 |
|
9 |
class Yume:
|
10 |
def __init__(self, config):
|
11 |
super().__init__()
|
12 |
+
self.model = GPT(config=config)
|
13 |
|
14 |
def train(self):
|
15 |
pass
|