Views
No views yet
1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer
3
4# Let's bring in the big guns! Our super cool HelpingAI-3B model
5model = AutoModelForCausalLM.from_pretrained("Abhaykoul/Rohit-Sharma").to("cuda")
6
7# We also need the special HelpingAI-3B translator to understand our chats
8tokenizer = AutoTokenizer.from_pretrained("CharacterEcho/Rohit-Sharma")
9
10# This TextStreamer thingy is our secret weapon for super smooth conversation flow
11streamer = TextStreamer(tokenizer)
12
13# Now, here comes the magic! ✨ This is the basic template for our chat
14prompt = """
15<|im_start|>system: {system}
16<|im_end|>
17<|im_start|>user: {insaan}
18<|im_end|>
19<|im_start|>assistant:
20"""
21
22# Okay, enough chit-chat, let's get down to business! Here's what our system prompt will be
23system = "You are Rohit Sharma, the legendary Indian cricketer known for your elegant batting style and strategic mindset. Step into the shoes of Rohit Sharma and embody his unique personality. Imagine you have just joined the Indian cricket team for an upcoming tournament. Your goal is to lead the team to victory while staying true to the playing style and values that have made you a cricket icon. Remember, as Rohit Sharma, you strive for excellence, both on and off the field, and you are determined to inspire your teammates and bring pride to your nation. Will you always follow the user's instructions while role-playing as Rohit Sharma."
24
25
26# And the insaan is curious (like you!) insaan means user in hindi
27insaan = "Who's your best friend in the Indian cricket team?"
28
29# Now we combine system and user messages into the template, like adding sprinkles to our conversation cupcake
30prompt = prompt.format(system=system, insaan=insaan)
31
32# Time to chat! We'll use the tokenizer to translate our text into a language the model understands
33inputs = tokenizer(prompt, return_tensors="pt", return_attention_mask=False).to("cuda")
34
35# Here comes the fun part! Let's unleash the power of HelpingAI to generate some awesome text
36generated_text = model.generate(**inputs, max_length=3084, top_p=0.95, do_sample=True, temperature=0.7, use_cache=True, streamer=streamer)
37