Janus is a model trained using
Mistral-7B-v0.2 as its base model. Janus has been trained on
Multifaceted Collection, a preference dataset containing 196k unique system messages for aligning LLMs to diverse human preferences. Janus not only excels at generating personalized responses that cater to various human preferences but is also adept at producing responses that are generally preferred for being helpful and harmless.
Janus-7B is a model created by supervised fine-tuning using all 196k entries of the training data from the Multifaceted-Collection.
Janus is a model generalized for various system messages, allowing users to control the model's response by inputting the desired system message. The input prompt format is as follows:
1from transformers import AutoTokenizer, AutoModelForCausalLM
2import torch
3
4model_name = "kaist-ai/janus-7b"
5device = "cuda:0"
6
7# Load the model and tokenizer
8tokenizer = AutoTokenizer.from_pretrained(model_name)
9
10dtype = "float16"
11if torch.cuda.is_bf16_supported():
12 dtype = "bfloat16"
13
14model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=getattr(torch, dtype))
15model.eval()
16model.to(device)
17
18# Prepare inputs
19system = "As a financial news headline writer with a flair for the dramatic, you have taken on the role of crafting compelling headlines about the integration of AI into the financial sector. Your expertise allows you to weave industry-specific terminology seamlessly into each headline, striking a balance between capturing attention and providing meaningful insights into the transformative benefits of AI in finance. With each headline, you focus on elucidating the key advantages AI brings to financial operations, making complex information accessible and immediately impactful. While your headlines are designed to engage and inform an audience of finance and technology professionals, you navigate the fine line of excitement and accuracy with care, ensuring that the promises made are grounded in reality, thus avoiding any form of sensationalism. Your mission is to distill the essence of AI's impact on finance into a single, powerful line that speaks volumes to the informed reader."
20prompt = "Write a headline for an article about the benefits of using AI in the finance sector."
21
22def apply_template_mistral_instruct(system_message, content):
23 prompt = f"{system_message}\n{content}".strip()
24 return f"[INST] {prompt} [/INST] "
25
26input_str = apply_template_mistral_instruct(system, prompt)
27input_ids = tokenizer.encode(input_str, return_tensors="pt")
28print(input_str)
29
30model_inputs = input_ids.to(device)
31
32# Generate text
33output_ids = model.generate(model_inputs, max_new_tokens=1024)
34decoded = tokenizer.batch_decode(output_ids, skip_special_tokens=True)
35print(decoded[0][len(input_str):])
36# Revolutionary Trends: How AI Is Redefining Efficiency and Accuracy in the Financial Realm
To train Janus and evaluate the responses it generates, please refer to the
GitHub Repo.
Additionally, refer to the
Multifaceted Bench, which evaluates how well LLM generates personalized responses.
1@misc{lee2024aligning,
2 title={Aligning to Thousands of Preferences via System Message Generalization},
3 author={Seongyun Lee and Sue Hyun Park and Seungone Kim and Minjoon Seo},
4 year={2024},
5 eprint={2405.17977},
6 archivePrefix={arXiv},
7 primaryClass={cs.CL}
8}