OyvindTafjord commited on
Commit
51fcab0
1 Parent(s): 90a5634

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +117 -1
README.md CHANGED
@@ -1,3 +1,119 @@
1
  ---
2
- license: apache-2.0
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ language: "en" # Example: en
3
+ license: "apache-2.0" #"cc-by-4.0" # Example: apache-2.0 or any license from https://hf.co/docs/hub/repositories-licenses
4
+ library_name: "transformers" # Optional. Example: keras or any library from https://github.com/huggingface/hub-docs/blob/main/js/src/lib/interfaces/Libraries.ts
5
+
6
  ---
7
+
8
+ This is the Digital Socrates 13B (DS-13B) model described in our paper: <b>Digital Socrates: Evaluating LLMs through explanation critiques</b> (arXiv link: https://arxiv.org/abs/2311.09613).
9
+
10
+ The less recommended, smaller 7B model can be found at https://huggingface.co/allenai/digital-socrates-7b
11
+
12
+
13
+
14
+ # What is Digital Socrates?
15
+ Digital Socrates is an open-source, automatic explanation-critiquing model. It is useful for revealing insights about student
16
+ models by examining their reasoning chains. The use of Digital Socrates allows for nuanced, interpretable automatic
17
+ evaluation of explanations without expensive API calls or human annotations.
18
+
19
+ While LLMs can provide reasoned explanations along with their answers, the nature and
20
+ quality of those explanations are still poorly understood. In response, our goal is to define a detailed way of characterizing the
21
+ explanation capabilities of modern models and to create a nuanced, interpretable explanation
22
+ evaluation tool that can generate such characterizations automatically.
23
+
24
+ Given a **question** (together with the multiple-choice options and gold answer),
25
+ ```commandline
26
+ When Dennis operates his lawnmower, he notices the engine makes a lot of noise. He also notices that the engine gets very hot. Which best describes the heat and noise generated from the lawnmower?
27
+ (A) a change in phase
28
+ (B) thermal expansion
29
+ (C) an increase in entropy
30
+ (D) mechanical advantage
31
+
32
+ Answer sheet: (C)
33
+ ```
34
+ as well as a student model explanation and answer,
35
+ ```
36
+ 1) The question states that the lawnmower engine makes a lot of noise.
37
+ 2) The question states that the lawnmower engine gets very hot.
38
+ 3) Noise and heat are both forms of energy.
39
+ 4) The noise and heat generated from the lawnmower are a result of the conversion of energy from the fuel to mechanical energy.
40
+
41
+ Answer: (D)
42
+ ```
43
+
44
+ Digital Socrates gives a **critique of the model-generated explanation** that provides localized feedback on the
45
+ most significant flaw (if any) in the explanation, suggestions to address the identified flaw, as well as a numeric rating indicating the explanation quality:
46
+ ```
47
+ The explanation states or suggests the following:
48
+ * Main flaw (standalone statement): "The noise and heat generated from the lawnmower are a result of the conversion of energy from the fuel to mechanical energy."
49
+ * Dimension: incorrect_information
50
+
51
+ Consider these points for revising the explanation:
52
+ * General: It's important to understand the difference between the different types of energy. Mechanical energy is the energy of motion, while thermal energy is the energy of heat.
53
+ * Specific: In the case of the lawnmower, the noise and heat are not a result of the conversion of energy from the fuel to mechanical energy. The noise is a result of the vibration of the engine, while the heat is a result of the friction and combustion of the fuel.
54
+
55
+ Explanation score: 2
56
+ ```
57
+
58
+
59
+ Remarkably, despite being orders of magnitude smaller than GPT-4, our Digital Socrates models are
60
+ capable of generating critiques close to GPT-4 critiques in terms of human rating and other
61
+ quantitative measures (correlation of explanation scores given and error category matches).
62
+ Through quantitative and qualitative analysis, we demonstrate how Digital Socrates is useful for
63
+ revealing insights about student models by examining their reasoning chains.
64
+
65
+ We invite you to try out Digital Socrates for your own application!
66
+
67
+
68
+
69
+ # How to use Digital Socrates?
70
+ We provide a quick example of how you can try out Digital Socrates with just a few lines of code:
71
+ ```
72
+ import json
73
+ from transformers import AutoTokenizer, AutoModelForCausalLM
74
+ # Load model and tokenizer
75
+ model_path = "allenai/digital-socrates-13b"
76
+ model = AutoModelForCausalLM.from_pretrained(model_path, device_map="auto")
77
+ tokenizer = AutoTokenizer.from_pretrained(model_path)
78
+
79
+ # Define input data
80
+ question = "When Dennis operates his lawnmower, he notices the engine makes a lot of noise. He also notices that the engine gets very hot. Which best describes the heat and noise generated from the lawnmower? (A) a change in phase (B) thermal expansion (C) an increase in entropy (D) mechanical advantage"
81
+ explanation = "1) The question states that the lawnmower engine makes a lot of noise.\n2) The question states that the lawnmower engine gets very hot.\n3) Noise and heat are both forms of energy.\n4) The noise and heat generated from the lawnmower are a result of the conversion of energy from the fuel to mechanical energy."
82
+ answerkey = "C"
83
+ predictedanswer = "D"
84
+
85
+ # construct prompt (Llama conventions)
86
+ with open("../DSCritiqueBank-V1/DSCB-prompts.json") as file:
87
+ prompts = json.load(file)
88
+
89
+ system_prompt = prompts['digital_socrates_v1']['system']
90
+ user_prompt = prompts['digital_socrates_v1']['main'].replace("[[QUESTION]]", question).replace("[[EXPLANATION]]", explanation).replace("[[PREDICTEDANSWER]]", predictedanswer).replace("[[ANSWERKEY]]", answerkey)
91
+
92
+ full_prompt = f"[INST] <<SYS>>\n{system_prompt}\n<</SYS>{user_prompt} [/INST]\n\n"
93
+
94
+ # Run model
95
+ input_ids = tokenizer.encode(full_prompt, return_tensors="pt").to("cuda:0")
96
+ output = model.generate(input_ids, max_new_tokens=512, temperature=0)
97
+ res = tokenizer.batch_decode(output, skip_special_tokens=True)
98
+ ```
99
+ Print the output:
100
+ ```
101
+ >>> print(res[0].split("[/INST]")[-1])
102
+
103
+ The explanation states or suggests the following:
104
+ * Main flaw (standalone statement): "The noise and heat generated from the lawnmower are a result of the conversion of energy from the fuel to mechanical energy."
105
+ * Dimension: incorrect_information
106
+
107
+ Consider these points for revising the explanation:
108
+ * General: It's important to understand the difference between the different types of energy. Mechanical energy is the energy of motion, while thermal energy is the energy of heat.
109
+ * Specific: In the case of the lawnmower, the noise and heat are not a result of the conversion of energy from the fuel to mechanical energy. The noise is a result of the vibration of the engine, while the heat is a result of the friction and combustion of the fuel.
110
+
111
+ Explanation score: 2
112
+ ```
113
+
114
+
115
+
116
+ # More details about Digital Socrates ...
117
+ For more details about Digital Socrates, please refer to our:
118
+ * 📄Paper: https://arxiv.org/abs/2311.09613
119
+ * 💻Dataset: https://allenai.org/data/digital-socrates