Open omkar806 opened 4 months ago
Can you try to install it from source as instructed here?
You can refer to this example file to see new APIs of the library.
yeah I tried building it from source , but when i ran it I got this error : Abort at /Users/username/Documents/pygemma/gemma-cpp-python-0.1.3/build/temp.macosx-14.0-arm64-cpython-312/_deps/gemma-src/gemma.cc:823: Failed to load the tokenizer file. zsh: abort python test.py
Have you already built successfully? From the error message looks like maybe there is a problem with the tokenizer file you are using to load model
I built successfully now I also loaded the tokenizer but now I am gettting this error when I run the code? tokenizer : [no path specified] compressed_weights : [no path specified] model : weights : [no path specified] max_tokens : 3072 max_generated_tokens : 2048 multiturn : 0 Failed to read cache c_embedding (error 381) Abort at /Users/username/Documents/pygemma/gemma-cpp-python-0.1.3/build/temp.macosx-14.0-arm64-cpython-312/_deps/gemma-src/gemma.cc:113: Failed to open model file - does it exist? zsh: abort python test.py Note:gemma.cc file exists
My Code : from pygemma import Gemma
gemma = Gemma() gemma.show_help() gemma.show_config() gemma.load_model("/Users/username/Documents/pygemma/gemma_model/tokenizer.spm", "/Users/username/Documents/pygemma/gemma_model/2b-it-sfp.sbs", "2b-it-sfp") gemma.completion("Write a poem")
If I am correct, you are still using the older version of pygemma
. I'd recommend you to update to the lastest commits of the repo and rebuild, as it was tested and uses a newer version of gemma.cpp. Maybe the issue you are facing relates to that this version of pygemma was still using old version of gemma.cpp, which may not work with newer model files.
Here is the how you may use the new version of pygemma
:
from pygemma import Gemma, ModelType, ModelTraining
gemma = Gemma(
tokenizer_path=<TOKENIZER_PATH>,
compressed_weights_path=<COMPRESSED_WEIGHTS_PATH>,
model_type=ModelType.Gemma2B,
model_training=ModelTraining.GEMMA_IT,
)
output = gemma("Write a poem")
Collecting pygemma==0.1.3 Using cached pygemma-0.1.3.tar.gz (4.0 kB) Installing build dependencies ... done Getting requirements to build wheel ... done Preparing metadata (pyproject.toml) ... done Building wheels for collected packages: pygemma Building wheel for pygemma (pyproject.toml) ... error error: subprocess-exited-with-error
× Building wheel for pygemma (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [63 lines of output] running bdist_wheel running build running build_ext CMake Warning: Ignoring extra path from command line:
note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for pygemma Failed to build pygemma ERROR: Could not build wheels for pygemma, which is required to install pyproject.toml-based projects