Upload folder using huggingface_hub
Browse files- README.md +48 -94
- model.safetensors +1 -1
- tokenizer.json +6 -1
- tokenizer_config.json +4 -0
README.md
CHANGED
|
@@ -1,125 +1,79 @@
|
|
| 1 |
---
|
| 2 |
-
base_model: TinyLlama/TinyLlama-1.1B-Chat-v1.0
|
| 3 |
-
library_name: peft
|
| 4 |
-
pipeline_tag: text-generation
|
| 5 |
license: mit
|
| 6 |
language:
|
| 7 |
-
- en
|
|
|
|
| 8 |
tags:
|
| 9 |
-
-
|
| 10 |
-
-
|
| 11 |
-
-
|
| 12 |
-
-
|
| 13 |
-
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
---
|
| 17 |
|
| 18 |
-
# TinyLlama Shakespeare
|
| 19 |
-
|
| 20 |
-
A fine-tuned version of [TinyLlama-1.1B-Chat](https://huggingface.co/TinyLlama/TinyLlama-1.1B-Chat-v1.0) trained on Shakespeare's complete works to generate Shakespearean-style text.
|
| 21 |
|
| 22 |
-
|
| 23 |
|
| 24 |
-
|
| 25 |
-
- **Fine-tuning Method:** LoRA (Low-Rank Adaptation)
|
| 26 |
-
- **Quantization:** 4-bit (NF4) via bitsandbytes
|
| 27 |
-
- **Developed by:** [Akash Nath](https://github.com/Akash-nath29)
|
| 28 |
-
- **License:** MIT
|
| 29 |
-
- **Language:** English
|
| 30 |
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
### Training Data
|
| 34 |
-
The model was fine-tuned on Shakespeare's complete works including sonnets, plays, and poems (~42,000 lines of text).
|
| 35 |
|
| 36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
-
|
| 39 |
-
|-----------|-------|
|
| 40 |
-
| LoRA Rank (r) | 16 |
|
| 41 |
-
| LoRA Alpha | 32 |
|
| 42 |
-
| Target Modules | q_proj, v_proj |
|
| 43 |
-
| LoRA Dropout | 0.05 |
|
| 44 |
-
| Batch Size | 2 |
|
| 45 |
-
| Gradient Accumulation | 4 |
|
| 46 |
-
| Learning Rate | 2e-4 |
|
| 47 |
-
| Epochs | 2 |
|
| 48 |
-
| Precision | FP16 |
|
| 49 |
-
| Max Sequence Length | 256 |
|
| 50 |
-
|
| 51 |
-
### Hardware
|
| 52 |
-
- **GPU:** NVIDIA GeForce RTX 3050 Laptop GPU
|
| 53 |
-
- **Training Time:** ~4 hours
|
| 54 |
|
| 55 |
## Usage
|
| 56 |
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
```python
|
| 60 |
-
from peft import PeftModel
|
| 61 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
|
|
| 62 |
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
load_in_4bit=True,
|
| 67 |
device_map="auto"
|
| 68 |
)
|
| 69 |
-
tokenizer = AutoTokenizer.from_pretrained("
|
| 70 |
-
|
| 71 |
-
# Load LoRA adapters
|
| 72 |
-
model = PeftModel.from_pretrained(base_model, "Akash-nath29/tinyllamashakespeare")
|
| 73 |
|
| 74 |
# Generate text
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
```
|
| 80 |
-
|
| 81 |
-
### Using the Training Repository
|
| 82 |
|
| 83 |
-
|
| 84 |
-
git clone https://github.com/Akash-nath29/TinyLlamaShakespeare
|
| 85 |
-
cd TinyLlamaShakespeare
|
| 86 |
-
pip install -r requirements.txt
|
| 87 |
-
|
| 88 |
-
# Run inference
|
| 89 |
-
python scripts/inference.py --model_path Akash-nath29/tinyllamashakespeare --prompt "Shall I compare thee"
|
| 90 |
-
```
|
| 91 |
|
| 92 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
|
| 94 |
-
|
| 95 |
|
| 96 |
-
|
|
|
|
| 97 |
|
| 98 |
-
##
|
| 99 |
|
| 100 |
-
|
| 101 |
-
- Output quality varies based on prompts and generation parameters
|
| 102 |
-
- The model inherits biases present in the base TinyLlama model and Shakespeare's original texts
|
| 103 |
|
| 104 |
## Repository
|
| 105 |
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
## Citation
|
| 109 |
-
|
| 110 |
-
```bibtex
|
| 111 |
-
@misc{tinyllamashakespeare,
|
| 112 |
-
author = {Akash Nath},
|
| 113 |
-
title = {TinyLlama Shakespeare: Fine-tuned TinyLlama on Shakespeare's Works},
|
| 114 |
-
year = {2025},
|
| 115 |
-
publisher = {HuggingFace},
|
| 116 |
-
url = {https://huggingface.co/Akash-nath29/tinyllamashakespeare}
|
| 117 |
-
}
|
| 118 |
-
```
|
| 119 |
|
| 120 |
-
##
|
| 121 |
|
| 122 |
-
|
| 123 |
-
- Transformers 4.x
|
| 124 |
-
- PyTorch 2.6.0+cu124
|
| 125 |
-
- bitsandbytes 0.41+
|
|
|
|
| 1 |
---
|
|
|
|
|
|
|
|
|
|
| 2 |
license: mit
|
| 3 |
language:
|
| 4 |
+
- en
|
| 5 |
+
library_name: transformers
|
| 6 |
tags:
|
| 7 |
+
- shakespeare
|
| 8 |
+
- chatbot
|
| 9 |
+
- tinyllama
|
| 10 |
+
- fine-tuned
|
| 11 |
+
- conversational
|
| 12 |
+
base_model: TinyLlama/TinyLlama-1.1B-Chat-v1.0
|
| 13 |
+
pipeline_tag: text-generation
|
| 14 |
---
|
| 15 |
|
| 16 |
+
# TinyLlama Shakespeare Chatbot
|
|
|
|
|
|
|
| 17 |
|
| 18 |
+
A conversational AI that speaks in authentic Shakespearean English.
|
| 19 |
|
| 20 |
+
## Model Description
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
+
Fine-tuned on Shakespeare's complete works (42,000+ lines) transformed into 8,000+ chat-style training examples.
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
+
**Capabilities:**
|
| 25 |
+
- Compose sonnets on any topic
|
| 26 |
+
- Engage in dramatic dialogue
|
| 27 |
+
- Respond in Shakespearean style
|
| 28 |
+
- Generate poetry and monologues
|
| 29 |
|
| 30 |
+
**This is a MERGED model** - works directly with transformers, no PEFT needed!
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
## Usage
|
| 33 |
|
| 34 |
+
`python
|
|
|
|
|
|
|
|
|
|
| 35 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 36 |
+
import torch
|
| 37 |
|
| 38 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 39 |
+
"Akash-nath29/tinyllamashakespeare",
|
| 40 |
+
torch_dtype=torch.float16,
|
|
|
|
| 41 |
device_map="auto"
|
| 42 |
)
|
| 43 |
+
tokenizer = AutoTokenizer.from_pretrained("Akash-nath29/tinyllamashakespeare")
|
|
|
|
|
|
|
|
|
|
| 44 |
|
| 45 |
# Generate text
|
| 46 |
+
inputs = tokenizer("To be or not to be", return_tensors="pt")
|
| 47 |
+
outputs = model.generate(**inputs, max_length=200)
|
| 48 |
+
print(tokenizer.decode(outputs[0]))
|
| 49 |
+
`
|
|
|
|
|
|
|
|
|
|
| 50 |
|
| 51 |
+
## Training Details
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
|
| 53 |
+
| Parameter | Value |
|
| 54 |
+
|-----------|-------|
|
| 55 |
+
| Base Model | TinyLlama-1.1B-Chat-v1.0 |
|
| 56 |
+
| Method | LoRA + QLoRA (4-bit) |
|
| 57 |
+
| LoRA Rank | 16 |
|
| 58 |
+
| LoRA Alpha | 32 |
|
| 59 |
+
| Target Modules | q_proj, k_proj, v_proj, o_proj |
|
| 60 |
+
| Training Examples | 8,000+ conversations |
|
| 61 |
+
| Max Length | 512 tokens |
|
| 62 |
+
| Epochs | 3 |
|
| 63 |
|
| 64 |
+
## Hardware
|
| 65 |
|
| 66 |
+
- GPU: NVIDIA GeForce RTX 3050 Laptop GPU
|
| 67 |
+
- Training Time: ~4 hours
|
| 68 |
|
| 69 |
+
## Developed By
|
| 70 |
|
| 71 |
+
[Akash Nath](https://github.com/Akash-nath29)
|
|
|
|
|
|
|
| 72 |
|
| 73 |
## Repository
|
| 74 |
|
| 75 |
+
[GitHub - TinyLlamaShakespeare](https://github.com/Akash-nath29/TinyLlamaShakespeare)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
|
| 77 |
+
## License
|
| 78 |
|
| 79 |
+
MIT License
|
|
|
|
|
|
|
|
|
model.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 2200119664
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b5a2901f9122c729b2f34c9fbef1cdb01c93312b167080827e1b08d97107ffa7
|
| 3 |
size 2200119664
|
tokenizer.json
CHANGED
|
@@ -1,6 +1,11 @@
|
|
| 1 |
{
|
| 2 |
"version": "1.0",
|
| 3 |
-
"truncation":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
"padding": null,
|
| 5 |
"added_tokens": [
|
| 6 |
{
|
|
|
|
| 1 |
{
|
| 2 |
"version": "1.0",
|
| 3 |
+
"truncation": {
|
| 4 |
+
"direction": "Right",
|
| 5 |
+
"max_length": 512,
|
| 6 |
+
"strategy": "LongestFirst",
|
| 7 |
+
"stride": 0
|
| 8 |
+
},
|
| 9 |
"padding": null,
|
| 10 |
"added_tokens": [
|
| 11 |
{
|
tokenizer_config.json
CHANGED
|
@@ -33,11 +33,15 @@
|
|
| 33 |
"eos_token": "</s>",
|
| 34 |
"extra_special_tokens": {},
|
| 35 |
"legacy": false,
|
|
|
|
| 36 |
"model_max_length": 2048,
|
| 37 |
"pad_token": "</s>",
|
| 38 |
"padding_side": "right",
|
| 39 |
"sp_model_kwargs": {},
|
|
|
|
| 40 |
"tokenizer_class": "LlamaTokenizer",
|
|
|
|
|
|
|
| 41 |
"unk_token": "<unk>",
|
| 42 |
"use_default_system_prompt": false
|
| 43 |
}
|
|
|
|
| 33 |
"eos_token": "</s>",
|
| 34 |
"extra_special_tokens": {},
|
| 35 |
"legacy": false,
|
| 36 |
+
"max_length": 512,
|
| 37 |
"model_max_length": 2048,
|
| 38 |
"pad_token": "</s>",
|
| 39 |
"padding_side": "right",
|
| 40 |
"sp_model_kwargs": {},
|
| 41 |
+
"stride": 0,
|
| 42 |
"tokenizer_class": "LlamaTokenizer",
|
| 43 |
+
"truncation_side": "right",
|
| 44 |
+
"truncation_strategy": "longest_first",
|
| 45 |
"unk_token": "<unk>",
|
| 46 |
"use_default_system_prompt": false
|
| 47 |
}
|