Views
No views yet
pip install transformers==4.51.1 torch==2.6.01from transformers import pipeline, TextStreamer
2import torch
3
4generate_text = pipeline(
5 "text-generation",
6 model="Felladrin/Minueza-2-96M-Instruct-Variant-09",
7 device=torch.device("cuda" if torch.cuda.is_available() else "cpu"),
8)
9
10messages = [
11 {
12 "role": "system",
13 "content": "You are a helpful and knowledgeable assistant that provides an expansive and comprehensive answer for a given query or instruction.",
14 },
15 {
16 "role": "user",
17 "content": "Write a tutorial on how to publish a book.",
18 },
19]
20
21generate_text(
22 generate_text.tokenizer.apply_chat_template(
23 messages, tokenize=False, add_generation_prompt=True
24 ),
25 streamer=TextStreamer(generate_text.tokenizer, skip_special_tokens=True),
26 max_new_tokens=512,
27 do_sample=True,
28 temperature=0.7,
29 top_p=0.9,
30 top_k=0,
31 min_p=0.1,
32 repetition_penalty=1.17,
33)