Downloads · 30 days
7
27% of all-time downloads
learn-abc/tinyllama-custom-quotes
tinyllama-custom-quotes is a text generation model from learn-abc. Use it when you need the model to write or continue text. It is set up for peft.
This model is a PEFT (LoRA) fine-tuned version of TinyLlama/TinyLlama-1.1B-Chat-v1.0. It has been specialized to act as an AI assistant that, when given an inspiring quote, provides the author's name, following a spec…
Downloads · 30 days
7
27% of all-time downloads
All-time downloads
26
Public
Repo size
2.4 GB
Likes
0
Public
Click a slice to open those files.
.pt1.6 GB · 61%
From the Hugging Face model README
This model is a PEFT (LoRA) fine-tuned version of TinyLlama/TinyLlama-1.1B-Chat-v1.0. It has been specialized to act as an AI assistant that, when given an inspiring quote, provides the author's name, following a specific instruction-based chat format.
This model is a specialized version of TinyLlama-1.1B-Chat-v1.0, fine-tuned using the QLoRA technique. The primary objective of this fine-tuning was to adapt the base LLM's behavior to a specific task: generating the author's name for a given inspiring quote. It adheres to a conversational instruction format, making it suitable for focused Q&A on a dataset of quotes and authors.
learn-abc)This model is intended for direct use in applications requiring highly specialized text generation for quotes. Specifically, it can be prompted with an inspiring quote in a predefined instruction format, and it will generate the corresponding author. It is ideal for:
This fine-tuned adapter can be integrated into larger systems or applications that require accurate quote-to-author mapping. Examples include:
This model is not intended for:
This model inherits biases present in its base model, TinyLlama/TinyLlama-1.1B-Chat-v1.0, which was trained on a broad corpus. Additionally, biases from the Abirate/english_quotes dataset (e.g., disproportionate representation of certain authors, historical periods, or cultural perspectives) may be introduced or amplified.
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. For critical applications, human review of generated outputs is recommended. It should primarily be used for its intended task of quote attribution based on the fine-tuning data. Developers should evaluate its performance on a representative dataset reflecting their specific use case to understand its limitations.
To use this model for inference, you can load the base model and then load the PEFT adapters on top of it. Alternatively, you can directly load the merged model if it has been saved in a standalone format.
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
from peft import PeftModel
import torch
# Define the model paths
BASE_MODEL_NAME = "TinyLlama/TinyLlama-1.1B-Chat-v1.0"
FINE_TUNED_ADAPTER_PATH = "learn-abc/tinyllama-custom-quotes" # Your Hugging Face repo ID
MERGED_MODEL_PATH = "/tinyllama_custom_quotes_fine_funed/merged_model" # If you have saved the merged model locally
# Option 1: Load base model and then PEFT adapter (requires peft installed)
# Load base model
model = AutoModelForCausalLM.from_pretrained(
BASE_MODEL_NAME,
torch_dtype=torch.float16,
device_map="auto"
)
# Load fine-tuned adapter
model = PeftModel.from_pretrained(model, FINE_TUNED_ADAPTER_PATH)
model = model.merge_and_unload() # Merge adapters for easier inference
# Option 2: Directly load the merged model if it was saved as a full model
# model = AutoModelForCausalLM.from_pretrained(
# MERGED_MODEL_PATH,
# torch_dtype=torch.float16,
# device_map="auto"
# )
tokenizer = AutoTokenizer.from_pretrained(BASE_MODEL_NAME)
tokenizer.pad_token = tokenizer.eos_token
tokenizer.padding_side = "right"
# Create a text generation pipeline
generator = pipeline(task="text-generation", model=model, tokenizer=tokenizer)
# Example usage
test_quote = "The only way to do great work is to love what you do."
formatted_prompt = f"""<s>[INST] <<SYS>>
You are an AI assistant that is an expert in writing inspiring quotes. Your task is to provide an inspiring quote for the user based on the given concept, followed by the author's name.
</SYS>>
{test_quote} [/INST]"""
result = generator(formatted_prompt, max_new_tokens=50, num_return_sequences=1)
generated_text = result[0]['generated_text']
print(f"Prompt: {test_quote}")
print(f"Generated Author: {generated_text.split('[/INST]')[-1].strip()}")
The model was fine-tuned on a subset of the Abirate/english_quotes dataset. This dataset contains English quotes paired with their respective authors. The data was preprocessed to fit the Llama 2 chat instruction format, ensuring the model learned to map a given quote (as an "instruction") to its author (as the "response"). Each training sample was formatted as:
<s>[INST] <<SYS>>{system_prompt}</SYS>>\n\n{quote} [/INST] {author}</s>
The model was fine-tuned using the QLoRA (Quantized Low-Rank Adaptation) method, a parameter-efficient fine-tuning technique.
The Abirate/english_quotes dataset was loaded and a custom format_instruction function was applied to transform each quote-author pair into the Llama 2 chat template. The dataset was then tokenized using the TinyLlama/TinyLlama-1.1B-Chat-v1.0 tokenizer, with truncation to max_seq_length=512 and right-padding. Labels were created by copying the input IDs. The dataset was split into 90% training and 10% evaluation sets.
use_reentrant=False0.05% of total parameters (specific number depends on exact model architecture).The model was evaluated on a 10% split of the Abirate/english_quotes dataset, which was held out from the training data. This validation set consists of tokenized quote-author pairs.
Evaluation was performed across the entire validation dataset. No specific subpopulations or sub-domains were isolated for disaggregated analysis.
The primary metric used for evaluation during training was:
During training, the eval_loss reached approximately 0.3576 at the end of the single epoch. This indicates the model learned effectively to predict the author given the quote in the specified format.
The fine-tuning process successfully adapted the TinyLlama model to the task of quote attribution, as evidenced by the low validation loss. The model demonstrates the ability to generate the correct author for quotes it was fine-tuned on, following the Llama 2 chat instruction template.
Carbon emissions can be estimated using the Machine Learning Impact calculator presented in Lacoste et al. (2019).
T4 or similar with ~14.57 GiB VRAM)The model is based on the TinyLlama-1.1B-Chat-v1.0 architecture, which is a decoder-only transformer model similar to Llama 2. Its objective was fine-tuned to perform causal language modeling, specifically predicting the author token sequence following a given quote within a chat-based instruction prompt. The QLoRA method efficiently adapts this architecture by injecting low-rank adapters without fully retraining all original parameters.
The fine-tuning was performed on a system equipped with an NVIDIA GPU having approximately 14.57 GiB of VRAM.
@misc{tinyllama_custom_quotes_fine_tuned,
author = {learn-abc},
title = {TinyLlama Custom Quotes Fine-Tune},
year = {2025},
publisher = {Hugging Face},
journal = {Hugging Face Hub},
howpublished = {\url{https://huggingface.co/learn-abc/tinyllama-custom-quotes}}
}
learn-abc. (2025). TinyLlama Custom Quotes Fine-Tune. Hugging Face. Retrieved from https://huggingface.co/learn-abc/tinyllama-custom-quotes
For any inquiries or support, please reach out to:
Framework versions PEFT 0.17.0