Downloads · 30 days
17
1% of all-time downloads
jeremyarancio/llm-tolkien
llm-tolkien is a machine learning model from jeremyarancio. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for adapter-transformers. The card lists the license as bigscience-bloom-rail-1.0.
<h1 style='text-align: left 'LLM-Tolkien</h1 <h3 style='text-align: left 'Write your own Lord Of The Rings story!</h3
Downloads · 30 days
17
1% of all-time downloads
All-time downloads
1.3K
Public
Repo size
113 MB
Likes
1
Public
Click a slice to open those files.
.bin19.7 MB · 58%
From the Hugging Face model README
Version 1.1 / 23 May 2023
This LLM is fine-tuned on Bloom-3B with texts extracted from the book "The Lord of the Rings".
The article: Fine-tune an LLM on your personal data: create a “The Lord of the Rings” storyteller.
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftConfig, PeftModel
# Import the model
config = PeftConfig.from_pretrained("JeremyArancio/llm-tolkien")
model = AutoModelForCausalLM.from_pretrained(config.base_model_name_or_path, load_in_8bit=True, device_map='auto')
tokenizer = AutoTokenizer.from_pretrained(config.base_model_name_or_path)
# Load the Lora model
model = PeftModel.from_pretrained(model, "JeremyArancio/llm-tolkien")
prompt = "The hobbits were so suprised seeing their friend"
inputs = tokenizer(prompt, return_tensors="pt")
tokens = model.generate(
**inputs,
max_new_tokens=100,
temperature=1,
eos_token_id=tokenizer.eos_token_id,
early_stopping=True
)
print(tokenizer.decode(tokens[0]))
# The hobbits were so suprised seeing their friend again that they did not
# speak. Aragorn looked at them, and then he turned to the others.</s>
# Dataset
context_length = 2048
# Training
model_name = 'bigscience/bloom-3b'
lora_r = 16 # attention heads
lora_alpha = 32 # alpha scaling
lora_dropout = 0.05
lora_bias = "none"
lora_task_type = "CAUSAL_LM" # set this for CLM or Seq2Seq
## Trainer config
per_device_train_batch_size = 1
gradient_accumulation_steps = 1
warmup_steps = 100
num_train_epochs=3
weight_decay=0.1
learning_rate = 2e-4
fp16 = True
evaluation_strategy = "no"