Kittykat924 commited on
Commit
a4ab412
·
verified ·
1 Parent(s): 80fa8f8

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +125 -3
README.md CHANGED
@@ -1,3 +1,125 @@
1
- ---
2
- license: mit
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ language:
4
+ - en
5
+ pipeline_tag: text-generation
6
+ library_name: transformers
7
+
8
+ tags:
9
+ - tinyllama
10
+ - fine-tuned
11
+ - chat
12
+ - conversational
13
+ - rlaif
14
+ - alignment
15
+ - peft
16
+ - lora
17
+
18
+ model-index:
19
+ - name: TinyPi-1.1B-Chat-v1.5
20
+ results:
21
+ - task:
22
+ type: text-generation
23
+ metrics: []
24
+ ---
25
+
26
+ # TinyPi-1.1B-Chat-v1.5: An AI Friend Aligned with RLAIF
27
+
28
+ ## Model Description
29
+
30
+ **TinyPi-1.1B-Chat-v1.5** is an advanced, conversational language model that represents a significant evolution from its v1 predecessor. Starting with a base model fine-tuned on a large corpus of Discord chat data, this version has undergone a sophisticated second stage of alignment using **Reinforcement Learning from AI Feedback (RLAIF)**.
31
+
32
+ The goal of this project was to cultivate an AI with a distinct, friendly, and engaging personality. While the v1 model successfully developed a unique "voice," it sometimes lacked factual depth and consistency. The v1.5 update addresses this directly by training the model on a high-quality dataset of corrections generated by a superior AI (Google's Gemini 1.5 Flash).
33
+
34
+ This process has made TinyPi not only more knowledgeable and less prone to repetitive loops but has also sharpened its persona, making it a more robust, reliable, and delightful conversational partner.
35
+
36
+ ## How to Use
37
+
38
+ This is a merged, standalone model and can be used directly for text generation. For best results, use the chat template which includes a system prompt to guide its persona.
39
+
40
+ ### Installation
41
+
42
+ ```bash
43
+ pip install transformers torch accelerate
44
+ ```
45
+
46
+ ### Inference with Python
47
+
48
+ ```python
49
+ from transformers import pipeline
50
+ import torch
51
+
52
+ model_path = "Kittykat924/TinyPi-Chat-v1.5"
53
+ pipe = pipeline(
54
+ "text-generation",
55
+ model=model_path,
56
+ torch_dtype=torch.float16,
57
+ device_map="auto"
58
+ )
59
+
60
+ # Define the system instruction and user prompt
61
+ system_instruction = "You are TinyPi, a 17-year-old girl who is a helpful and friendly AI assistant. You have a slightly humorous and feminine personality. You are an expert in technology, science, and gaming."
62
+ prompt = "What's a creative way to explain how a CPU works?"
63
+
64
+ # Format the conversation using the chat template
65
+ messages = [
66
+ {"role": "system", "content": system_instruction},
67
+ {"role": "user", "content": prompt},
68
+ ]
69
+ prompt_formatted = pipe.tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
70
+
71
+ # Generate a response
72
+ outputs = pipe(
73
+ prompt_formatted,
74
+ max_new_tokens=256,
75
+ do_sample=True,
76
+ temperature=0.7,
77
+ top_k=50,
78
+ top_p=0.95
79
+ )
80
+
81
+ # Extract and print the assistant's response
82
+ response = outputs[0]["generated_text"]
83
+ assistant_response = response.split("<|assistant|>")[1].strip()
84
+ print(assistant_response)
85
+ ```
86
+
87
+ ## Training Procedure
88
+
89
+ This model was developed in a two-stage fine-tuning process.
90
+
91
+ ### Stage 1: Initial Persona Fine-tuning (Creation of v1)
92
+
93
+ * **Base Model:** `TinyLlama/TinyLlama-1.1B-Chat-v1.0`
94
+ * **Dataset:** A large, private dataset of over 2 million general-purpose Discord chat messages.
95
+ * **Method:** LoRA fine-tuning using the `peft` library.
96
+ * **Result:** A model with a strong, emergent personality but with some factual inconsistencies and conversational weaknesses (e.g., repetitiveness).
97
+
98
+ ### Stage 2: RLAIF Alignment (Creation of v1.5)
99
+
100
+ This stage used an automated, AI-driven data generation loop to correct the flaws of the v1 model.
101
+
102
+ * **"Student" Model:** The merged `v1` model from Stage 1.
103
+ * **"Teacher" (Evaluator) AI:** `gemini-1.5-flash`.
104
+ * **"Chat Partner" AI:** `gemini-1.5-flash`.
105
+ * **Workflow:**
106
+ 1. A conversation was initiated between the "Chat Partner" and "TinyPi" (v1).
107
+ 2. For each of TinyPi's responses, the "Evaluator" AI judged its quality, accuracy, and adherence to the target persona.
108
+ 3. If a response was flawed, the Evaluator generated a high-quality, corrected version.
109
+ 4. Only these `(instruction, corrected_output)` pairs were saved, creating a dataset focused exclusively on fixing the model's mistakes.
110
+ * **Dataset:** **[Customize]** Approximately [e.g., `1,200`] high-quality, corrected examples generated by this RLAIF process.
111
+ * **Continual Learning:** To prevent catastrophic forgetting, the RLAIF dataset was combined with a small "replay" sample (~20,000 examples) of the original Discord data.
112
+ * **Final Fine-tune:** A new LoRA adapter was trained on this combined dataset, starting from the v1 model. This new adapter was then merged to create the final v1.5 model.
113
+
114
+ ## Model Capabilities and Limitations
115
+
116
+ **Capabilities:**
117
+ * Maintains a consistent, friendly, and humorous persona.
118
+ * Engages in coherent, multi-turn conversations on a wide variety of topics.
119
+ * Improved factual accuracy and reasoning ability on subjects covered during the RLAIF process.
120
+ * Less prone to generic refusals and repetitive loops compared to v1.
121
+
122
+ **Limitations:**
123
+ * This model is designed for conversational and entertainment purposes. It is not a substitute for expert advice and may still produce factual inaccuracies.
124
+ * Its personality is a core feature. It may not be suitable for tasks requiring a purely neutral or formal tone.
125
+ * The model inherits biases from its training data, which includes a large corpus of internet chat logs and AI-generated text. User discretion is advised.