Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Requirements:
- 1- A working tensorflow installation.
- 2- The pytorch library: pip install torch
- 3- The transformers library: pip install transformers
- 4- The model file (pytorch_model.bin). HuggingFace deleted it, but you can download it by torrent: https://archive.org/details/gpt4chan_model
- 5- The model config file (config.json). It should be placed in the same folder as the model file and can be found here: https://github.com/yk/gpt-4chan-public
- 6- A computer with 24GB of free RAM. A GPU is not required. The model will be executed directly from the CPU.
- The folder structure will look like this:
- gpt4chan_model
- \_ pytorch_model.bin
- \_ config.json
- \_ CITATION.bib
- \_ gpt4chan_model_meta.sqlite
- \_ gpt4chan_model_meta.xml
- \_ LICENSE.txt
- Then execute the model with the following Python script, making sure to place it in the same parent folder as the gpt4chan_model folder:
- from transformers import AutoModelForCausalLM, AutoTokenizer
- import sys
- import time
- model = AutoModelForCausalLM.from_pretrained("gpt4chan_model", low_cpu_mem_usage=True)
- tokenizer = AutoTokenizer.from_pretrained("EleutherAI/gpt-j-6B")
- prompt = ("-----\n--- 865467536\nAI is interesting because ")
- input_ids = tokenizer(prompt, return_tensors="pt").input_ids
- gen_tokens = model.generate(
- input_ids,
- do_sample=True,
- temperature=0.8,
- top_p=1,
- typical_p=0.3,
- max_length=128,
- )
- gen_text = tokenizer.batch_decode(gen_tokens)[0]
- print(gen_text)
- It takes a few minutes to run the script above.
- In case config.json is taken down, here are its contents:
- {
- "activation_function": "gelu_new",
- "architectures": [
- "GPTJForCausalLM"
- ],
- "attn_pdrop": 0.0,
- "bos_token_id": 50256,
- "embd_pdrop": 0.0,
- "eos_token_id": 50256,
- "gradient_checkpointing": false,
- "initializer_range": 0.02,
- "layer_norm_epsilon": 1e-05,
- "model_type": "gptj",
- "n_embd": 4096,
- "n_head": 16,
- "n_layer": 28,
- "n_positions": 2048,
- "rotary_dim": 64,
- "summary_activation": null,
- "summary_first_dropout": 0.1,
- "summary_proj_to_labels": true,
- "summary_type": "cls_index",
- "summary_use_proj": true,
- "transformers_version": "4.10.0.dev0",
- "tokenizer_class": "GPT2Tokenizer",
- "task_specific_params": {
- "text-generation": {
- "do_sample": true,
- "temperature": 1.0,
- "max_length": 50
- }
- },
- "torch_dtype": "float32",
- "use_cache": true,
- "vocab_size": 50400
- }