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