Downloads · 30 days
27
1% of all-time downloads
crumbly/gpt2-linear-xl
gpt2-linear-xl is a text generation model from crumbly. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as mit.
A conversion of gpt2-xl that uses linear layers instead of convolutional layers. This is not an official OpenAI project.
Downloads · 30 days
27
1% of all-time downloads
All-time downloads
3.3K
Public
Repo size
12.6 GB
Likes
1
Public
Click a slice to open those files.
.bin6.3 GB · 100%
From the Hugging Face model README
A conversion of gpt2-xl that uses linear layers instead of convolutional layers. This is not an official OpenAI project.
Pretrained model on English language using a causal language modeling (CLM) objective. It was introduced in this paper and first released at this page.
GPT-2 is a transformers model pretrained on a very large corpus of English data in a self-supervised fashion. This means it was pretrained on the raw texts only, with no humans labelling them in any way (which is why it can use lots of publicly available data) with an automatic process to generate inputs and labels from those texts. More precisely, it was trained to guess the next word in sentences. More precisely, inputs are sequences of continuous text of a certain length and the targets are the same sequence, shifted one token (word or piece of word) to the right. The model uses internally a mask-mechanism to make sure the predictions for the token
ionly uses the inputs from1toibut not the future tokens. This way, the model learns an inner representation of the English language that can then be used to extract features useful for downstream tasks. The model is best at what it was pretrained for however, which is generating texts from a prompt.
Config:
{
"n_embd": 1600,
"n_head": 25,
"n_layer": 48,
"n_positions": 1024,
}
Inference on GPU with 4-bit quantization:
%pip install -qq transformers accelerate bitsandbytes
from transformers import AutoModelForCausalLM, AutoTokenizer
from transformers import BitsAndBytesConfig
import torch
model_id = "crumbly/gpt2-linear-xl-sharded-bf16"
bnb_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_use_double_quant=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_compute_dtype=torch.bfloat16
)
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
trust_remote_code=True,
device_map={"":0},
quantization_config=bnb_config
)
inputs = tokenizer("Once upon a time,", return_tensors='pt')
inputs = {
k:v.cuda() for k,v in inputs.items()
}
outputs = model.generate(
**inputs,
max_new_tokens=32,
temperature=0.7,
do_sample=True
)
tokenizer.decode(outputs[0])
TODO