a-01a commited on
Commit
a95cdff
·
verified ·
1 Parent(s): d27a409

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +191 -136
README.md CHANGED
@@ -1,199 +1,254 @@
1
  ---
 
 
 
2
  library_name: transformers
3
- tags: []
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  ---
5
 
6
- # Model Card for Model ID
7
-
8
- <!-- Provide a quick summary of what the model is/does. -->
9
-
10
-
11
 
12
  ## Model Details
13
 
14
  ### Model Description
15
 
16
- <!-- Provide a longer summary of what this model is. -->
17
-
18
- This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
19
 
20
- - **Developed by:** [More Information Needed]
21
- - **Funded by [optional]:** [More Information Needed]
22
- - **Shared by [optional]:** [More Information Needed]
23
- - **Model type:** [More Information Needed]
24
- - **Language(s) (NLP):** [More Information Needed]
25
- - **License:** [More Information Needed]
26
- - **Finetuned from model [optional]:** [More Information Needed]
 
 
27
 
28
- ### Model Sources [optional]
29
 
30
- <!-- Provide the basic links for the model. -->
31
-
32
- - **Repository:** [More Information Needed]
33
- - **Paper [optional]:** [More Information Needed]
34
- - **Demo [optional]:** [More Information Needed]
35
 
36
  ## Uses
37
 
38
- <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
39
-
40
  ### Direct Use
41
 
42
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
43
-
44
- [More Information Needed]
 
 
 
45
 
46
- ### Downstream Use [optional]
47
 
48
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
49
-
50
- [More Information Needed]
 
 
 
51
 
52
  ### Out-of-Scope Use
53
 
54
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
55
-
56
- [More Information Needed]
 
 
 
57
 
58
  ## Bias, Risks, and Limitations
59
 
60
- <!-- This section is meant to convey both technical and sociotechnical limitations. -->
61
-
62
- [More Information Needed]
63
 
64
- ### Recommendations
65
-
66
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
 
 
67
 
68
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
69
 
70
- ## How to Get Started with the Model
 
 
 
71
 
72
- Use the code below to get started with the model.
73
 
74
- [More Information Needed]
 
 
 
 
 
75
 
76
  ## Training Details
77
 
78
  ### Training Data
79
 
80
- <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
81
-
82
- [More Information Needed]
 
 
 
 
83
 
84
  ### Training Procedure
85
 
86
- <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
87
-
88
- #### Preprocessing [optional]
89
-
90
- [More Information Needed]
91
-
92
-
93
  #### Training Hyperparameters
94
 
95
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
96
-
97
- #### Speeds, Sizes, Times [optional]
98
-
99
- <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
100
-
101
- [More Information Needed]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
 
103
  ## Evaluation
104
 
105
- <!-- This section describes the evaluation protocols and provides the results. -->
106
-
107
- ### Testing Data, Factors & Metrics
108
-
109
- #### Testing Data
110
-
111
- <!-- This should link to a Dataset Card if possible. -->
112
-
113
- [More Information Needed]
114
-
115
- #### Factors
116
 
117
- <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
 
 
118
 
119
- [More Information Needed]
120
 
121
- #### Metrics
 
 
122
 
123
- <!-- These are the evaluation metrics being used, ideally with a description of why. -->
124
-
125
- [More Information Needed]
126
-
127
- ### Results
128
-
129
- [More Information Needed]
130
-
131
- #### Summary
132
-
133
-
134
-
135
- ## Model Examination [optional]
136
-
137
- <!-- Relevant interpretability work for the model goes here -->
138
-
139
- [More Information Needed]
140
 
141
  ## Environmental Impact
142
 
143
- <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
144
-
145
- Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
146
-
147
- - **Hardware Type:** [More Information Needed]
148
- - **Hours used:** [More Information Needed]
149
- - **Cloud Provider:** [More Information Needed]
150
- - **Compute Region:** [More Information Needed]
151
- - **Carbon Emitted:** [More Information Needed]
152
-
153
- ## Technical Specifications [optional]
154
-
155
- ### Model Architecture and Objective
156
 
157
- [More Information Needed]
 
 
 
 
158
 
159
- ### Compute Infrastructure
160
 
161
- [More Information Needed]
162
 
163
- #### Hardware
 
 
 
 
 
 
164
 
165
- [More Information Needed]
166
 
167
- #### Software
 
 
 
 
168
 
169
- [More Information Needed]
170
 
171
- ## Citation [optional]
172
-
173
- <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
174
-
175
- **BibTeX:**
176
-
177
- [More Information Needed]
178
-
179
- **APA:**
180
-
181
- [More Information Needed]
182
-
183
- ## Glossary [optional]
184
-
185
- <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
186
-
187
- [More Information Needed]
188
-
189
- ## More Information [optional]
190
 
191
- [More Information Needed]
 
 
192
 
193
- ## Model Card Authors [optional]
194
 
195
- [More Information Needed]
 
 
 
 
 
196
 
197
- ## Model Card Contact
198
 
199
- [More Information Needed]
 
 
 
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\n\n"
23
+ example_title: "Chapter Start"
24
+ - text: "The old house stood at the edge of the forest,"
25
+ example_title: "Scene Setting"
26
+ model-index:
27
+ - name: NovelCrafter
28
+ results: []
29
+ datasets: []
30
+ metrics: []
31
  ---
32
 
33
+ # Model Card: NovelCrafter Fine-Tuned Model
 
 
 
 
34
 
35
  ## Model Details
36
 
37
  ### Model Description
38
 
39
+ 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.
 
 
40
 
41
+ - **Developed by**: [990aa](https://github.com/990aa)
42
+ - **Model type**: Causal Language Model (CLM)
43
+ - **Base Model**:
44
+ - `meta-llama/Llama-3.2-1B-Instruct` (CPU training)
45
+ - `meta-llama/Llama-3.2-3B-Instruct` (GPU training)
46
+ - **Language(s)**: English (primarily)
47
+ - **License**: MIT License (training code), Llama 3.2 License (base model)
48
+ - **Finetuned from**: Meta Llama 3.2 Instruct
49
+ - **Training Method**: LoRA (Parameter-Efficient Fine-Tuning)
50
 
51
+ ### Model Sources
52
 
53
+ - **Repository**: [https://github.com/990aa/novelCrafter](https://github.com/990aa/novelCrafter)
54
+ - **Model Hub**: [https://huggingface.co/a-01a/novelCrafter](https://huggingface.co/a-01a/novelCrafter)
 
 
 
55
 
56
  ## Uses
57
 
 
 
58
  ### Direct Use
59
 
60
+ This model can be used for:
61
+ - **Text Generation**: Generate text in the style of the training book
62
+ - **Story Continuation**: Continue narratives with consistent style
63
+ - **Creative Writing Assistance**: Help authors write in specific literary styles
64
+ - **Literary Analysis**: Understand patterns in specific works
65
+ - **Educational Purposes**: Learn about fine-tuning and literary AI
66
 
67
+ ### Downstream Use
68
 
69
+ Can be further fine-tuned on:
70
+ - Additional literary works
71
+ - Specific genres or authors
72
+ - Creative writing tasks
73
+ - Dialogue generation
74
+ - Scene description
75
 
76
  ### Out-of-Scope Use
77
 
78
+ This model should NOT be used for:
79
+ - Medical, legal, or financial advice
80
+ - Generating harmful, toxic, or biased content
81
+ - Impersonating specific real individuals
82
+ - Producing academic work without proper attribution
83
+ - Any application requiring factual accuracy without verification
84
 
85
  ## Bias, Risks, and Limitations
86
 
87
+ ### Known Limitations
 
 
88
 
89
+ 1. **Training Data Bias**: The model reflects biases present in the training literature
90
+ 2. **Factual Accuracy**: Not trained for factual tasks; may generate plausible but incorrect information
91
+ 3. **Context Length**: Limited to the base model's context window (~8k tokens for Llama 3.2)
92
+ 4. **Style Specificity**: Most effective for generating text similar to training material
93
+ 5. **Language**: Primarily trained on English text
94
 
95
+ ### Risks
96
 
97
+ - **Copyright Concerns**: Generated text may inadvertently reproduce training data
98
+ - **Harmful Content**: Despite instruction tuning, may generate inappropriate content
99
+ - **Over-reliance**: Users should not rely solely on model outputs for critical decisions
100
+ - **Hallucination**: May generate confident but false information
101
 
102
+ ### Recommendations
103
 
104
+ Users should:
105
+ - Review and edit all generated content
106
+ - Add appropriate disclaimers for AI-generated text
107
+ - Not use for high-stakes decisions without human oversight
108
+ - Be aware of potential copyright issues
109
+ - Test thoroughly for their specific use case
110
 
111
  ## Training Details
112
 
113
  ### Training Data
114
 
115
+ - **Source**: PDF book(s) placed in `input/` directory
116
+ - **Preprocessing**:
117
+ - Text extracted from PDF
118
+ - Cleaned and normalized (whitespace, newlines)
119
+ - Split into sentence chunks (10 sentences per chunk by default)
120
+ - Tokenized with Llama tokenizer
121
+ - 90/10 train/test split per training part
122
 
123
  ### Training Procedure
124
 
 
 
 
 
 
 
 
125
  #### Training Hyperparameters
126
 
127
+ **LoRA Configuration:**
128
+ ```python
129
+ rank (r) = 8
130
+ lora_alpha = 32
131
+ lora_dropout = 0.05
132
+ target_modules = ["q_proj", "v_proj"]
133
+ bias = "none"
134
+ task_type = "CAUSAL_LM"
135
+ ```
136
+
137
+ **Training Arguments:**
138
+ ```python
139
+ num_train_epochs = 3 (per part)
140
+ per_device_train_batch_size = 1
141
+ gradient_accumulation_steps = 8
142
+ learning_rate = 5e-5
143
+ weight_decay = 0.01
144
+ warmup_steps = 100 (adjusted per part)
145
+ fp16 = True (GPU only)
146
+ optimizer = AdamW
147
+ lr_scheduler = Linear with warmup
148
+ ```
149
+
150
+ #### Training Process
151
+
152
+ 1. **Text Extraction**: PDF → plain text
153
+ 2. **Chunking**: Split into 10 parts for incremental training
154
+ 3. **Tokenization**: Llama tokenizer with max_length=1024
155
+ 4. **LoRA Application**: Add trainable adapters to base model
156
+ 5. **Incremental Training**: Train on each part sequentially
157
+ 6. **Checkpoint Saving**: Save after each part
158
+ 7. **Hub Upload**: Push to Hugging Face after each part
159
+
160
+ **Trainable Parameters:**
161
+ - Total parameters: ~1.2B (1B model) or ~3.2B (3B model)
162
+ - Trainable parameters: ~2.3M (0.07% of total)
163
+ - LoRA enables efficient training with minimal memory
164
+
165
+ #### Compute Infrastructure
166
+
167
+ **Hardware:**
168
+ - CPU training: Any modern CPU with 8GB+ RAM
169
+ - GPU training: NVIDIA GPU with 8GB+ VRAM recommended
170
+ - Tested on: Consumer-grade hardware
171
+
172
+ **Software:**
173
+ ```
174
+ Python 3.8+
175
+ PyTorch 2.0+
176
+ Transformers 4.56+
177
+ PEFT 0.17+
178
+ ```
179
+
180
+ **Training Time:**
181
+ - CPU (1B model): ~2-4 hours per part (30-40 hours total)
182
+ - GPU (3B model): ~15-30 minutes per part (3-5 hours total)
183
 
184
  ## Evaluation
185
 
186
+ ### Testing Data
 
 
 
 
 
 
 
 
 
 
187
 
188
+ - 10% of each training part held out for evaluation
189
+ - Evaluated using perplexity on held-out test set
190
+ - Real-time evaluation during training
191
 
192
+ ### Metrics
193
 
194
+ - **Training Loss**: Cross-entropy loss on training data
195
+ - **Validation Loss**: Cross-entropy loss on test data
196
+ - **Perplexity**: exp(validation_loss)
197
 
198
+ Note: Specific metrics depend on the training run and can be viewed in WandB logs or training outputs.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
199
 
200
  ## Environmental Impact
201
 
202
+ - **Hardware Type**: CPU or GPU (varies by user)
203
+ - **Hours Used**: 3-40 hours (depending on hardware)
204
+ - **Cloud Provider**: N/A (local training)
205
+ - **Compute Region**: User-dependent
206
+ - **Carbon Emitted**: Varies by location and power source
 
 
 
 
 
 
 
 
207
 
208
+ I encourage users to:
209
+ - Use energy-efficient hardware when possible
210
+ - Train during off-peak hours
211
+ - Consider renewable energy sources
212
+ - Reuse and share trained models
213
 
214
+ ## Technical Specifications
215
 
216
+ ### Model Architecture
217
 
218
+ - **Base Architecture**: Llama 3.2 (Transformer decoder)
219
+ - **Attention Type**: Multi-head attention with GQA
220
+ - **Hidden Size**: 2048 (1B) or 3072 (3B)
221
+ - **Num Layers**: 16 (1B) or 28 (3B)
222
+ - **Num Attention Heads**: 32
223
+ - **Vocabulary Size**: 128,256
224
+ - **Position Embeddings**: RoPE (Rotary Position Embedding)
225
 
226
+ ### Fine-Tuning Method
227
 
228
+ **LoRA (Low-Rank Adaptation):**
229
+ - Adds trainable low-rank matrices to attention layers
230
+ - Freezes original model weights
231
+ - Reduces memory and compute requirements
232
+ - Enables efficient multi-task learning
233
 
 
234
 
235
+ ## Model Card Contact
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
236
 
237
+ For questions or concerns about this model:
238
+ - **GitHub Issues**: [https://github.com/990aa/novelCrafter/issues](https://github.com/990aa/novelCrafter/issues)
239
+ - **Email**: Via GitHub profile
240
 
241
+ ## Changelog
242
 
243
+ ### Version 1.0.0 (October 2025)
244
+ - Initial release
245
+ - Incremental training on literary works
246
+ - LoRA fine-tuning implementation
247
+ - CPU/GPU optimization
248
+ - Hugging Face integration
249
 
250
+ ---
251
 
252
+ **Model Card Authors**: 990aa
253
+ **Model Card Date**: October 2025
254
+ **Model Card Version**: 1.0.0