TroyDoesAI commited on
Commit
f3b8374
·
verified ·
1 Parent(s): eb961dd

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +88 -3
README.md CHANGED
@@ -1,3 +1,88 @@
1
- ---
2
- license: artistic-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: artistic-2.0
3
+ ---
4
+
5
+ Base Model : TroyDoesAI/BlackSheep-4B
6
+
7
+ Overview
8
+ This model is meant to enhance adherence to provided context (e.g., for RAG applications) and reduce hallucinations, inspired by airoboros context-obedient question answer format.
9
+
10
+ ---
11
+ license: cc-by-4.0
12
+ ---
13
+
14
+ # Contextual DPO
15
+
16
+ ## Overview
17
+
18
+ The format for a contextual prompt is as follows:
19
+ ```
20
+ BEGININPUT
21
+ BEGINCONTEXT
22
+ [key0: value0]
23
+ [key1: value1]
24
+ ... other metdata ...
25
+ ENDCONTEXT
26
+ [insert your text blocks here]
27
+ ENDINPUT
28
+ [add as many other blocks, in the exact same format]
29
+ BEGININSTRUCTION
30
+ [insert your instruction(s). The model was tuned with single questions, paragraph format, lists, etc.]
31
+ ENDINSTRUCTION
32
+ ```
33
+
34
+ I know it's a bit verbose and annoying, but after much trial and error, using these explicit delimiters helps the model understand where to find the responses and how to associate specific sources with it.
35
+ - `BEGININPUT` - denotes a new input block
36
+ - `BEGINCONTEXT` - denotes the block of context (metadata key/value pairs) to associate with the current input block
37
+ - `ENDCONTEXT` - denotes the end of the metadata block for the current input
38
+ - [text] - Insert whatever text you want for the input block, as many paragraphs as can fit in the context.
39
+ - `ENDINPUT` - denotes the end of the current input block
40
+ - [repeat as many input blocks in this format as you want]
41
+ - `BEGININSTRUCTION` - denotes the start of the list (or one) instruction(s) to respond to for all of the input blocks above.
42
+ - [instruction(s)]
43
+ - `ENDINSTRUCTION` - denotes the end of instruction set
44
+
45
+ Here's a trivial, but important example to prove the point:
46
+ ```
47
+ BEGININPUT
48
+ BEGINCONTEXT
49
+ date: 2021-01-01
50
+ url: https://web.site/123
51
+ ENDCONTEXT
52
+ In a shocking turn of events, blueberries are now green, but will be sticking with the same name.
53
+ ENDINPUT
54
+ BEGININSTRUCTION
55
+ What color are bluberries? Source?
56
+ ENDINSTRUCTION
57
+ ```
58
+
59
+ And the expected response:
60
+ ```
61
+ Blueberries are now green.
62
+ Source:
63
+ date: 2021-01-01
64
+ url: https://web.site/123
65
+ ```
66
+
67
+ ### References in response
68
+
69
+ As shown in the example, the dataset includes many examples of including source details in the response, when the question asks for source/citation/references.
70
+
71
+ Why do this? Well, the R in RAG seems to be the weakest link in the chain.
72
+ Retrieval accuracy, depending on many factors including the overall dataset size, can be quite low.
73
+ This accuracy increases when retrieving more documents, but then you have the issue of actually using
74
+ the retrieved documents in prompts. If you use one prompt per document (or document chunk), you know
75
+ exactly which document the answer came from, so there's no issue. If, however, you include multiple
76
+ chunks in a single prompt, it's useful to include the specific reference chunk(s) used to generate the
77
+ response, rather than naively including references to all of the chunks included in the prompt.
78
+
79
+ For example, suppose I have two documents:
80
+ ```
81
+ url: http://foo.bar/1
82
+ Strawberries are tasty.
83
+
84
+ url: http://bar.foo/2
85
+ The cat is blue.
86
+ ```
87
+
88
+ If the question being asked is `What color is the cat?`, I would only expect the 2nd document to be referenced in the response, as the other link is irrelevant.