Skip to content

Commit

Permalink
Add tests folder
Browse files Browse the repository at this point in the history
Signed-off-by: GitHub <[email protected]>
  • Loading branch information
Aisuko authored Mar 31, 2024
1 parent 8a8ecd1 commit 4410ca5
Show file tree
Hide file tree
Showing 14 changed files with 119 additions and 131 deletions.
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
version: 2
updates:
- package-ecosystem: "pip"
directory: "/"
directory: "/pkg"
schedule:
interval: weekly
2 changes: 1 addition & 1 deletion .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name-template: 'kimchi v$NEXT_PATCH_VERSION'
name-template: 'kimchima v$NEXT_PATCH_VERSION'
tag-template: 'v$NEXT_PATCH_VERSION'
categories:
- title: '🚀 Features'
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@ jobs:
name: 'Test 🔬'
strategy:
matrix:
os:
- ubuntu-latest
python-version:
- "3.11"

os: ["ubuntu-latest"]
python-version: ["3.11"]
poetry-version: ["1.8.2"]
runs-on: ${{ matrix.os }}
steps:
- name: Check repository
Expand All @@ -27,14 +25,16 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
# cache: 'pip'
cache: 'pip'
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Install Poetry
uses: abatilo/actions-poetry@v2
with:
poetry-version: ${{ matrix.poetry-version }}
- name: Install dependencies
run: |
conda env create -f kimchi.yml
conda activate kimchi
make install
- name: Run tests
run: |
make test
34 changes: 28 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ upload:
twine upload dist/* --verbose


.PHONY: test
test:
@python -m unittest -v


################################Poetry################################
.PHONY: poetry
poetry:
Expand All @@ -28,6 +23,11 @@ install:
@poetry install -vvv


.PHONY: test
test:
@poetry run python -m unittest discover -v


# build and publish
.PHONY: publish
publish:
Expand All @@ -42,4 +42,26 @@ config:

.PHONY: source
source:
@poetry config repositories.source https://pypi.org/simple
@poetry config repositories.source https://pypi.org/project/kimchima


###################################################################################################
# Commit and recommit changes to github
.PONY: commit
commit:
@echo "Committing changes..."
@git add .
@git commit -s -m"${message}"
@git push origin ${branch}
@git log -1
@echo "Changes committed and pushed to github."


.PONY: recommit
recommit:
@echo "Committing changes..."
@git add .
@git commit -s --amend --no-edit
@git push -f origin ${branch}
@git log -1
@echo "Changes committed and pushed to github."
30 changes: 10 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,29 @@
# kimchi
# kimchima

The collections of tools for testing and dumping LLMs. And this project is inspired by [Llama2-burn Project](https://github.com/Gadersd/llama2-burn/tree/main). And the main purpose of this project is to make sure the Llama2 model works well before we load it into the Rust ML framework.
[![Backend CI/CD 🚀](https://github.com/Aisuko/kimchima/actions/workflows/ci.yml/badge.svg)](https://github.com/Aisuko/kimchima/actions/workflows/ci.yml)
[![Release Drafter 🚀](https://github.com/Aisuko/kimchima/actions/workflows/release-drafter.yml/badge.svg)](https://github.com/Aisuko/kimchima/actions/workflows/release-drafter.yml)

The collections of tools for ML model development.


# Usage

You can use it as a command line tool if you like. And you can also use it as a library. Or you can run it in VSCode with [`launch.json`](.vscode/launch.json).



### Test the model
## Command Line Tool

```bash
kimchi test <model_dir> <tokenizer_path>
# or
python3 kimchi.py test <model_dir> <tokenizer_path>
$ python -m kimchima auto sentence-transformers/all-MiniLM-L6-v2 Melbourne

```

### Dump the model

```bash
kimchi dump <model_dir> <tokenizer_path>
# or
python3 kimchi.py dump <model_dir> <tokenizer_path>
```

```
pip install torch==2.2.1
pip install sentencepiece==0.2.0
pip install transformers==4.39.1
```
# Acknowledgement

# Credits
- [Llama2-burn Project](https://github.com/Gadersd/llama2-burn/tree/main)


# License

This project is licensed as specified in the [LICENSE](./LICENSE) file.
65 changes: 0 additions & 65 deletions kimchi.yml

This file was deleted.

27 changes: 17 additions & 10 deletions kimchima.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
# coding=utf-8
# Copyright [2024] [Aisuko]
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import argparse

from cmds.auto import CommandAuto


def main():
"""
Main function for kimchima.
"""
parser = argparse.ArgumentParser(
prog="kimchima",
description="A command line tool for natural language processing."
Expand All @@ -16,16 +33,6 @@ def main():
parser_auto.add_argument("text", help="text str or list of text str")
parser_auto.set_defaults(func=CommandAuto.auto)

# parser_command_test=subparsers.add_parser("test", help="test help")
# parser_command_test.add_argument("model_dir", help="model directory")
# parser_command_test.add_argument("tokenizer_path", help="tokenizer path")
# parser_command_test.set_defaults(func=CommandTestModel.t_model)

# parser_command_dump=subparsers.add_parser("dump", help="dump help")
# parser_command_dump.add_argument("model_dir", help="model directory")
# parser_command_dump.add_argument("tokenizer_path", help="tokenizer path")
# parser_command_dump.set_defaults(func=CommandDumpModel.dump_model)

args = parser.parse_args()
args.func(args)

Expand Down
31 changes: 12 additions & 19 deletions pkg/auto/auto.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
# coding=utf-8
# Copyright (c) 2023 Aisuko

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:

# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.

# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
# Copyright [2024] [Aisuko]
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import torch
import torch.nn.functional as F
Expand Down
14 changes: 14 additions & 0 deletions pkg/devices/devices.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# coding=utf-8
# Copyright [2024] [Aisuko]
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from enum import Enum
import torch
import platform
Expand Down
Empty file added tests/__init__.py
Empty file.
13 changes: 13 additions & 0 deletions pkg/auto/test_auto.py → tests/test_auto.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
# coding=utf-8
# Copyright [2024] [Aisuko]
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import unittest

from pkg.auto import Auto
Expand Down
14 changes: 14 additions & 0 deletions pkg/devices/test_devices.py → tests/test_devices.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# coding=utf-8
# Copyright [2024] [Aisuko]
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import unittest
import platform
import torch
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 4410ca5

Please sign in to comment.