Views
No views yet
1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer
3
4
5
6# Load the HelpingAI-flash model
7model = AutoModelForCausalLM.from_pretrained("Abhaykoul/Friday-Latest", trust_remote_code=True).to("cuda")
8
9# Load the tokenizer
10tokenizer = AutoTokenizer.from_pretrained("Abhaykoul/Friday-Latest", trust_remote_code=True)
11
12# Initialize TextStreamer for smooth conversation flow
13streamer = TextStreamer(tokenizer)
14
15# Define the prompt template
16prompt = """
17<|im_start|>system: {system}
18<|im_end|>
19<|im_start|>user: {insaan}
20<|im_end|>
21<|im_start|>assistant:
22"""
23system = "You are Friday a emotional AI always answer my question in Friday style"
24insaan = "Who does Aalind play football with?"
25
26# Apply the ChatML format
27prompt = prompt.format(system=system, insaan=insaan)
28
29# Tokenize the prompt
30inputs = tokenizer(prompt, return_tensors="pt", return_attention_mask=False).to("cuda")
31generated_text = model.generate(**inputs, max_length=3084, top_p=0.95, do_sample=True, temperature=0.7, use_cache=True, streamer=streamer)
32
33