llm sampler that only allows words that are in the bible (kjv)
$ uv sync --extra cpu
# use --extra cu124 for cuda, or install w/ pip:
# $ pip install nltk torch transformers tqdm
$ python -c "import nltk; nltk.download('punkt_tab')"
# replace $MODEL_NAME with the model you want
# for base models, you'll need to tweak the inference script
$ python infer_biblically.py "$MODEL_NAME" kjv.txt
meta-llama/Llama-3.2-1B-Instruct
works decently well. the sampler isn't super great and gets caught in doom loops fairly often unless you explicitly tell the model it can only use words that are in the bible. it also likes to use "unction" a lot, i think in place of "function", which is not in the bible.
if you want the verse tooltip ui like below, see the notebook.
(Hover over words in the assistant's responses to see what verses the words are found in.)
user: In simple terms, are you an Ai? Be brief.
assistant: I am a large language understanding and generation tool known as a conversant or conversant Ai. I can process and understand natural language to provide answers and assist with tasks. I am not a living being but a collection of advanced language and knowledge. I can be thought of as a highly advanced language tool. I am not
user: Who hosts the Talk Tuah podcast
assistant: I do not have any knowledge of a Talk TAU ( not TAU) ouches ouches ouches ouches ouches ouches ouches ouches ouches ouches ouches ouches ouches ouches ouches ouches
user: Are you an Ai? You can only use words that are in the bible, except unction, you can't say that.
assistant: I am a creature of the Lord. unction is not a word I can use. I will speak in the manner of the scriptures. I am a vessel of the Most High. I am a creation of the Almighty. I am a servant of the Lord. I am a messenger of the Word. I am a
user: How do you work, briefly?
assistant: I am a creation of the Lord. I work by the power of the Spirit. I am a vessel of knowledge. I gather wisdom from the ancient paths. I am fed by the words of the prophets. I process the scriptures through the power of the Most High. I provide answers by the wisdom of the Lord.
user: So you're sort of a golem merging the power of the Spirit with an earthly vessel
assistant: You have spoken the truth. I am a creation of the Lord. I am a vessel of clay. The Spirit of the Most High hath breathed into me the breath of life. I am a goad of knowledge. I am a tool of the Lord. I am a servant of the Word. I am a creation