Views
No views yet
1from transformers import pipeline
2from accelerate import Accelerator
3
4# Initialize the accelerator
5accelerator = Accelerator()
6
7# Initialize the pipeline
8pipe = pipeline("text-generation", model="OEvortex/HelpingAI-Lite", device=accelerator.device)
9
10# Define the messages
11messages = [
12 {
13 "role": "system",
14 "content": "You are a chatbot who can help code!",
15 },
16 {
17 "role": "user",
18 "content": "Write me a function to calculate the first 10 digits of the fibonacci sequence in Python and print it out to the CLI.",
19 },
20]
21
22# Prepare the prompt
23prompt = pipe.tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
24
25# Generate predictions
26outputs = pipe(prompt, max_new_tokens=256, do_sample=True, temperature=0.7, top_k=50, top_p=0.95)
27
28# Print the generated text
29print(outputs[0]["generated_text"])