Skip to main content

Package for training and deploying doctrinally correct LLMs.

Project description

AI for the Church

Modern LLMs are rooted in secular value systems that are often misaligned with religious organisations. This PyPI package allows anyone to train and deploying doctrinally correct LLMs based on Llama2. Effectively, we are aligning models to a set of values.

Model fine-tuning

from aiforthechurch import align_llama2
doctrinal_dataset = "/path/to/csv"

aiforthechurch is integrated with HuggingFace shuch that the aligned model will be automatically pushed to your HuggingFace repo of choice at the end of the training.

At we provide tools for generating doctrinal datasets, a few examples are available at

Model inference and deployment

We implemented an inference API in the same format as OpenAI's.

import aiforthechurch
aiforthechurch.Completion.create(denomination="catholic", message="Does Jesus love me?")

There is also an asynchronous streaming API, just set stream=True.

And you can use our code to create your own inference server with the models you train by editing the MODELS dictionary in gloohack/deployment/ with a denomination and a path to your model in huggingface. Start the server by running the following command on your machine:

python gloohack/deployment/

Model training requirements

If you wish to train your models using this repo you will need access to a machine with over 16GB of GPU memory and 30GB RAM. The full model weights for Llama2-7B amount to almost 30GB, but we use parameter-efficient fine-tuning (PEFT) LoRA to save memory and avoid any catastrophic forgetting during the fine-tuning procedure.


We leaned heavily on open-source libraries like transformers, peft, and bitsandbytes for this project.

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

aiforthechurch-0.5.tar.gz (2.4 kB view hashes)

Uploaded Source

Built Distribution

aiforthechurch-0.5-py3-none-any.whl (2.4 kB view hashes)

Uploaded Python 3

Supported by

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