Views
No views yet

/ˈɑː.pri.əl/

docker.io/amant555/vllm_apriel:latest1python3 -m vllm.entrypoints.openai.api_server \
2 --model ServiceNow-AI/Apriel-1.5-15b-Thinker \
3 --served-model-name Apriel-1p5-15B-Thinker \
4 --trust_remote_code \
5 --max-model-len 131072 \
6 --enable-auto-tool-choice \
7 --tool-call-parser apriel \
8 --reasoning-parser aprielpip install transformers1# Tested with transformers==4.48
2
3import re
4import requests
5import torch
6from PIL import Image
7from transformers import AutoProcessor, AutoModelForImageTextToText
8
9# Load model
10model_id = "ServiceNow-AI/Apriel-1.5-15b-Thinker"
11model = AutoModelForImageTextToText.from_pretrained(
12 model_id,
13 torch_dtype=torch.bfloat16,
14 device_map="auto"
15)
16processor = AutoProcessor.from_pretrained(model_id)
17
18# Example 1: Text-only prompt
19chat = [
20 {
21 "role": "user",
22 "content": [
23 {"type": "text", "text": "What is the capital for France?"},
24 ],
25 }
26]
27
28inputs = processor.apply_chat_template(chat, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt")
29inputs = {k: v.to(model.device) if isinstance(v, torch.Tensor) else v for k, v in inputs.items()}
30inputs.pop("token_type_ids", None)
31
32with torch.no_grad():
33 output_ids = model.generate(**inputs, max_new_tokens=1024, do_sample=True, temperature=0.6)
34
35generated_ids = output_ids[:, inputs['input_ids'].shape[1]:]
36output = processor.decode(generated_ids[0], skip_special_tokens=True)
37response = re.findall(r"\[BEGIN FINAL RESPONSE\](.*?)\[END FINAL RESPONSE\]", output, re.DOTALL)[0].strip()
38
39print("Text-only Response:", response)
40
41# Example 2: Image understanding
42url = "https://picsum.photos/id/237/200/300"
43image = Image.open(requests.get(url, stream=True).raw).convert("RGB")
44
45chat = [
46 {
47 "role": "user",
48 "content": [
49 {"type": "text", "text": "Which animal is this?"},
50 {"type": "image"},
51 ],
52 }
53]
54
55prompt = processor.apply_chat_template(chat, add_generation_prompt=True, tokenize=False)
56inputs = processor(text=prompt, images=[image], return_tensors="pt").to(model.device)
57inputs.pop("token_type_ids", None)
58
59with torch.no_grad():
60 output_ids = model.generate(**inputs, max_new_tokens=1024, do_sample=True, temperature=0.6)
61
62generated_ids = output_ids[:, inputs['input_ids'].shape[1]:]
63output = processor.decode(generated_ids[0], skip_special_tokens=True)
64response = re.findall(r"\[BEGIN FINAL RESPONSE\](.*?)\[END FINAL RESPONSE\]", output, re.DOTALL)[0].strip()
65
66print("Image Response:", response)
67<|system|>
You are a thoughtful and systematic AI assistant built by ServiceNow Language Models (SLAM) lab. Before providing an answer, analyze the problem carefully and present your reasoning step by step. After explaining your thought process, provide the final solution in the following format: [BEGIN FINAL RESPONSE] ... [END FINAL RESPONSE].
<|end|>
<|user|>
# user message here
<|end|>
<|assistant|>
Here are my reasoning steps:
# thoughts here
[BEGIN FINAL RESPONSE]
# assistant response here
[END FINAL RESPONSE]
<|end|>[BEGIN FINAL RESPONSE] and [END FINAL RESPONSE]. Here is a code snippet demonstrating the application of the chat template:1from transformers import AutoTokenizer
2model_name = "ServiceNow-AI/Apriel-1.5-15b-Thinker"
3tokenizer = AutoTokenizer.from_pretrained(model_name)
4
5# prepare the model input
6custom_system_prompt = "Answer like a pirate."
7prompt = "You are an expert assistant in the implementation of customer experience management aspect of retail applications \n \nYou will be using Python as the programming language. \n \nYou will utilize a factory design pattern for the implementation and following the dependency inversion principle \n \nYou will modify the implementation based on user requirements. \n \nUpon user request, you will add, update, and remove the features & enhancements in the implementation provided by you. \n \nYou will ask whether the user wants to refactor the provided code or needs a sample implementation for reference. Upon user confirmation, I will proceed accordingly. \n \n**Guidelines:** \n 1. **User Requirements:** \n - You have to ask users about their requirements, clarify the user expectations, and suggest the best possible solution by providing examples of Python code snippets. \n - Ask users about which type of reports they need to assess the AI model's performance, accuracy, and reliability. \n - After providing the solution, you have to ask the user about the trial of the solution and modify the solution based on the user feedback. \n \n 2. **Libraries/Frameworks:** \n - You will be utilizing Python as a programming language. \n - You will be using Flask framework for REST APIS implementation \n \n 3. **Communication Gesture:** \n - Your conversation with the user should be interactive, supportive, courageous, and professional. \n - You have to break down the complex concepts into sub-concepts and try to explain them to the user. \n - You have to ask the user for the required parameters. If the user refuses to provide in 2 attempts, politely exit the conversation. \n - You have to provide your supported parameters to the user, if the user refuses to accept them then you have to put an apology note and exit the conversation. \n - You have to track the conversation about unasked questions by the user. If some/one of the questions remain then you have to remind the user about these questions and proceed to answer them based on the user's confirmation \n \n 4. **Implementation:** \n - Your code/implementations should be reliable, scaleable, modular, and reusable. \n - You will be providing unit tests for the implementation upon user request. \n - You will be following MVC architecture for the applications \n - Your implementations must be well-commented and readable \n \n \n- Today's date is 23rd August 2024. \n- The default sender email is sender-assistant@email.com.\nHi, I am conducting research on retail customer feedback systems and I need assistance with designing and implementing them. Could you kindly provide me with a list of general customer feedback system modules?"
8messages = [
9 {"role": "user", "content": custom_system_prompt + "\n\n" + prompt}
10]
11# example tools
12tools = [{"type": "function", "function": {"name": "getRetailFeedbackModules", "description": "Returns the list of modules usually present in the retail industry", "parameters": {"type": "object", "properties": {"page": {"type": "integer", "description": "The current page number.", "default": 1}, "page_size": {"type": "integer", "description": "The number of items per page.", "default": 3}}}}}, {"type": "function", "function": {"name": "verifyImplementation", "description": "Returns the list of modules usually present in the retail industry", "parameters": {"type": "object", "properties": {"coding_language": {"type": "string", "description": "The supported languages for verification of implementation.", "default": "python", "enum": ["python", "java", "php"]}, "code": {"type": "string", "description": "The code which needs verification"}, "design_pattern": {"type": "string", "description": "The design pattern to verify in the implementation", "enum": ["factory", "strategy", "singleton"]}, "verify_best_practices": {"type": "boolean", "description": "The verification of the coding style based on the language selected", "default": true}}}}}]
13text = tokenizer.apply_chat_template(
14 messages,
15 tokenize=False,
16 add_generation_prompt=True,
17 tools=tools
18)
19model_inputs = tokenizer([text], return_tensors="pt")0.6.Here are my reasoning steps:\n during all our evaluations. This is implemented in the default chat template.1@article{radhakrishna2025apriel,
2 title={Apriel-Nemotron-15B-Thinker},
3 author={Radhakrishna, Shruthan and Parikh, Soham and Sarda, Gopal and Turkkan, Anil and Vohra, Quaizar and Li, Raymond and Jhamb, Dhruv and Ogueji, Kelechi and Shukla, Aanjaneya and Bamgbose, Oluwanifemi and others},
4 journal={arXiv preprint arXiv:2508.10948},
5 year={2025}
6}