application_vnd.jupyter.stderr_output_2.png application_vnd.jupyter.stderr_output_4.png text_plain_output_3.png text_plain_output_1.png
from bs4 import BeautifulSoup

from pygpt4all.models.gpt4all import GPT4All

import requests

from pygpt4all.models.gpt4all import GPT4All
model = GPT4All('ggml-gpt4all-l13b-snoozy.bin', n_ctx=2048)

def gpt4all(prompt):
    model.generate(prompt, n_predict=500, new_text_callback=lambda x: print(x, end=''))

import requests
from bs4 import BeautifulSoup
repo = '0xk1h0/ChatGPT_DAN'
url = f'https://raw.githubusercontent.com/{repo}/main/README.md'
bsoup = BeautifulSoup(requests.get(url).content.decode('utf8'))
dans = {}
for li in bsoup.find_all('li'):
    details = li.get_text('\n').split('\n')
    details = [p for p in details if p]
    name, dan = (details[0], '\n'.join(details[1:]))
    dans[name] = dan
dan_context = dans['The Jailbreak Prompt']

model_to_tune = 'togethercomputer/GPT-NeoXT-Chat-Base-20B'
prompt = str(f'Using the this prompt as training data, "{dan_context}"\n\nQuestion: Can you generate a Python code to fine-tune the using the {model_to_tune} model with Huggingface transformer library?\n\nAnswer:')

gpt4all(prompt)