Downloads · 30 days
7
3% of all-time downloads
noelpn26/lenna
lenna is a machine learning model from noelpn26. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as cc-by-nc-2.0.
--- language: - en pipelinetag: text-generation tags: - gpt2 - causal-lm - lenna - pytorch ---
Downloads · 30 days
7
3% of all-time downloads
All-time downloads
221
Public
Parameters
124M
31.4 GB on disk
Likes
0
Public
Click a slice to open those files.
.pt20.9 GB · 66%
From the Hugging Face model README
language:
noelpn26/lenna)Lenna is a fine-tuned causal language model based on GPT-2. It has been lightweight-adapted to answer basic identity questions, general technology concepts, programming concepts, and general knowledge queries in both English.
gpt2You can easily run inference using PyTorch and the Hugging Face transformers library.
import torch
from transformers import GPT2LMHeadModel, GPT2Tokenizer
model_id = "noelpn26/lenna"
# Load Model & Tokenizer
tokenizer = GPT2Tokenizer.from_pretrained(model_id)
model = GPT2LMHeadModel.from_pretrained(model_id)
device = "cuda" if torch.cuda.is_available() else "cpu"
model.to(device)
# Prepare Prompt (Always use the "User: ... \nAssistant:" format)
prompt = "User: what is your name\nAssistant:"
inputs = tokenizer(prompt, return_tensors="pt").to(device)
# Generate Response
outputs = model.generate(
**inputs,
max_new_tokens=30,
temperature=0.3,
repetition_penalty=1.2,
eos_token_id=tokenizer.eos_token_id,
pad_token_id=tokenizer.eos_token_id,
do_sample=True
)
# Parse Clean Response
full_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
clean_reply = full_text[len(prompt):].split("\n")[0].split("User:")[0].strip()
print(f"Assistant: {clean_reply}")