Skip to main content

Python bindings for the C++ port of GPT4All-J model.

Project description

GPT4All-J tests

Python bindings for the [C++ port][gptj.cpp] of GPT4All-J model.

Installation

pip install gpt4all-j

Download the model from here.

Usage

from gpt4allj import Model

model = Model('/path/to/ggml-gpt4all-j.bin')

print(model.generate('AI is going to'))

Run in Google Colab

If you are getting Illegal instruction error, try using instructions='avx':

model = Model('/path/to/ggml-gpt4all-j.bin', instructions='avx')

If it is running slow, try building the C++ library from source. Learn more

Parameters

model.generate(prompt,
               seed=-1,
               n_threads=-1,
               n_predict=200,
               top_k=40,
               top_p=0.9,
               temp=0.9,
               n_batch=8,
               callback=None)

callback

If a callback function is passed to model.generate(), it will be called once per each generated token. To stop generating more tokens, return False inside the callback function.

def callback(token):
    print(token)

model.generate('AI is going to', callback=callback)

C++ Library

To build the C++ library from source, please see [gptj.cpp][gptj.cpp]. Once you have built the shared libraries, you can use them as:

from gpt4allj import Model, load_library

lib = load_library('/path/to/libgptj.so', '/path/to/libggml.so')

model = Model('/path/to/ggml-gpt4all-j.bin', lib=lib)

License

MIT [gptj.cpp]: https://github.com/marella/gptj.cpp

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gpt4all-j-0.2.0.tar.gz (1.1 MB view details)

Uploaded Source

File details

Details for the file gpt4all-j-0.2.0.tar.gz.

File metadata

  • Download URL: gpt4all-j-0.2.0.tar.gz
  • Upload date:
  • Size: 1.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.10

File hashes

Hashes for gpt4all-j-0.2.0.tar.gz
Algorithm Hash digest
SHA256 29b1b9ffea8fe6fdd75c39ff152220d4e6a0814bd9269739f7bc037986e11931
MD5 94d559886b5cbca32af2224cb703080f
BLAKE2b-256 92c55d4ce4018e94d7a9018f1816467b96fe74eab13661bd7e47a4ee982d7eab

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page