a-01a commited on
Commit
1c68f1c
·
verified ·
1 Parent(s): 3b9d6be

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +42 -169
README.md CHANGED
@@ -1,190 +1,63 @@
1
  ---
2
- language:
3
- - en
4
- license: llama3.2
5
- library_name: transformers
6
- base_model: meta-llama/Llama-3.2-1B-Instruct
7
  tags:
8
  - text-generation
9
- - llm
10
  - lora
11
  - peft
12
- - fine-tuned
13
- - creative-writing
14
  - literature
15
- - novel
16
- - storytelling
17
- - incremental-training
18
- pipeline_tag: text-generation
19
- widget:
20
- - text: Once upon a time, in a distant land,
21
- example_title: Story Beginning
22
- - text: 'Chapter 1: The Beginning
23
-
24
-
25
- '
26
- example_title: Chapter Start
27
- - text: The old house stood at the edge of the forest,
28
- example_title: Scene Setting
29
- datasets: []
30
- metrics: []
31
- model-index:
32
- - name: NovelCrafter
33
- results: []
34
  ---
35
 
36
- # Model Card: NovelCrafter Fine-Tuned Model
37
-
38
- ## Model Details
39
-
40
- ### Model Description
41
-
42
- This model is a fine-tuned version of Meta's Llama 3.2 (1B or 3B) using LoRA (Low-Rank Adaptation) on literary text. It has been trained incrementally on book content to capture writing style, narrative patterns, and literary conventions.
43
-
44
- - **Developed by**: [990aa](https://github.com/990aa)
45
- - **Model type**: Causal Language Model (CLM)
46
- - **Base Model**:
47
- - `meta-llama/Llama-3.2-1B-Instruct` (CPU training)
48
- - `meta-llama/Llama-3.2-3B-Instruct` (GPU training)
49
- - **Language(s)**: English (primarily)
50
- - **License**: MIT License (training code), Llama 3.2 License (base model)
51
- - **Finetuned from**: Meta Llama 3.2 Instruct
52
- - **Training Method**: LoRA (Parameter-Efficient Fine-Tuning)
53
 
54
- ## Uses
55
 
56
- ### Direct Use
57
-
58
- This model can be used for:
59
- - **Text Generation**: Generate text in the style of the training book
60
- - **Story Continuation**: Continue narratives with consistent style
61
- - **Creative Writing Assistance**: Help authors write in specific literary styles
62
- - **Literary Analysis**: Understand patterns in specific works
63
- - **Educational Purposes**: Learn about fine-tuning and literary AI
64
-
65
- ### Downstream Use
66
-
67
- Can be further fine-tuned on:
68
- - Additional literary works
69
- - Specific genres or authors
70
- - Creative writing tasks
71
- - Dialogue generation
72
- - Scene description
73
-
74
- ### Out-of-Scope Use
75
-
76
- This model should NOT be used for:
77
- - Medical, legal, or financial advice
78
- - Generating harmful, toxic, or biased content
79
- - Impersonating specific real individuals
80
- - Producing academic work without proper attribution
81
- - Any application requiring factual accuracy without verification
82
-
83
- ## Bias, Risks, and Limitations
84
 
85
- ### Known Limitations
 
 
 
 
86
 
87
- 1. **Training Data Bias**: The model reflects biases present in the training literature
88
- 2. **Factual Accuracy**: Not trained for factual tasks; may generate plausible but incorrect information
89
- 3. **Context Length**: Limited to the base model's context window (~8k tokens for Llama 3.2)
90
- 4. **Style Specificity**: Most effective for generating text similar to training material
91
- 5. **Language**: Primarily trained on English text
92
 
93
- ### Risks
 
 
 
94
 
95
- - **Copyright Concerns**: Generated text may inadvertently reproduce training data
96
- - **Harmful Content**: Despite instruction tuning, may generate inappropriate content
97
- - **Over-reliance**: Users should not rely solely on model outputs for critical decisions
98
- - **Hallucination**: May generate confident but false information
99
 
100
- ## Training Details
101
 
102
- #### Training Hyperparameters
103
 
104
- **LoRA Configuration:**
105
  ```python
106
- rank (r) = 8
107
- lora_alpha = 32
108
- lora_dropout = 0.05
109
- target_modules = ["q_proj", "v_proj"]
110
- bias = "none"
111
- task_type = "CAUSAL_LM"
 
 
 
 
 
 
 
 
 
 
 
 
 
112
  ```
113
 
114
- **Training Arguments:**
115
- ```python
116
- num_train_epochs = 3 (per part)
117
- per_device_train_batch_size = 1
118
- gradient_accumulation_steps = 8
119
- learning_rate = 5e-5
120
- weight_decay = 0.01
121
- warmup_steps = 100 (adjusted per part)
122
- fp16 = True (GPU only)
123
- optimizer = AdamW
124
- lr_scheduler = Linear with warmup
125
- ```
126
-
127
- #### Training Process
128
-
129
- 1. **Text Extraction**: PDF → plain text
130
- 2. **Chunking**: Split into 10 parts for incremental training
131
- 3. **Tokenization**: Llama tokenizer with max_length=1024
132
- 4. **LoRA Application**: Add trainable adapters to base model
133
- 5. **Incremental Training**: Train on each part sequentially
134
- 6. **Checkpoint Saving**: Save after each part
135
- 7. **Hub Upload**: Push to Hugging Face after each part
136
-
137
- **Trainable Parameters:**
138
- - Total parameters: ~1.2B (1B model) or ~3.2B (3B model)
139
- - Trainable parameters: ~2.3M (0.07% of total)
140
- - LoRA enables efficient training with minimal memory
141
-
142
- #### Compute Infrastructure
143
-
144
- **Hardware:**
145
- - CPU training: Any modern CPU with 8GB+ RAM
146
- - GPU training: NVIDIA GPU with 8GB+ VRAM recommended
147
- - Tested on: Consumer-grade hardware
148
-
149
- **Training Time:**
150
- - CPU (1B model): ~2-4 hours per part (30-40 hours total)
151
- - GPU (3B model): ~15-30 minutes per part (3-5 hours total)
152
-
153
- ## Evaluation
154
-
155
- ### Testing Data
156
-
157
- - 10% of each training part held out for evaluation
158
- - Evaluated using perplexity on held-out test set
159
- - Real-time evaluation during training
160
-
161
- ### Metrics
162
-
163
- - **Training Loss**: Cross-entropy loss on training data
164
- - **Validation Loss**: Cross-entropy loss on test data
165
- - **Perplexity**: exp(validation_loss)
166
-
167
- ## Technical Specifications
168
-
169
- ### Model Architecture
170
-
171
- - **Base Architecture**: Llama 3.2 (Transformer decoder)
172
- - **Attention Type**: Multi-head attention with GQA
173
- - **Hidden Size**: 2048 (1B) or 3072 (3B)
174
- - **Num Layers**: 16 (1B) or 28 (3B)
175
- - **Num Attention Heads**: 32
176
- - **Vocabulary Size**: 128,256
177
- - **Position Embeddings**: RoPE (Rotary Position Embedding)
178
-
179
- ### Fine-Tuning Method
180
-
181
- **LoRA (Low-Rank Adaptation):**
182
- - Adds trainable low-rank matrices to attention layers
183
- - Freezes original model weights
184
- - Reduces memory and compute requirements
185
- - Enables efficient multi-task learning
186
- ---
187
 
188
- **Model Card Author**: 990aa
189
- **Model Card Date**: October 2025
190
- **Model Card Version**: 1.0.0
 
1
  ---
2
+ license: mit
3
+ base_model: meta-llama/Llama-3.2-3B-Instruct
 
 
 
4
  tags:
5
  - text-generation
 
6
  - lora
7
  - peft
 
 
8
  - literature
9
+ - creative-writing
10
+ - dostoevsky
11
+ library_name: peft
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  ---
13
 
14
+ # NovelCrafter - Literary LLM
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
 
16
+ This is a LoRA adapter fine-tuned on literary works using instruction-response pairs.
17
 
18
+ ## Model Details
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
 
20
+ - **Base Model**: meta-llama/Llama-3.2-3B-Instruct (GPU) / Llama-3.2-1B-Instruct (CPU)
21
+ - **Training Method**: LoRA (Low-Rank Adaptation)
22
+ - **LoRA Rank**: 8
23
+ - **LoRA Alpha**: 32
24
+ - **Target Modules**: q_proj, v_proj
25
 
26
+ ## Training Data
 
 
 
 
27
 
28
+ The model was trained incrementally on literary works in JSON format with:
29
+ - `previous_chapter`: Context from previous chapter (optional)
30
+ - `instruction`: Writing prompt
31
+ - `response`: Expected literary output
32
 
33
+ ### Completed Training Files
 
 
 
34
 
35
+ - dream_of_ridiculous_man1.json
36
 
37
+ ## Usage
38
 
 
39
  ```python
40
+ from peft import PeftModel
41
+ from transformers import AutoModelForCausalLM, AutoTokenizer
42
+
43
+ base_model = "meta-llama/Llama-3.2-3B-Instruct"
44
+ adapter = "a-01a/novelCrafter"
45
+
46
+ model = AutoModelForCausalLM.from_pretrained(base_model)
47
+ model = PeftModel.from_pretrained(model, adapter)
48
+ tokenizer = AutoTokenizer.from_pretrained(adapter)
49
+
50
+ # Generate text
51
+ messages = [
52
+ {"role": "system", "content": "You are a creative writing assistant."},
53
+ {"role": "user", "content": "Write a chapter about..."}
54
+ ]
55
+ prompt = tokenizer.apply_chat_template(messages, tokenize=False)
56
+ inputs = tokenizer(prompt, return_tensors="pt")
57
+ outputs = model.generate(**inputs, max_new_tokens=500)
58
+ print(tokenizer.decode(outputs[0]))
59
  ```
60
 
61
+ ## License
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
 
63
+ MIT License