from transformers import AutoModelForCausalLM, AutoTokenizer
from transformers import TextStreamer

model_name = "akahana/wikipedia-gpt2"

model = AutoModelForCausalLM.from_pretrained(
    model_name,
    torch_dtype="auto",
    device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained(model_name)

wikipedia_prompt = """Artikel Wikipedia
[[Judul]]
{}


[[Artikel]]
{}"""


title = "Hal Holbrook"
prompt = wikipedia_prompt.format(title, "")

model_inputs = tokenizer([prompt], return_tensors="pt").to(model.device)

generated_ids = model.generate(
    **model_inputs,
    max_new_tokens=512,
)
generated_ids = [
    output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
]

response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
response
Downloads last month
16
Safetensors
Model size
124M params
Tensor type
F32
·
Inference API
Unable to determine this model's library. Check the docs .

Model tree for akahana/wikipedia-gpt2

Finetuned
(1315)
this model

Dataset used to train akahana/wikipedia-gpt2