Last active
May 1, 2023 22:29
-
-
Save epeters3/11875c89e3e6c122460789fb587b6b8e to your computer and use it in GitHub Desktop.
A bare-bones CLI for interacting with the `GPT4All-J@v1.2-jazzy` LLM.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from fire import Fire | |
import torch | |
from transformers import pipeline | |
def main(): | |
generate_text = pipeline( | |
model="nomic-ai/gpt4all-j", | |
revision="v1.2-jazzy", | |
torch_dtype=torch.bfloat16, | |
trust_remote_code=True, | |
device_map="auto", | |
max_length=2000, | |
) | |
print("Welcome to GPT4All-J!") | |
prompt = "" | |
while prompt.lower() not in {"q", "quit", "exit"}: | |
prompt = input(">>> ") | |
res = generate_text(prompt) | |
output: str = res[0]["generated_text"] | |
content = output[len(prompt) :].strip() | |
print(content) | |
if __name__ == "__main__": | |
Fire(main) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment