TroyDoesAI commited on
Commit
53b39bf
1 Parent(s): c642ab6

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: cc-by-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
+ ## Overview
13
+
14
+ The format for a contextual prompt is as follows:
15
+ ```
16
+ Contextual-Request:
17
+ BEGININPUT
18
+ BEGINCONTEXT
19
+ [key0: value0]
20
+ [key1: value1]
21
+ ... other metdata ...
22
+ ENDCONTEXT
23
+ [insert your text blocks here]
24
+ ENDINPUT
25
+ [add as many other blocks, in the exact same format]
26
+ BEGININSTRUCTION
27
+ [insert your instruction(s). The model was tuned with single questions, paragraph format, lists, etc.]
28
+ ENDINSTRUCTION
29
+ ```
30
+
31
+ 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.
32
+ - `Contextual-Request:` - denotes the type of request pattern the model is to follow for consistency
33
+ - `BEGININPUT` - denotes a new input block
34
+ - `BEGINCONTEXT` - denotes the block of context (metadata key/value pairs) to associate with the current input block
35
+ - `ENDCONTEXT` - denotes the end of the metadata block for the current input
36
+ - [text] - Insert whatever text you want for the input block, as many paragraphs as can fit in the context.
37
+ - `ENDINPUT` - denotes the end of the current input block
38
+ - [repeat as many input blocks in this format as you want]
39
+ - `BEGININSTRUCTION` - denotes the start of the list (or one) instruction(s) to respond to for all of the input blocks above.
40
+ - [instruction(s)]
41
+ - `ENDINSTRUCTION` - denotes the end of instruction set
42
+
43
+ Here's a trivial, but important example to prove the point:
44
+ ```
45
+ Contextual-Request:
46
+ BEGININPUT
47
+ BEGINCONTEXT
48
+ date: 2021-01-01
49
+ url: https://web.site/123
50
+ ENDCONTEXT
51
+ In a shocking turn of events, blueberries are now green, but will be sticking with the same name.
52
+ ENDINPUT
53
+ BEGININSTRUCTION
54
+ What color are bluberries? Source?
55
+ ENDINSTRUCTION
56
+ ```
57
+
58
+ And the expected response:
59
+ ```
60
+ ### Contextual Response:
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.