hf_mirrors/janus-7b
Model Introduction
Files & versions
Analysis

Links for Reference

  • Homepage: https://lklab.kaist.ac.kr/Janus/
  • Repository: https://github.com/kaistAI/Janus
  • Paper: https://arxiv.org/abs/2405.17977
  • Point of Contact: seongyun@kaist.ac.kr

TL; DR

image/png

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.

Model Details

Janus-7B is a model created by supervised fine-tuning using all 196k entries of the training data from the Multifaceted-Collection.

Model Description

  • Model type: Language model
  • Language(s) (NLP): English
  • License: Apache 2.0
  • Related Models: Janus-DPO-7B, Janus-ORPO-7B, Janus-RM-7B
  • Training Datasets: Multifaceted-Collection-SFT
  • Resources for more information:
    • Research paper
    • GitHub Repo

Usage

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:

[INST]{system_message}\n{instruction}[/INST]

Additionally, an example of the inference code applying this is as follows:

from openmind import AutoTokenizer, AutoModelForCausalLM, is_torch_npu_available
from openmind_hub import snapshot_download
import torch.nn.functional as F
from torch import Tensor
import openmind
import torch
import argparse
import sys
import time

def parse_args():
    parser = argparse.ArgumentParser()
    parser.add_argument(
        "--model_name_or_path",
        type=str,
        help="Path to model",
        default="zhouhui/janus-7b",
    )
    args = parser.parse_args()
    return args

def main():
    args = parse_args()
    model_path = args.model_name_or_path

    if is_torch_npu_available():
        device = "npu:0"
    else:
        device = "cpu"
    #device = "cpu"
    start_time = time.time()      
    model = AutoModelForCausalLM.from_pretrained(model_path).to(device)
    tokenizer = AutoTokenizer.from_pretrained(model_path)
    model.eval()

    prompt = "Hello, who are you?"
    input_ids = tokenizer(prompt, return_tensors="pt").input_ids.to(device)
    outputs = model.generate(input_ids=input_ids, max_length=100)
    response = tokenizer.decode(outputs[0], skip_special_tokens=True)
    print(response)
    end_time = time.time()
    print(f"硬件环境:{device},推理执行时间:{end_time - start_time}秒")
    
if __name__ == "__main__":
    main()

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.

Training Details

Training hyperparameters

The following hyperparameters were used during training:

  • learning_rate: 5e-06
  • train_batch_size: 2
  • eval_batch_size: 2
  • seed: 42
  • distributed_type: multi-GPU
  • num_devices: 4
  • gradient_accumulation_steps: 4
  • total_train_batch_size: 32
  • total_eval_batch_size: 8
  • optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
  • lr_scheduler_type: cosine
  • lr_scheduler_warmup_steps: 10
  • num_epochs: 4

Framework versions

  • Transformers 4.40.0.dev0
  • Pytorch 2.2.2
  • Datasets 2.18.0
  • Tokenizers 0.15.0

Citation

If you find the following model helpful, please consider citing our paper!

BibTeX:

@misc{lee2024aligning,
      title={Aligning to Thousands of Preferences via System Message Generalization}, 
      author={Seongyun Lee and Sue Hyun Park and Seungone Kim and Minjoon Seo},
      year={2024},
      eprint={2405.17977},
      archivePrefix={arXiv},
      primaryClass={cs.CL}
}