-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Alejandro Martinez
authored and
Alejandro Martinez
committed
May 22, 2024
1 parent
f53d67a
commit 4d477bd
Showing
27 changed files
with
90 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
# auto-zkml | ||
# zkcook | ||
|
||
This package is designed to provide functionality that facilitates the transition from ML algorithms to ZKML. Its two main functionalities are: | ||
|
||
- [**Serialization**](#serialization): saving a trained ML model in a specific format to be interpretable by other programs. | ||
|
||
- [**model-complexity-reducer (mcr)**](#mcr): Given a model and a training dataset, transform the model and the data to obtain a lighter representation that maximizes the tradeoff between performance and complexity. | ||
|
||
It's important to note that although the main goal is the transition from ML to ZKML, auto-zkml can be useful in other contexts, such as: | ||
It's important to note that although the main goal is the transition from ML to ZKML, mcr can be useful in other contexts, such as: | ||
|
||
- The model's weight needs to be minimal, for example for mobile applications. | ||
- Minimal inference times are required for low latency applications. | ||
|
@@ -20,7 +20,7 @@ It's important to note that although the main goal is the transition from ML to | |
For the latest release: | ||
|
||
```bash | ||
pip install auto-zkml | ||
pip install giza-zkcook | ||
``` | ||
|
||
### Installing from source | ||
|
@@ -29,8 +29,8 @@ Clone the repository and install it with `pip`: | |
|
||
|
||
```bash | ||
git clone [email protected]:gizatechxyz/auto-zkml.git | ||
cd auto-zkml | ||
git clone [email protected]:gizatechxyz/zkcook.git | ||
cd zkcook | ||
pip install . | ||
``` | ||
|
||
|
@@ -41,7 +41,7 @@ To see in more detail how this tool works, check out this [tutorial](tutorials/s | |
To run it: | ||
|
||
```python | ||
from auto_zkml import serialize_model | ||
from giza.zkcook import serialize_model | ||
|
||
serialize_model(YOUR_TRAINED_MODEL, "OUTPUT_PATH/MODEL_NAME.json") | ||
``` | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from giza.zkcook.model_reducer import mcr | ||
from giza.zkcook.serializer.serialize import serialize_model | ||
|
||
__all__ = ["mcr", "serialize_model"] | ||
|
||
__version__ = "0.1.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
auto_zkml/serializer/serialize.py → giza/zkcook/serializer/serialize.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import json | ||
|
||
|
||
def serialize(model, output_path): | ||
booster = model.get_booster() | ||
model_bytes = booster.save_raw(raw_format="json") | ||
model_json_str = model_bytes.decode("utf-8") | ||
model_json = json.loads(model_json_str) | ||
opt_type = model_json["learner"]["objective"]["name"].lower() | ||
|
||
if "binary" in opt_type: | ||
opt_type = 1 | ||
elif "reg" in opt_type: | ||
opt_type = 0 | ||
else: | ||
raise ValueError("The model should be a classifier or regressor model.") | ||
|
||
new_fields = {"model_type": "xgboost", "opt_type": opt_type} | ||
combined_json = {**new_fields, **model_json} | ||
|
||
combined_json_str = json.dumps(combined_json) | ||
|
||
with open(output_path, "w") as file: | ||
file.write(combined_json_str) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
[tool.poetry] | ||
name = "auto-zkml" | ||
name = "giza-zkcook" | ||
version = "0.1.0" | ||
description = "" | ||
authors = ["Alejandro Martinez <[email protected]>"] | ||
readme = "README.md" | ||
license = "MIT" | ||
packages = [{include = "giza"}] | ||
|
||
|
||
[tool.poetry.dependencies] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.