Update README.md
Browse files
README.md
CHANGED
@@ -1,25 +1,80 @@
|
|
1 |
---
|
2 |
library_name: transformers
|
3 |
-
tags:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
---
|
5 |
|
6 |
-
|
7 |
|
8 |
-
|
9 |
|
10 |
-
|
11 |
-
from transformers import AutoModelForCausalLM, GPT2Tokenizer
|
12 |
|
13 |
-
|
14 |
-
model = AutoModelForCausalLM.from_pretrained("suriya7/ChatGPT-2.V2")
|
15 |
-
```
|
16 |
|
17 |
-
|
18 |
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
import torch
|
22 |
|
|
|
|
|
|
|
23 |
prompt = """
|
24 |
<|im_start|>system\nYou are a helpful AI assistant named Securitron, trained by Aquilax.<|im_end|>
|
25 |
"""
|
@@ -58,43 +113,50 @@ while True:
|
|
58 |
|
59 |
# Start generating tokens one by one
|
60 |
assistant_response = ""
|
61 |
-
# print("Assistant: ", end="", flush=True) # Print "Assistant:" once before streaming starts
|
62 |
for _ in range(512): # Specify a max token limit for streaming
|
63 |
-
# Generate the next token in the sequence
|
64 |
next_token = model.generate(
|
65 |
generated_ids,
|
66 |
max_new_tokens=1,
|
67 |
pad_token_id=50259,
|
68 |
eos_token_id=50259,
|
69 |
num_return_sequences=1,
|
70 |
-
do_sample=True,
|
71 |
-
top_k=50,
|
72 |
-
temperature=0.7,
|
73 |
-
top_p
|
74 |
)
|
75 |
|
76 |
-
# Add the generated token to the list
|
77 |
generated_ids = torch.cat([generated_ids, next_token[:, -1:]], dim=1)
|
78 |
-
|
79 |
-
# Decode the generated token (flatten it to a list of IDs)
|
80 |
-
token_id = next_token[0, -1].item() # Extract the last token as an integer
|
81 |
token = tokenizer.decode([token_id], skip_special_tokens=True)
|
82 |
-
|
83 |
|
84 |
-
# Append the token to the ongoing response
|
85 |
assistant_response += token
|
86 |
-
print(token, end="", flush=True)
|
87 |
|
88 |
-
# If EOS token is encountered, stop generating
|
89 |
if token_id == 50259: # EOS token
|
90 |
break
|
91 |
|
92 |
-
print()
|
93 |
-
|
94 |
-
# Add the assistant's response to the conversation history
|
95 |
conversation_history.append(f"<|im_start|>{assistant_response.strip()}<|im_end|>")
|
96 |
-
|
97 |
```
|
98 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
|
|
|
|
|
100 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
library_name: transformers
|
3 |
+
tags:
|
4 |
+
- conversational-ai
|
5 |
+
- fine-tuning
|
6 |
+
- gpt2
|
7 |
+
- causal-lm
|
8 |
+
- chatbots
|
9 |
+
license: apache-2.0
|
10 |
+
model_name: ChatGPT-2.V2
|
11 |
+
base_model:
|
12 |
+
- MBZUAI/LaMini-GPT-774M
|
13 |
---
|
14 |
|
15 |
+
# ChatGPT-2.V2 Model Card
|
16 |
|
17 |
+
## Model Description
|
18 |
|
19 |
+
**ChatGPT-2.V2** is a fine-tuned version of the **lamini-gpt-774M** instruction model, optimized for conversational AI tasks. The model is trained to generate coherent, context-aware responses for interactive chatbot applications, achieving significant improvements in performance through fine-tuning on a combination of public conversational datasets and curated, domain-specific datasets.
|
|
|
20 |
|
21 |
+
This model supports a context length of up to **1024 tokens**, enabling it to handle multi-turn conversations effectively.
|
|
|
|
|
22 |
|
23 |
+
---
|
24 |
|
25 |
+
## Fine-Tuning Process
|
26 |
+
|
27 |
+
The model was fine-tuned using **public conversational datasets** and **curated datasets** specifically tailored for interactive chat scenarios. The fine-tuning process aimed to:
|
28 |
+
|
29 |
+
- Enhance the model's ability to understand and respond to diverse conversational prompts.
|
30 |
+
- Improve context retention and relevance in multi-turn interactions.
|
31 |
+
- Achieve a balance between creativity and accuracy for engaging chatbot responses.
|
32 |
+
|
33 |
+
The training process resulted in a **final loss of 1.2**, indicating strong convergence and performance.
|
34 |
+
|
35 |
+
---
|
36 |
+
|
37 |
+
## Key Features
|
38 |
+
|
39 |
+
- **Conversational Proficiency:** Designed for real-time chat applications with context-aware responses.
|
40 |
+
- **Fine-Tuned Context Handling:** Supports up to 1024 tokens, enabling robust multi-turn conversations.
|
41 |
+
- **Instruction-Based Foundation:** Built on the lamini-gpt-774M instruction model, retaining its strengths in task-oriented dialogues.
|
42 |
+
|
43 |
+
---
|
44 |
+
|
45 |
+
## Training Details
|
46 |
+
|
47 |
+
- **Base Model:** lamini-gpt-774M
|
48 |
+
- **Fine-Tuning Framework:** Hugging Face Transformers
|
49 |
+
- **Datasets Used:**
|
50 |
+
- Public conversational datasets (open-domain)
|
51 |
+
- Custom curated datasets for domain-specific conversations
|
52 |
+
- **Context Length:** 1024 tokens
|
53 |
+
- **Final Loss:** 1.2
|
54 |
+
- **Learning Rate:** 1e-5
|
55 |
+
- **Training Epochs:** 3
|
56 |
+
- **fp16:** True
|
57 |
|
58 |
+
---
|
59 |
+
|
60 |
+
## Usage
|
61 |
+
|
62 |
+
The model is intended for conversational AI applications, such as:
|
63 |
+
|
64 |
+
- Chatbots for customer support
|
65 |
+
- Interactive virtual assistants
|
66 |
+
- Personalized conversational agents
|
67 |
+
|
68 |
+
### Inference Example
|
69 |
+
|
70 |
+
```python
|
71 |
+
# Load model directly
|
72 |
+
from transformers import AutoModelForCausalLM, GPT2Tokenizer
|
73 |
import torch
|
74 |
|
75 |
+
tokenizer = GPT2Tokenizer.from_pretrained("suriya7/ChatGPT-2.V2")
|
76 |
+
model = AutoModelForCausalLM.from_pretrained("suriya7/ChatGPT-2.V2")
|
77 |
+
|
78 |
prompt = """
|
79 |
<|im_start|>system\nYou are a helpful AI assistant named Securitron, trained by Aquilax.<|im_end|>
|
80 |
"""
|
|
|
113 |
|
114 |
# Start generating tokens one by one
|
115 |
assistant_response = ""
|
|
|
116 |
for _ in range(512): # Specify a max token limit for streaming
|
|
|
117 |
next_token = model.generate(
|
118 |
generated_ids,
|
119 |
max_new_tokens=1,
|
120 |
pad_token_id=50259,
|
121 |
eos_token_id=50259,
|
122 |
num_return_sequences=1,
|
123 |
+
do_sample=True,
|
124 |
+
top_k=50,
|
125 |
+
temperature=0.7,
|
126 |
+
top_p=0.90
|
127 |
)
|
128 |
|
|
|
129 |
generated_ids = torch.cat([generated_ids, next_token[:, -1:]], dim=1)
|
130 |
+
token_id = next_token[0, -1].item()
|
|
|
|
|
131 |
token = tokenizer.decode([token_id], skip_special_tokens=True)
|
|
|
132 |
|
|
|
133 |
assistant_response += token
|
134 |
+
print(token, end="", flush=True)
|
135 |
|
|
|
136 |
if token_id == 50259: # EOS token
|
137 |
break
|
138 |
|
139 |
+
print()
|
|
|
|
|
140 |
conversation_history.append(f"<|im_start|>{assistant_response.strip()}<|im_end|>")
|
|
|
141 |
```
|
142 |
|
143 |
+
## Limitations
|
144 |
+
While the model performs well in general chat scenarios, it may encounter challenges in:
|
145 |
+
|
146 |
+
- Highly domain-specific contexts not covered during fine-tuning.
|
147 |
+
- Very long conversations that exceed the 1024-token context limit.
|
148 |
+
|
149 |
+
## Additional Disclaimer
|
150 |
+
|
151 |
+
Please note that this model has not been specifically aligned using techniques such as Direct Preference Optimization (DPO) or similar methodologies. While the model has been fine-tuned to perform well in chat-based tasks, its responses are not guaranteed to reflect human-aligned preferences or ethical guidelines. Use with caution in sensitive or critical applications.
|
152 |
+
|
153 |
|
154 |
+
## Citation
|
155 |
+
If you use this model in your work, please cite as:
|
156 |
|
157 |
+
@article{ChatGPT2.V2,
|
158 |
+
title={ChatGPT-2.V2: Fine-Tuned Conversational AI Model},
|
159 |
+
author={Aquilax Team},
|
160 |
+
year={2024},
|
161 |
+
note={https://huggingface.co/suriya7/ChatGPT-2.V2}
|
162 |
+
}
|