TroyDoesAI commited on
Commit
bcdf65a
·
verified ·
1 Parent(s): 9b57e04

Update README.md

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