Views
No views yet
1import transformers
2from transformers import AutoTokenizer
3
4# Format prompt
5message = [
6 {"role": "system", "content": "You are a helpful AI assistant."},
7 {"role": "user", "content": "What is a Large Language Model?"}
8]
9tokenizer = AutoTokenizer.from_pretrained("FINGU-AI/Ultimos-32B")
10prompt = tokenizer.apply_chat_template(message, add_generation_prompt=True, tokenize=False)
11
12# Create pipeline
13pipeline = transformers.pipeline(
14 "text-generation",
15 model="FINGU-AI/Ultimos-32B",
16 tokenizer=tokenizer
17)
18
19# Generate text
20sequences = pipeline(
21 prompt,
22 do_sample=True,
23 temperature=0.7,
24 top_p=0.9,
25 num_return_sequences=1,
26 max_length=200,
27)
28print(sequences[0]['generated_text'])