Views
No views yet
| Property | Value |
|---|---|
| Base Model | microsoft/DialoGPT-small |
| Architecture | GPT-2 (117M parameters) |
| Task | Conversational Text Generation |
| Fine-tuned on | Rick Sanchez dialogue (Rick & Morty) |
| Framework | PyTorch + HuggingFace Transformers |
| Language | English |
1from transformers import AutoModelForCausalLM, AutoTokenizer
2import torch
3
4tokenizer = AutoTokenizer.from_pretrained("iamhariraj/DialoGPT-small-Rick")
5model = AutoModelForCausalLM.from_pretrained("iamhariraj/DialoGPT-small-Rick")
6
7chat_history_ids = None
8
9print("Talk to Rick (type 'quit' to exit)")
10while True:
11 user_input = input("You: ")
12 if user_input.lower() == "quit":
13 break
14
15 input_ids = tokenizer.encode(
16 user_input + tokenizer.eos_token,
17 return_tensors="pt"
18 )
19
20 if chat_history_ids is not None:
21 input_ids = torch.cat([chat_history_ids, input_ids], dim=-1)
22
23 chat_history_ids = model.generate(
24 input_ids,
25 max_length=1000,
26 pad_token_id=tokenizer.eos_token_id,
27 no_repeat_ngram_size=3,
28 do_sample=True,
29 top_k=100,
30 top_p=0.7,
31 temperature=0.8
32 )
33
34 response = tokenizer.decode(
35 chat_history_ids[:, input_ids.shape[-1]:][0],
36 skip_special_tokens=True
37 )
38 print(f"Rick: {response}")| You | Rick |
|---|---|
| "What is the meaning of life?" | (Rick-style nihilistic response) |
| "Can you build me a portal gun?" | (Rick flexing his genius) |
| "I need your help" | (sarcastic Rick response) |
Trainer API