TroyDoesAI commited on
Commit
9d670de
1 Parent(s): 6228439

Update README.md

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