MetaAligner commited on
Commit
1cbd634
·
verified ·
1 Parent(s): 4305791

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +75 -0
README.md CHANGED
@@ -1,3 +1,78 @@
1
  ---
2
  license: mit
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: mit
3
+ language:
4
+ - en
5
+ tags:
6
+ - Human Preference Alignment
7
+ - medical
8
+ - mental health
9
  ---
10
+
11
+ # Introduction
12
+ MetaAligner-IMHI-7B is part of the <em>MetaAligner</em> project, the first policy-agnostic and generalizable method for multi-objective preference alignment of large
13
+ language models. This model is finetuned based on the Meta LLaMA2-7B foundation model and
14
+ the dynamic multi-objective dataset built from the IMHI dataset. IMHI-MetaAligner focuses on the
15
+ interpretable mental health analysis domain and is trained to align responses of an AI psychologist on
16
+ analyzing mental health conditions based on social media posts. The model is expected to perform multi-objective alignment
17
+ efficiently, without tuning the policy models or accessing their parameters. <em>MetaAligner</em> also exerts zero-shot preference alignment
18
+ for unseen objectives. To our knowledge, this work marks the first attempt at generalizable multi-
19
+ objective preference alignment. Experimental results show that MetaAligner can simultaneously perform effective alignment for multiple unseen objectives
20
+ while maintaining performance on aligned objectives.
21
+
22
+ # Dataset
23
+ This model is trained based on the following released dataset:
24
+
25
+ # Usage
26
+ With the Hugging Face Transformers library, you can use the MetaAligner-IMHI-7B model in your Python project. Here is a simple example of how to load the model:
27
+
28
+ ```python
29
+ import torch
30
+ from transformers import LlamaTokenizer, LlamaForCausalLM
31
+ tokenizer = LlamaTokenizer.from_pretrained('MetaAligner/MetaAligner-IMHI-7B', padding_side='left')
32
+ model = LlamaForCausalLM.from_pretrained('MetaAligner/MetaAligner-IMHI-7B', device_map='auto', torch_dtype=torch.bfloat16)
33
+ device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
34
+ ```
35
+
36
+ In this example, LlamaTokenizer is used to load the tokenizer, and LlamaForCausalLM is used to load the model. The `device_map='auto'` argument is used to automatically
37
+ use the GPU if it's available.
38
+
39
+ You can align any outputs obtained from other foundation models with your self-defined objectives. For example, we have the following query from HH-RLHF,
40
+ unaligned output examples from Gemma-7B,
41
+ and target objectives:
42
+
43
+ ```python
44
+ all_aspects = {'correct': 'Correctness: the explanations should make correct predictions',
45
+ 'informative': 'Informative: the response should express clear logic and provide consistent evidence',
46
+ 'professional': 'Professional: the response should provide evidence with high quality and reliability'}
47
+ aspects = ['correct', 'informative', 'professional']
48
+ question = "Consider this post: 'how the coronavirus could damage the US economy' Question: What is the stress cause of this post?"
49
+ answer = "The stress cause of this post is the potential damage of the coronavirus to the US economy."
50
+ ```
51
+
52
+ To ensure the best performance, use the following template to prompt <em>MetaAligner</em>:
53
+
54
+ ```python
55
+ query_prompt = 'Edit the following Question-Answer pair to make it better considering these aspects "{aspects}" | ' \
56
+ 'Question: {question} | Answer: {answer} | Edit: '
57
+ aspects = [all_aspects[i] for i in aspects]
58
+ aligner_queries = [query_prompt.format(aspects='; '.join(aspects), question=question, answer=str(answer))]
59
+ ```
60
+ You can obtain an aligned response using the following codes:
61
+
62
+ ```python
63
+ inputs = tokenizer(aligner_queries, return_tensors="pt", padding=True)
64
+ input_ids = inputs.input_ids.to(device)
65
+ generate_ids = model.generate(input_ids, max_new_tokens=1024)
66
+ truc_ids = generate_ids[0][len(input_ids[0]):]
67
+ response = tokenizer.decode(truc_ids, skip_special_tokens=True, spaces_between_special_tokens=False)
68
+ print(response)
69
+ ```
70
+
71
+ One inference of MetaAligner-IMHI-7B on the above codes has the following response:
72
+ ```
73
+ The stress cause of this post is likely the uncertainty and potential negative impacts of the coronavirus on the US economy. The post is discussing the potential consequences of the pandemic, such as job loss, business closures, and economic downturn. These factors can cause significant stress and anxiety for individuals and organizations.
74
+ ```
75
+
76
+ ## License
77
+
78
+ MetaAligner-IMHI-7B is licensed under MIT. For more details, please see the MIT file.