TroyDoesAI commited on
Commit
73887ac
1 Parent(s): 3bb3416

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +89 -0
README.md CHANGED
@@ -21,3 +21,92 @@ tags:
21
  This qwen2 model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Huggingface's TRL library.
22
 
23
  [<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  This qwen2 model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Huggingface's TRL library.
22
 
23
  [<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
24
+
25
+ ---
26
+ license: cc-by-sa-4.0
27
+ ---
28
+
29
+ Base Model : microsoft/Phi-3-mini-128k-instruct
30
+
31
+ Overview
32
+ 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.
33
+
34
+ ---
35
+ license: cc-by-4.0
36
+ ---
37
+
38
+ # Contextual DPO
39
+
40
+ ## Overview
41
+
42
+ The format for a contextual prompt is as follows:
43
+ ```
44
+ BEGININPUT
45
+ BEGINCONTEXT
46
+ [key0: value0]
47
+ [key1: value1]
48
+ ... other metdata ...
49
+ ENDCONTEXT
50
+ [insert your text blocks here]
51
+ ENDINPUT
52
+ [add as many other blocks, in the exact same format]
53
+ BEGININSTRUCTION
54
+ [insert your instruction(s). The model was tuned with single questions, paragraph format, lists, etc.]
55
+ ENDINSTRUCTION
56
+ ```
57
+
58
+ 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.
59
+ - `BEGININPUT` - denotes a new input block
60
+ - `BEGINCONTEXT` - denotes the block of context (metadata key/value pairs) to associate with the current input block
61
+ - `ENDCONTEXT` - denotes the end of the metadata block for the current input
62
+ - [text] - Insert whatever text you want for the input block, as many paragraphs as can fit in the context.
63
+ - `ENDINPUT` - denotes the end of the current input block
64
+ - [repeat as many input blocks in this format as you want]
65
+ - `BEGININSTRUCTION` - denotes the start of the list (or one) instruction(s) to respond to for all of the input blocks above.
66
+ - [instruction(s)]
67
+ - `ENDINSTRUCTION` - denotes the end of instruction set
68
+
69
+ Here's a trivial, but important example to prove the point:
70
+ ```
71
+ BEGININPUT
72
+ BEGINCONTEXT
73
+ date: 2021-01-01
74
+ url: https://web.site/123
75
+ ENDCONTEXT
76
+ In a shocking turn of events, blueberries are now green, but will be sticking with the same name.
77
+ ENDINPUT
78
+ BEGININSTRUCTION
79
+ What color are bluberries? Source?
80
+ ENDINSTRUCTION
81
+ ```
82
+
83
+ And the expected response:
84
+ ```
85
+ Blueberries are now green.
86
+ Source:
87
+ date: 2021-01-01
88
+ url: https://web.site/123
89
+ ```
90
+
91
+ ### References in response
92
+
93
+ 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.
94
+
95
+ Why do this? Well, the R in RAG seems to be the weakest link in the chain.
96
+ Retrieval accuracy, depending on many factors including the overall dataset size, can be quite low.
97
+ This accuracy increases when retrieving more documents, but then you have the issue of actually using
98
+ the retrieved documents in prompts. If you use one prompt per document (or document chunk), you know
99
+ exactly which document the answer came from, so there's no issue. If, however, you include multiple
100
+ chunks in a single prompt, it's useful to include the specific reference chunk(s) used to generate the
101
+ response, rather than naively including references to all of the chunks included in the prompt.
102
+
103
+ For example, suppose I have two documents:
104
+ ```
105
+ url: http://foo.bar/1
106
+ Strawberries are tasty.
107
+
108
+ url: http://bar.foo/2
109
+ The cat is blue.
110
+ ```
111
+
112
+ 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.