GPT4All-J

Python bindings for the C++ port of GPT4All-J model.
Please migrate to
ctransformerslibrary which supports more models and has more features.
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'))
If you are getting illegal instruction error, try using instructions='avx' or instructions='basic':
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,
repeat_penalty=1.0,
repeat_last_n=64,
n_batch=8,
reset=True,
callback=None)
reset
If True, context will be reset. To keep the previous context, use reset=False.
model.generate('Write code to sort numbers in Python.')
model.generate('Rewrite the code in JavaScript.', reset=False)
callback
If a callback function is passed, 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)
LangChain
LangChain is a framework for developing applications powered by language models. A LangChain LLM object for the GPT4All-J model can be created using:
from gpt4allj.langchain import GPT4AllJ
llm = GPT4AllJ(model='/path/to/ggml-gpt4all-j.bin')
print(llm('AI is going to'))
If you are getting illegal instruction error, try using instructions='avx' or instructions='basic':
llm = GPT4AllJ(model='/path/to/ggml-gpt4all-j.bin', instructions='avx')
It can be used with other LangChain modules:
from langchain import PromptTemplate, LLMChain
template = """Question: {question}
Answer:"""
prompt = PromptTemplate(template=template, input_variables=['question'])
llm_chain = LLMChain(prompt=prompt, llm=llm)
print(llm_chain.run('What is AI?'))
Parameters
llm = GPT4AllJ(model='/path/to/ggml-gpt4all-j.bin',
seed=-1,
n_threads=-1,
n_predict=200,
top_k=40,
top_p=0.9,
temp=0.9,
repeat_penalty=1.0,
repeat_last_n=64,
n_batch=8,
reset=True)
C++ Library
To build the C++ library from source, please see 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
Metadata
Release files for gpt4all-j 0.2.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| gpt4all-j-0.2.6.tar.gz | 1.8 MB | Without provenance | Details |
Release files / gpt4all-j-0.2.6.tar.gz
| Download URL | gpt4all-j-0.2.6.tar.gz |
|---|---|
| Size | 1.8 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d2681cc4b7974586ecd4fa614fbb7e315bb787944a66f6b5e103f202c004fa40
|
|
BLAKE2b-256 checksum How to use checksums |
5a487c6c8a4d3262b77f8b909b2ca49d3d2196ce5bbbbad8192533a7a9da26d3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.10
|
Security for gpt4all-j 0.2.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.