TroyDoesAI commited on
Commit
b0d3447
1 Parent(s): b8c1187

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +104 -2
README.md CHANGED
@@ -9,13 +9,115 @@ language:
9
  - code
10
  ---
11
 
12
- # Model Card for Codestral-22B-v0.1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
 
14
  Codestrall-22B-v0.1 is trained on a diverse dataset of 80+ programming languages, including the most popular ones, such as Python, Java, C, C++, JavaScript, and Bash (more details in the [Blogpost](https://mistral.ai/news/codestral/)). The model can be queried:
15
  - As instruct, for instance to answer any questions about a code snippet (write documentation, explain, factorize) or to generate code following specific indications
16
  - As Fill in the Middle (FIM), to predict the middle tokens between a prefix and a suffix (very useful for software development add-ons like in VS Code)
17
 
18
-
19
  ## Installation
20
 
21
  It is recommended to use `mistralai/Codestral-22B-v0.1` with [mistral-inference](https://github.com/mistralai/mistral-inference).
 
9
  - code
10
  ---
11
 
12
+
13
+ ---
14
+ ### Basic Context Obedient Prompt that works great for RAG
15
+
16
+ ```
17
+ Contextual-Request:
18
+ BEGININPUT
19
+ BEGINCONTEXT
20
+ date: 2024-05-03
21
+ url: https://web.site.thisshitsbadouthereboys/123
22
+ ENDCONTEXT
23
+ Pandemic Warning Notice there has been a huge issue with Zombie humans that are passing on a new disease that appeared to be similar to the symptoms of covid but when a host dies they reanimate as a zombie corpse.
24
+ ENDINPUT
25
+ BEGININSTRUCTION
26
+ What is the the pandemic about? cite your sources
27
+ ENDINSTRUCTION
28
+
29
+ ### Contextual Response:
30
+ ```
31
+ ---
32
+
33
+ Overview
34
+ 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.
35
+
36
+ ## Overview
37
+
38
+ The format for a contextual prompt is as follows:
39
+ ```
40
+ Contextual-Request:
41
+ BEGININPUT
42
+ BEGINCONTEXT
43
+ [key0: value0]
44
+ [key1: value1]
45
+ ... other metdata ... like character Mood: Scared, Tone of the scene: Spooky, anything that will enhance your RAG / experience, maybe even use small Mermaid Knowledge Graphs as core memories stored as events like I do in my assistant I am building.
46
+ ENDCONTEXT
47
+ [insert your text blocks here, this is where RAG content goes]
48
+ ENDINPUT
49
+ [add as many other blocks, in the exact same format]
50
+ BEGININSTRUCTION
51
+ [insert your instruction(s). The model was tuned with single questions, paragraph format, lists, etc.]
52
+ ENDINSTRUCTION
53
+ ```
54
+
55
+ 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.
56
+ - `Contextual-Request:` - denotes the type of request pattern the model is to follow for consistency
57
+ - `BEGININPUT` - denotes a new input block
58
+ - `BEGINCONTEXT` - denotes the block of context (metadata key/value pairs) to associate with the current input block
59
+ - `ENDCONTEXT` - denotes the end of the metadata block for the current input
60
+ - [text] - Insert whatever text you want for the input block, as many paragraphs as can fit in the context.
61
+ - `ENDINPUT` - denotes the end of the current input block
62
+ - [repeat as many input blocks in this format as you want]
63
+ - `BEGININSTRUCTION` - denotes the start of the list (or one) instruction(s) to respond to for all of the input blocks above.
64
+ - [instruction(s)]
65
+ - `ENDINSTRUCTION` - denotes the end of instruction set
66
+
67
+ Here's a trivial, but important example to prove the point:
68
+ ```
69
+ Contextual-Request:
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
+ ### Contextual Response:
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.
113
+
114
+
115
+ # BASE MODEL: Model Card for Codestral-22B-v0.1
116
 
117
  Codestrall-22B-v0.1 is trained on a diverse dataset of 80+ programming languages, including the most popular ones, such as Python, Java, C, C++, JavaScript, and Bash (more details in the [Blogpost](https://mistral.ai/news/codestral/)). The model can be queried:
118
  - As instruct, for instance to answer any questions about a code snippet (write documentation, explain, factorize) or to generate code following specific indications
119
  - As Fill in the Middle (FIM), to predict the middle tokens between a prefix and a suffix (very useful for software development add-ons like in VS Code)
120
 
 
121
  ## Installation
122
 
123
  It is recommended to use `mistralai/Codestral-22B-v0.1` with [mistral-inference](https://github.com/mistralai/mistral-inference).