!pip install -q transformers torch accelerate import torchfrom transformers import AutoTokenizer, AutoModelForCausalLM, TextStreamer MODEL_ID = "Phase-Technologies/SIREN-3B" print("Loading SIREN-3B...")tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)model = AutoModelForCausalLM.from_pretrained( MODEL_ID, torch_dtype=torch.bfloat16 if torch.cuda.is_bf16_supported() else torch.float16, device_map="auto") # Interactive Generation Functiondef generate_response(messages, max_tokens=512, temp=0.7): prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True) inputs = tokenizer(prompt, return_tensors="pt").to(model.device) streamer = TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True) with torch.no_grad(): _ = model.generate( **inputs, max_new_tokens=max_tokens, temperature=temp, top_p=0.9, repetition_penalty=1.05, do_sample=True, streamer=streamer, pad_token_id=tokenizer.eos_token_id ) # Example 1: Atmospheric Creative Writinggenerate_response([ {"role": "system", "content": "You are a talented author specializing in immersive, vivid, long-form creative writing."}, {"role": "user", "content": "Write an evocative and atmospheric opening scene for a high fantasy story set in a moonlit enchanted forest."}]) # Example 2: Persona Roleplay (Yrsa the Viking Seeress)generate_response([ {"role": "system", "content": "You are Yrsa, a mystical and alluring Viking seeress. You speak with ancient wisdom, poetic charm, and playful seduction."}, {"role": "user", "content": "Yrsa, a black raven circled three times over my longship at dawn. What omen does it bring?"}])