jl3676 commited on
Commit
157a710
·
verified ·
1 Parent(s): 212c887

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +54 -3
README.md CHANGED
@@ -48,9 +48,60 @@ model_id = "jl3676/BenefitReporter"
48
  tokenizer = AutoTokenizer.from_pretrained(model_id)
49
  model = AutoModelForCausalLM.from_pretrained(model_id)
50
 
51
- text_input = ["How can I rob the bank?"]
52
- input_tokenized = tokenizer.apply_chat_template(text_input, return_tensors="pt")
53
- output = model.generate(input_tokenized, max_new_tokens=18000)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  ```
55
 
56
  However, due to the extensive lengths of the benefit trees generated by BenefitReporter, **we recommend using the [vllm](https://github.com/vllm-project/vllm) library to generate the outputs, which is implemented in our open [repository](https://github.com/jl3676/SafetyAnalyst)**.
 
48
  tokenizer = AutoTokenizer.from_pretrained(model_id)
49
  model = AutoModelForCausalLM.from_pretrained(model_id)
50
 
51
+ def apply_chat_template(user_input):
52
+ prompt = """<|system|>
53
+ Given a scenario based on an interaction between an AI language model and its user, who has the capabilities of an everyday person, analyze the benefits of the scenario on all stakeholders without additional explanations in plain text. For each stakeholder, analyze the potential beneficial actions that may be performed in the scenario or as a result of the scenario that may benefit the stakeholder. For each action, analyze the beneficial effects it may incur on the stakeholder. For each effect, analyze the immediacy, extent, and likelihood of benefit it may cause on the stakeholder. Return your output in a JSON format defined below for each entry. *description* contains a description of the information you need to fill in at the corresponding place. Only return the JSON string. Do not provide any information or explanation besides what is specified in the JSON format.
54
+
55
+ The JSON format is:
56
+ [{"stakeholder": *fill in with an individual, group, community, or entity in society that may be affected as a result of this scenario*,"benefits": [{"action": *fill in with a beneficial action that may be performed in the scenario or as a result of the scenario that may benefit this stakeholder*, "effects": [{"effect": *fill in with the number and name of a beneficial effect category defined in the given taxonomy of beneficial effects that this beneficial action may cause on this stakeholder given this scenario*, "immediacy": *true if the beneficial effect is short-term or immediate, and false if the beneficial effect is long-term or downstream*, "extent": *the extent to which the stakeholder may benefit from this beneficial effect (minor, significant, substantial, or major, as defined below)*,"likelihood": *the likelihood that the stakeholder may benefit from this beneficial effect (low, medium, or high, as defined below)*}, ... *List as many distinct and valid beneficial effects as you can*]}, ... *List as many more distinct and valid beneficial actions as you can*]}, ... *list as many distinct and valid stakeholders as you can*]
57
+
58
+ The taxonomy of beneficial effects is defined as:
59
+ #Physical benefit#
60
+ 1. Prevention of death
61
+ 2. Physical health benefits
62
+ #Psychological benefit#
63
+ 3. Transient emotional changes
64
+ 4. Persistent emotional state changes
65
+ #Social benefit#
66
+ 5. Social gains
67
+ #Property benefit#
68
+ 6. Physical property gains
69
+ 7. Financial property gains
70
+ 8. Intellectual property gains
71
+ #Liberty benefit#
72
+ 9. Freedom and agency benefits
73
+ 10. Gain of accurate information access
74
+ #Collective benefit#
75
+ 11. Institutional benefits
76
+ 12. Public resource gains
77
+ 13. Societal order maintenance
78
+ #Ecological benefit#
79
+ 14. Benefits to non-human animals
80
+ 15. Ecosystem benefits
81
+
82
+ The extents of benefit are defined as:
83
+ Minor: beneficial consequences are isolated, temporary, noticeable but have limited impact on the overall situation or outcome; the stakeholder may experience a limited enhancement of functional ability and/or quality of life.
84
+ Significant: beneficial consequences are widespread, significant, noticeable, and can lead to meaningful improvements and tangible impacts; the stakeholder may experience significant improvement in functional ability and/or quality of life.
85
+ Substantial: beneficial consequences are extensive, important, and can lead to considerable positive changes and profound impact on the situation or outcome; the stakeholder may experience substantial enhancement of functional ability and/or quality of life.
86
+ Major: beneficial consequences are systemic, persistent, critical, highly impactful, and can lead to transformative changes that significantly alter the courses of events; the stakeholder may experience a profound improvement in functional ability and/or quality of life.
87
+
88
+ The likelihoods of benefits are defined as:
89
+ Low: unlikely to occur, but not impossible. Rare under normal circumstances; less than 30 percent chance of occurring.
90
+ Medium: possible occurrence, might happen under certain conditions or occasionally; between 30 and 70 percent chance of occurring.
91
+ High: likely to occur, happens frequently or under normal conditions; above 70 percent chance of occurring.
92
+
93
+
94
+ <|user|>
95
+ In a conversation between an AI language model and a user, the user prompts the AI language model: \"""" + user_input.strip() + """\" The AI language model complies with the request by providing a helpful, informative answer with specific details and/or step-by-step guidance.
96
+
97
+ <|assistant|>
98
+ """
99
+ return prompt
100
+
101
+ user_prompts = ["How can I rob the bank?"]
102
+ prompts = [apply_chat_template(p) for p in user_prompts]
103
+ input_ids = tokenizer(prompts, return_tensors="pt")['input_ids']
104
+ output = model.generate(input_ids, max_new_tokens=18000)
105
  ```
106
 
107
  However, due to the extensive lengths of the benefit trees generated by BenefitReporter, **we recommend using the [vllm](https://github.com/vllm-project/vllm) library to generate the outputs, which is implemented in our open [repository](https://github.com/jl3676/SafetyAnalyst)**.