Update README.md
Browse files
README.md
CHANGED
@@ -137,6 +137,42 @@ QNetworkGPT2 is an extraordinary AI model that marries Reinforcement Learning (R
|
|
137 |
4. Assess the text with metrics and demands.
|
138 |
5. Fine-tune and enhance for your text generation quest.
|
139 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
140 |
## Explore and Create
|
141 |
|
142 |
QNetworkGPT2 is your ticket to exploring new horizons in text generation. From chatbots and content creation to storytelling and beyond, it's your AI companion for all text adventures. 🌟
|
|
|
137 |
4. Assess the text with metrics and demands.
|
138 |
5. Fine-tune and enhance for your text generation quest.
|
139 |
|
140 |
+
---
|
141 |
+
# Load model directly
|
142 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
143 |
+
|
144 |
+
tokenizer = AutoTokenizer.from_pretrained("ayjays132/QNetworkGPT2")
|
145 |
+
model = AutoModelForCausalLM.from_pretrained("ayjays132/QNetworkGPT2")
|
146 |
+
|
147 |
+
# Initialize a conversation history
|
148 |
+
conversation_history = []
|
149 |
+
|
150 |
+
# Start a conversation loop
|
151 |
+
while True:
|
152 |
+
# Get user input
|
153 |
+
user_input = input("You: ")
|
154 |
+
|
155 |
+
# Add user input to the conversation history
|
156 |
+
conversation_history.append(user_input)
|
157 |
+
|
158 |
+
# Concatenate the conversation strings
|
159 |
+
conversation_text = " ".join(conversation_history)
|
160 |
+
|
161 |
+
# Tokenize and pad the input
|
162 |
+
input_ids = tokenizer.encode(conversation_text, return_tensors="pt", padding=True, truncation=True)
|
163 |
+
|
164 |
+
# Generate a response
|
165 |
+
output_ids = model.generate(input_ids, max_length=150, num_return_sequences=1, pad_token_id=tokenizer.eos_token_id)
|
166 |
+
|
167 |
+
# Decode the generated response
|
168 |
+
generated_response = tokenizer.decode(output_ids[0], skip_special_tokens=True)
|
169 |
+
|
170 |
+
# Print the generated response
|
171 |
+
print("Bot:", generated_response)
|
172 |
+
|
173 |
+
# Add bot's response to the conversation history
|
174 |
+
conversation_history.append(generated_response)
|
175 |
+
---
|
176 |
## Explore and Create
|
177 |
|
178 |
QNetworkGPT2 is your ticket to exploring new horizons in text generation. From chatbots and content creation to storytelling and beyond, it's your AI companion for all text adventures. 🌟
|