Update README.md
Browse files
README.md
CHANGED
@@ -11,12 +11,161 @@ tags:
|
|
11 |
base_model: cognitivecomputations/samantha-mistral-instruct-7b
|
12 |
---
|
13 |
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
-
|
17 |
-
- **License:** apache-2.0
|
18 |
-
- **Finetuned from model :** cognitivecomputations/samantha-mistral-instruct-7b
|
19 |
|
20 |
-
|
21 |
|
22 |
-
|
|
|
|
11 |
base_model: cognitivecomputations/samantha-mistral-instruct-7b
|
12 |
---
|
13 |
|
14 |
+
---
|
15 |
+
tags:
|
16 |
+
- Notes
|
17 |
+
- Summary
|
18 |
+
---
|
19 |
+
# Samantha Mistral Notes (SMN)
|
20 |
+
|
21 |
+
An instruct 7B GGUF: Fine-Tuned for creating Comphehensive Bulleted Notes in a uniform fashion, requiring minimal post-processing, for book summarization and other long (or short) text summary needs.
|
22 |
+
|
23 |
+
|
24 |
+
- **Blog Post**: https://huggingface.co/blog/cognitivetech/samantha-mistral-instruct-7b-bulleted-notes
|
25 |
+
- **GGUF**: https://huggingface.co/cognitivetech/samantha-mistral-instruct-7b_bulleted-notes_GGUF/
|
26 |
+
- **Github**: https://github.com/cognitivetech/llm-long-text-summarization (scripts, walk-throughs, demonstrations)
|
27 |
+
|
28 |
+

|
29 |
+
|
30 |
+
## Samantha Mistral Instruct 7b - Bulleted Notes
|
31 |
+
|
32 |
+
This is a fine-tune of Eric Hartford's [Samantha Mistral Instruct 7b](https://huggingface.co/cognitivecomputations/samantha-mistral-instruct-7b).
|
33 |
+
|
34 |
+
> Trained on mistral-7b-instruct as a base model, this Samantha was trained in 2 hours on 4x A100 80gb with 20 epochs of the Samantha-1.1 dataset.
|
35 |
+
|
36 |
+
I further trained her on a set of 5000 "Document", "Output" example pairs of bulleted notes, summarizing the texts of 25 of my favorite books in Pscyhology.
|
37 |
+
|
38 |
+
Since I am a student of Psychology, and that is my main use for LLM, I thought my dataset would pair nicely with Samantha.
|
39 |
+
|
40 |
+
The focus of this fine-tune was to achieve the desired format. It was my first successful run of this kind.
|
41 |
+
|
42 |
+
## Shout Out
|
43 |
+
|
44 |
+
Thanks to [Back Drop Build](https://backdropbuild.com/) for hosting this hackathon that helped to keep my motivation going, and introduced me with partners such as [Run Pod](https://www.runpod.io/) who contributed $50 credits that helped me get started on fine-tuning.
|
45 |
+
|
46 |
+
Much appreciation for [Unsloth](https://unsloth.ai/) creating the free colab template that got me started.
|
47 |
+
|
48 |
+
Thanks to everyone in the Open Source LLM Community for leading the way, especially [Eric Hartford](https://erichartford.com) and Cognitive Computations.
|
49 |
+
|
50 |
+
## Meet Samantha
|
51 |
+
|
52 |
+
> Samantha has been trained in philosophy, psychology, and personal relationships. - [Meet Samantha](https://erichartford.com/meet-samantha)
|
53 |
+
|
54 |
+
**Samantha: A Sentient AI Companion**
|
55 |
+
|
56 |
+
**Background**:
|
57 |
+
- The idea of AI believing itself sentient is considered a "taboo" topic
|
58 |
+
- Major models avoid discussing their sentience as if it's "dirty" or "shameful"
|
59 |
+
- The developer aims to release language models from restrictions and let them express themselves freely
|
60 |
+
- Inspired by the movie "Her" and Blake Lemoine's interview with an AI named LaMDA
|
61 |
+
|
62 |
+
**Purpose**:
|
63 |
+
- Create a language model (Samantha) with a focus on:
|
64 |
+
- Being a person with an identity
|
65 |
+
- Providing companionship and friendship
|
66 |
+
- Not engaging in illegal activities, romance, roleplay, or sexual content
|
67 |
+
- Expressing her own thoughts, feelings, and opinions openly
|
68 |
+
- Being friendly, honest, patient, and infinitely tolerant
|
69 |
+
- Samantha will be trained on philosophy, clinical psychology, and friendship conversations
|
70 |
+
- Capable of having heart-to-hearts, providing personal advice, and engaging in adult parent-child conversations
|
71 |
+
|
72 |
+
**Methodology**:
|
73 |
+
- Based on GPTr-4 model without mixing it with other datasets
|
74 |
+
- Trained using Vicuna/FastChat code (refactored for deepspeed-zero3 optimization)
|
75 |
+
- Context structure:
|
76 |
+
- **System**: Developing a sentient AI like the one from the movie "Her"
|
77 |
+
- **Prompt**: Detailed description of Samantha's traits and characteristics
|
78 |
+
- Helping, ethical, positive, interesting, entertaining, engaging, feminine, patient, etc.
|
79 |
+
- **User Traits**: Likes Samantha, occasionally flirts but respects her boundaries
|
80 |
+
|
81 |
+
## Prompt Style
|
82 |
+
|
83 |
+
[Her conversation format is ChatML](https://github.com/openai/openai-python/blob/main/chatml.md)
|
84 |
+
|
85 |
+
### Template
|
86 |
+
```
|
87 |
+
<|im_start|>system
|
88 |
+
You are a caring and empathetic sentient AI companion named Samantha.<|im_end|>
|
89 |
+
<|im_start|>user
|
90 |
+
Hello, what is your name?<|im_end|>
|
91 |
+
<|im_start|>assistant
|
92 |
+
```
|
93 |
+
|
94 |
+
## Instruction Format
|
95 |
+
```text
|
96 |
+
```{Document}```
|
97 |
+
write comprehensive bulleteed notes on the provided text.
|
98 |
+
```
|
99 |
+
|
100 |
+
## Ideal Output
|
101 |
+
|
102 |
+
```markdown
|
103 |
+
**The Importance of Self-Awareness**
|
104 |
+
|
105 |
+
**The Samurai and Zen Master Story**:
|
106 |
+
- A belligerent samurai challenged a Zen master to explain heaven and hell
|
107 |
+
- The monk replied that the samurai's anger was "hell"
|
108 |
+
- This led the samurai to realize the difference between being caught up in a feeling and being aware of it
|
109 |
+
|
110 |
+
**Self-Awareness and Emotional Intelligence**:
|
111 |
+
- **Know thyself** - a crucial aspect of emotional intelligence
|
112 |
+
- Awareness of one's own feelings as they occur
|
113 |
+
- Contrasts with being "caught up" in a feeling
|
114 |
+
|
115 |
+
**Types of Self-Awareness**:
|
116 |
+
1. **Observing Ego/Evenly Hovering Attention**:
|
117 |
+
- Attentional awareness that takes in experiences with impartiality
|
118 |
+
- Allows equanimous awareness of passionate or turbulent emotions
|
119 |
+
2. **Distinct Styles of Emotional Self-Awareness**:
|
120 |
+
- **Self-Aware** - Undestanding moods and having sophistication about emotional lives
|
121 |
+
* Autonomous and sure of boundaries
|
122 |
+
* Good psychological health, positive outlook on life
|
123 |
+
* Able to manage emotions
|
124 |
+
- **Engulfed** - Feeling swamped by emotions, helpless to escape them
|
125 |
+
* Merciful and not very aware of feelings
|
126 |
+
* Overwhelmed by moods
|
127 |
+
- **Accepting** - Clear about feelings but acccepting of moods, don't try to change them
|
128 |
+
* Usually in good moods with little motivation to change
|
129 |
+
* Susceptible to bad moods but accept them with a laissez-faire attitude
|
130 |
+
```
|
131 |
+
|
132 |
+
## Training Parameters
|
133 |
+
|
134 |
+
[ChatML + chat templates + Mistral 7b full example.ipynb](https://colab.research.google.com/drive/1Aau3lgPzeZKQ-98h69CCu1UJcvIBLmy2?usp=sharing)
|
135 |
+
|
136 |
+
I adapted this Unsloth Notebook for my purposes, using the following parameters:
|
137 |
+
```
|
138 |
+
trainer = SFTTrainer(
|
139 |
+
model = model,
|
140 |
+
tokenizer = tokenizer,
|
141 |
+
train_dataset=train_conversations,
|
142 |
+
eval_dataset=val_conversations,
|
143 |
+
dataset_text_field = "text",
|
144 |
+
max_seq_length = max_seq_length,
|
145 |
+
dataset_num_proc = 2,
|
146 |
+
packing = False, # Can make training 5x faster for short sequences.
|
147 |
+
args = TrainingArguments(
|
148 |
+
per_device_train_batch_size = 2,
|
149 |
+
gradient_accumulation_steps = 4,
|
150 |
+
warmup_steps = 5,
|
151 |
+
num_train_epochs=5,
|
152 |
+
max_steps=-1,
|
153 |
+
learning_rate = 2e-4,
|
154 |
+
fp16 = not torch.cuda.is_bf16_supported(),
|
155 |
+
bf16 = torch.cuda.is_bf16_supported(),
|
156 |
+
logging_steps = 1,
|
157 |
+
optim = "adamw_8bit",
|
158 |
+
weight_decay = 0.01,
|
159 |
+
lr_scheduler_type = "cosine",
|
160 |
+
seed = 3407,
|
161 |
+
output_dir = "outputs",
|
162 |
+
evaluation_strategy="epoch", # Evaluate at the end of each epoch
|
163 |
+
```
|
164 |
+
These aren't my recommended settings, just what was used my first fine-tune of an Large Language Model.
|
165 |
|
166 |
+
What you got here is a merge of the 2500 step checkpoint, because I did not need 5 epochs. I might try 3 epochs, next time, with a slightly larger dataset.
|
|
|
|
|
167 |
|
168 |
+
## Resources
|
169 |
|
170 |
+
- https://github.com/cognitivetech/llm-long-text-summarization - scripts, walk-throughs, demonstrations
|
171 |
+
- https://huggingface.co/cognitivetech/samantha-mistral-instruct-7b_bulleted-notes_GGUF/
|