Downloads · 30 days
7
5% of all-time downloads
cahlen/tinyllama-offline-practical-skills-qa-qlora
tinyllama-offline-practical-skills-qa-qlora is a question answering model from cahlen. Use it when the input is a question plus a passage. It is set up for peft. The card lists the license as apache-2.0.
Downloads · 30 days
7
5% of all-time downloads
All-time downloads
143
Public
Repo size
4 GB
Likes
1
Public
Click a slice to open those files.
.safetensors202 MB · 98%
From the Hugging Face model README
Adapter created by: Cahlen Humphreys
This repository contains a LoRA (Low-Rank Adaptation) adapter fine-tuned for Question Answering on practical knowledge topics (e.g., survival, first aid, basic maintenance), using the TinyLlama/TinyLlama-1.1B-Chat-v1.0 base model. The goal is to provide helpful information potentially useful in offline or edge AI scenarios.
This adapter was trained using QLoRA (Quantized Low-Rank Adaptation), allowing efficient fine-tuning on consumer hardware.
Note: This adapter was created as part of a tutorial demonstrating QLoRA fine-tuning. It is intended for educational and demonstrative purposes.
TinyLlama/TinyLlama-1.1B-Chat-v1.0peft library.nf4 quantization of the base model via bitsandbytes, training only the added LoRA weights).Intended Use:
Limitations:
You can load the base model and apply this LoRA adapter using the transformers and peft libraries.
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
# Define paths (replace with your Hub repo ID if uploaded)
base_model_name = "TinyLlama/TinyLlama-1.1B-Chat-v1.0"
adapter_path = "path/to/your/results_tinyllama_adapter" # Or Hub ID like "YourUsername/YourRepoName"
# Load the base model (quantized, as used during training)
# Ensure you have bitsandbytes installed
base_model = AutoModelForCausalLM.from_pretrained(
base_model_name,
load_in_4bit=True,
torch_dtype=torch.float16, # Or torch.bfloat16 if supported
device_map="auto",
)
# Load the tokenizer
tokenizer = AutoTokenizer.from_pretrained(base_model_name)
if tokenizer.pad_token is None:
tokenizer.pad_token = tokenizer.eos_token
# Load the LoRA adapter
model = PeftModel.from_pretrained(base_model, adapter_path)
# --- Now you can use the 'model' for inference ---
# Example: Prepare prompt (adapt based on training format)
topic = "Wilderness Survival Basics"
question = "How do you signal for help using a mirror?"
system_prompt = f"You are a helpful assistant knowledgeable about {topic}."
messages = [
{"role": "system", "content": system_prompt},
{"role": "user", "content": f"Question: {question}"}
]
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
# Generate
with torch.no_grad():
outputs = model.generate(
**inputs,
max_new_tokens=100,
temperature=0.6,
do_sample=True,
pad_token_id=tokenizer.eos_token_id
)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
# Post-process response to extract answer if needed (logic depends on template)
print(response)
src/train.py (from accompanying repository)data/final_qa_unique.jsonl (~2845 examples)Qualitative testing was performed by comparing the adapter's responses to the base model's responses on questions from the training domains.
Findings:
Overall, the adapter shows clear specialization towards the trained QA domains, but its accuracy is tied to the underlying training data.
This LoRA adapter is provided strictly for educational and research demonstration purposes. It was trained on synthetically generated data and has not undergone rigorous safety testing or evaluation for production use. The creator, Cahlen Humphreys, assumes no responsibility or liability for any consequences, damages, or issues arising from the use, interpretation, or application of this model adapter. This includes, but is not limited to, use in production systems, decision-making processes, safety-critical applications, or any situation where incorrect information could cause harm. Use this adapter entirely at your own risk and be aware of potential inaccuracies or biases inherited from the base model and the unverified synthetic training data.