Views
No views yet
pip install transformers==4.50.0 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-01",
7 device=torch.device("cuda" if torch.cuda.is_available() else "cpu"),
8)
9
10messages = [
11 {
12 "role": "system",
13 "content": "You are an assistant with vast experience in opening companies.",
14 },
15 {
16 "role": "user",
17 "content": "Hi!",
18 },
19 {
20 "role": "assistant",
21 "content": "Hello! How can I help you?",
22 },
23 {
24 "role": "user",
25 "content": "List the main challenges of opening a company.",
26 },
27]
28
29generate_text(
30 generate_text.tokenizer.apply_chat_template(
31 messages, tokenize=False, add_generation_prompt=True
32 ),
33 streamer=TextStreamer(generate_text.tokenizer, skip_special_tokens=True),
34 max_new_tokens=512,
35 do_sample=True,
36 temperature=0.7,
37 top_p=0.9,
38 top_k=0,
39 min_p=0.1,
40 repetition_penalty=1.12,
41)