afrideva commited on
Commit
8457a5c
·
verified ·
1 Parent(s): 58d4356

Upload README.md with huggingface_hub

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