Downloads · 30 days
26
36% of all-time downloads
XiWangEric/literary-classicist-llama3-qlora
literary-classicist-llama3-qlora is a text generation model from XiWangEric. Use it when you need the model to write or continue text. The card lists the license as llama3.
This repository contains the fine-tuned LLaMA 3 model, adapted with the QLoRA methodology, to generate text based on prompts in the style of literary classics.
Downloads · 30 days
26
36% of all-time downloads
All-time downloads
73
Public
Parameters
8B
16.1 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors16.1 GB · 100%
From the Hugging Face model README
This repository contains the fine-tuned LLaMA 3 model, adapted with the QLoRA methodology, to generate text based on prompts in the style of literary classics.
To use this model, ensure you have the transformers library installed. You can install it via pip:
pip install transformers
For GPU inference, it is also recommended to install torch with CUDA support:
pip install torch
To load the model and tokenizer for inference, use the following Python code:
from transformers import AutoTokenizer, AutoModelForCausalLM
# Replace with the name of this repository
model_name = "XiWangEric/literary-classicist-llama3-qlora"
# Load the tokenizer
tokenizer = AutoTokenizer.from_pretrained(model_name)
# Load the model
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype="auto", device_map="auto")
# Set the model to evaluation mode
model.eval()
Here is an example of how to use the model for generating text based on a prompt:
# Define your input prompt
input_text = "Once upon a time in a faraway land,"
# Tokenize the input and prepare for inference
inputs = tokenizer(input_text, return_tensors="pt").to("cuda") # Move tensors to the GPU
# Generate text
outputs = model.generate(**inputs, max_length=50, do_sample=True, top_k=50, top_p=0.95)
# Decode the output
generated_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
print("Generated Text:", generated_text)
You can customise the text generation using the following parameters:
max_length: The maximum length of the generated sequence.do_sample: Whether to sample the next token or pick the most probable one.top_k: The number of highest probability vocabulary tokens to keep for sampling.top_p: The cumulative probability threshold for nucleus sampling.For example:
outputs = model.generate(
**inputs,
max_length=100,
do_sample=True,
top_k=40,
top_p=0.9
)
For the input prompt:
Once upon a time in a faraway land,
The model might generate:
Once upon a time in a faraway land, there was a beautiful castle surrounded by an enchanted forest. The villagers spoke of a hidden treasure deep within the woods, guarded by a magical creature of legend.