Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
datasets:
|
| 4 |
+
- Fu01978/ao3_chat
|
| 5 |
+
language:
|
| 6 |
+
- en
|
| 7 |
+
base_model:
|
| 8 |
+
- HuggingFaceTB/SmolLM2-135M-Instruct
|
| 9 |
+
pipeline_tag: text-generation
|
| 10 |
+
library_name: transformers
|
| 11 |
+
tags:
|
| 12 |
+
- creative-writing
|
| 13 |
+
- roleplay
|
| 14 |
+
- smollm
|
| 15 |
+
- ao3
|
| 16 |
+
---
|
| 17 |
+
|
| 18 |
+
# SmolLM2-135M-Instruct-AO3
|
| 19 |
+
|
| 20 |
+
This model is a fine-tuned version of [HuggingFaceTB/SmolLM2-135M-Instruct](https://huggingface.co/HuggingFaceTB/SmolLM2-135M-Instruct) trained on the [Fu01978/ao3_chat](https://huggingface.co/datasets/Fu01978/ao3_chat) dataset.
|
| 21 |
+
|
| 22 |
+
It is designed to blend the instruction-following capabilities of SmolLM2 with the descriptive, narrative, and atmospheric prose styles commonly found in creative writing communities.
|
| 23 |
+
|
| 24 |
+
## Model Description
|
| 25 |
+
- **Model type:** Causal Language Model (Fine-tuned)
|
| 26 |
+
- **Language(s) (NLP):** English
|
| 27 |
+
- **License:** Apache 2.0
|
| 28 |
+
- **Finetuned from model:** [HuggingFaceTB/SmolLM2-135M-Instruct](https://huggingface.co/HuggingFaceTB/SmolLM2-135M-Instruct)
|
| 29 |
+
|
| 30 |
+
## Training Details
|
| 31 |
+
The model was fine-tuned for a short duration to "infuse" the base model with narrative flair without completely overwriting its general knowledge.
|
| 32 |
+
|
| 33 |
+
### Training Hyperparameters
|
| 34 |
+
* **Steps:** 75
|
| 35 |
+
* **Learning Rate:** 5e-4
|
| 36 |
+
* **Batch Size:** 8
|
| 37 |
+
* **Gradient Accumulation Steps:** 2
|
| 38 |
+
* **LR Scheduler Type:** linear
|
| 39 |
+
* **Precision:** FP32 (Full Precision)
|
| 40 |
+
|
| 41 |
+
### Loss Curve
|
| 42 |
+
The model showed a rapid descent in the first 20 steps, eventually stabilizing around a loss of **2.5-2.6**.
|
| 43 |
+
|
| 44 |
+
| Step | Training Loss |
|
| 45 |
+
| :--- | :--- |
|
| 46 |
+
| 5 | 3.572342 |
|
| 47 |
+
| 15 | 2.720610 |
|
| 48 |
+
| 30 | 2.497861 |
|
| 49 |
+
| 45 | 2.626326 |
|
| 50 |
+
| 60 | 2.708193 |
|
| 51 |
+
| 75 | 2.637797 |
|
| 52 |
+
|
| 53 |
+
## Usage
|
| 54 |
+
This model uses the **ChatML** template. It is recommended to use the `apply_chat_template` method for best results.
|
| 55 |
+
|
| 56 |
+
```python
|
| 57 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 58 |
+
import torch
|
| 59 |
+
|
| 60 |
+
model_id = "Fu01978/SmolLM2-135M-Instruct-AO3"
|
| 61 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 62 |
+
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.float32, device_map="auto")
|
| 63 |
+
|
| 64 |
+
messages = [
|
| 65 |
+
{"role": "system", "content": "You are a creative writing assistant."},
|
| 66 |
+
{"role": "user", "content": "Write a scene about a rainy library."},
|
| 67 |
+
]
|
| 68 |
+
|
| 69 |
+
inputs = tokenizer.apply_chat_template(messages, tokenize=True, add_generation_prompt=True, return_tensors="pt").to(model.device)
|
| 70 |
+
outputs = model.generate(**inputs, max_new_tokens=150, do_sample=True, temperature=0.7)
|
| 71 |
+
print(tokenizer.decode(outputs[0][len(inputs[0]):], skip_special_tokens=True))
|
| 72 |
+
```
|
| 73 |
+
|
| 74 |
+
## Intended Use & Limitations
|
| 75 |
+
* **Roleplay & Fiction:** Best suited for creative prompts and stylistic prose.
|
| 76 |
+
* **Domain Shift:** While it retains general knowledge, its explanations (e.g., science) may adopt a more narrative or "story-like" tone.
|