Views
No views yet
- Two guys argued about a painting. There was a rupture in the peace. (peace → piece)
- Old pianists never die they just get tuned away.
- A successful soft drink company is full of cool executives.
- The story of a boy who was born with one eye in the wrong place was told from an unexpected angle.
- "I love kiwis," said Tom kiwwisely. (they're not all zingers)
| File | Format | Use |
|---|---|---|
model.safetensors (+ config.json, tokenizer) | fp16 safetensors | loads with a plain from_pretrained on modern transformers — no custom code, no 8-bit tricks |
ggml-model-q4_0.bin | ggml, 4-bit | CPU-only inference (~3.4 GB, ~4 GB RAM) via ggml's gpt-j |
eval.py | reference | the original 2023 inference script — documents the prompt schema |
.pt pickle has been removed in
favour of this safetensors (safe-format) equivalent.<|extratoken_N|> vocabulary. To
generate a pun unconditionally, prompt with:<|extratoken_60|><|extratoken_61|> # TASK_START
<|extratoken_46|><|extratoken_47|> # generate pun → explanation from keywords
<|extratoken_10|><|extratoken_11|> # PUN begin
<|extratoken_24|><|extratoken_25|> # GRAPHEMES (written form) begin<|extratoken_60|><|extratoken_61|><|extratoken_46|><|extratoken_47|><|extratoken_10|><|extratoken_11|><|extratoken_24|><|extratoken_25|>,
then sample. The pun is emitted as written text; the model also produces an
explanation (often as ARPABET phonemes — a quirk of how deeply the phonetic
training pervades it). Strip the <|extratoken_N|> tags from the output.1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer
3
4repo = "pcalhoun/gpt-j-6b-8bit-pun-generator"
5tok = AutoTokenizer.from_pretrained(repo)
6model = AutoModelForCausalLM.from_pretrained(repo, torch_dtype=torch.float16).cuda().eval()
7
8pre = ("<|extratoken_60|><|extratoken_61|>"
9 "<|extratoken_46|><|extratoken_47|>"
10 "<|extratoken_10|><|extratoken_11|>"
11 "<|extratoken_24|><|extratoken_25|>")
12ids = tok(pre, return_tensors="pt").to(model.device)
13out = model.generate(ids.input_ids, do_sample=True, temperature=0.9,
14 top_k=50, top_p=0.98, max_new_tokens=128, pad_token_id=50256)
15text = tok.decode(out[0])
16import re
17print(re.sub(r"<\|extratoken_\d+\|>", " ", text).strip())gpt-j example of the ggml
repo. Build that, and patch its tokenizer to treat the <|extratoken_N|> tags as
atomic special tokens (otherwise they get BPE-split and the model isn't
conditioned):1git clone https://github.com/ggml-org/ggml && cd ggml
2cmake -B build -DCMAKE_BUILD_TYPE=Release && cmake --build build --target gpt-j -j
3# download ggml-model-q4_0.bin from this repo, then:
4./build/bin/gpt-j -m ggml-model-q4_0.bin -n 128 --top_k 50 --top_p 0.98 --temp 0.9 \
5 -p '<|extratoken_60|><|extratoken_61|><|extratoken_46|><|extratoken_47|><|extratoken_10|><|extratoken_11|><|extratoken_24|><|extratoken_25|>'