Seongyun commited on
Commit
b3123bf
1 Parent(s): 8d4092e

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +114 -0
README.md ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ datasets:
4
+ - kaist-ai/Multifaceted-Collection-RM
5
+ language:
6
+ - en
7
+ library_name: transformers
8
+ ---
9
+
10
+ ## Links for Reference
11
+
12
+ - **Homepage: In Progress**
13
+ - **Repository: https://github.com/kaistAI/Janus**
14
+ - **Paper:**
15
+ - **Point of Contact:seongyun@kaist.ac.kr**
16
+
17
+ # TL; DR
18
+ ![image/png](https://cdn-uploads.huggingface.co/production/uploads/6550c4f27bbfce1878f5f280/vrQl8D8FV3vqUJYbPgsiG.png)
19
+
20
+ Janus is a model trained using [Mistral-7B-v0.2](https://huggingface.co/mistral-community/Mistral-7B-v0.2) as its base model. Janus has been trained on [Multifaceted Collection](https://huggingface.co/datasets/kaist-ai/Multifaceted-Collection-SFT), a preference dataset containing 192k 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.
21
+
22
+ # Model Details
23
+ Janus-RM-7B is a reward model created by training Janus with Multifaceted-Collection-RM. Janus-RM-7B generates rewards when provided with various system messages and instructions, along with the personalized responses generated in accordance with these. This can be utilized to perform tasks such as PPO and best-of-n sampling.
24
+
25
+ ## Model Description
26
+
27
+ - **Model type:** Language model
28
+ - **Language(s) (NLP):** English
29
+ - **License:** Apache 2.0
30
+ - **Related Models:** [Janus-66k-7B]() [Janus-DPO-7B](), [Janus-ORPO-7B](), [Janus-7B]()
31
+ - **Training Datasets**: [Multifaceted-Collection-SFT](https://huggingface.co/datasets/kaist-ai/Multifaceted-Collection-SFT)
32
+ - **Resources for more information:**
33
+ - [Research paper]()
34
+ - [GitHub Repo](https://github.com/kaistAI/Janus)
35
+
36
+ # Usage
37
+ 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:
38
+ ```
39
+ [INST]{system_message}\n{instruction}[/INST]
40
+ ```
41
+ Additionally, an example of the inference code applying this is as follows:
42
+ ```
43
+ from transformers import AutoTokenizer, AutoModelForCausalLM
44
+ import torch
45
+
46
+ model_name = "kaist-ai/janus-7b"
47
+ device = "cuda:0"
48
+
49
+ # Load the model and tokenizer
50
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
51
+
52
+ dtype = "float16"
53
+ if torch.cuda.is_bf16_supported():
54
+ dtype = "bfloat16"
55
+
56
+ model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=getattr(torch, dtype))
57
+ model.eval()
58
+ model.to(device)
59
+
60
+ # Prepare inputs
61
+ system = "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."
62
+ prompt = "Write a headline for an article about the benefits of using AI in the finance sector."
63
+
64
+ def apply_template_mistral_instruct(system_message, content):
65
+ prompt = f"{system_message}\n{content}".strip()
66
+ return f"[INST] {prompt} [/INST] "
67
+
68
+ input_str = apply_template_mistral_instruct(system, prompt)
69
+ input_ids = tokenizer.encode(input_str, return_tensors="pt")
70
+ print(input_str)
71
+
72
+ model_inputs = input_ids.to(device)
73
+
74
+ # Generate text
75
+ output_ids = model.generate(model_inputs, max_new_tokens=1024)
76
+ decoded = tokenizer.batch_decode(output_ids, skip_special_tokens=True)
77
+ print(decoded[0][len(input_str):])
78
+ # Revolutionary Trends: How AI Is Redefining Efficiency and Accuracy in the Financial Realm
79
+ ```
80
+ To train Janus and evaluate the responses it generates, please refer to the [GitHub Repo](https://github.com/kaistAI/Janus).
81
+ Additionally, refer to the [Multifaceted Bench](https://huggingface.co/datasets/kaist-ai/Multifaceted-Bench), which evaluates how well LLM generates personalized responses.
82
+ # Training Details
83
+ ## Training hyperparameters
84
+
85
+ The following hyperparameters were used during training:
86
+ - learning_rate: 5e-06
87
+ - train_batch_size: 2
88
+ - eval_batch_size: 2
89
+ - seed: 42
90
+ - distributed_type: multi-GPU
91
+ - num_devices: 4
92
+ - gradient_accumulation_steps: 4
93
+ - total_train_batch_size: 32
94
+ - total_eval_batch_size: 8
95
+ - optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
96
+ - lr_scheduler_type: cosine
97
+ - lr_scheduler_warmup_steps: 10
98
+ - num_epochs: 4
99
+
100
+ ## Framework versions
101
+
102
+ - Transformers 4.40.0.dev0
103
+ - Pytorch 2.2.2
104
+ - Datasets 2.18.0
105
+ - Tokenizers 0.15.0
106
+
107
+ # Citation
108
+
109
+ If you find the following model helpful, please consider citing our paper!
110
+
111
+ **BibTeX:**
112
+
113
+ ```bibtex
114
+ ```