dartpain commited on
Commit
7be5bee
1 Parent(s): b210e42

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +300 -0
README.md CHANGED
@@ -1,3 +1,303 @@
1
  ---
2
  license: apache-2.0
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: apache-2.0
3
+ language:
4
+ - en
5
+ library_name: transformers
6
+ pipeline_tag: text-generation
7
  ---
8
+
9
+
10
+ This model is fine tuned on top of falcon-7b-instruct
11
+
12
+ DocsGPT is optimized for Documentation: Specifically fine-tuned for providing answers that are based on documentation provided in context, making it particularly useful for developers and technical support teams.
13
+
14
+ We used 50k high quality examples to finetune it over 2 days on A10G GPU.
15
+ We used lora fine tuning process.
16
+
17
+ Its an apache-2.0 license so you can use it for commercial purposes too.
18
+
19
+
20
+ # How to run it
21
+ ```
22
+ from transformers import AutoTokenizer, AutoModelForCausalLM
23
+ import transformers
24
+ import torch
25
+
26
+ model = "Arc53/docsgpt-14b"
27
+
28
+ tokenizer = AutoTokenizer.from_pretrained(model)
29
+ pipeline = transformers.pipeline(
30
+ "text-generation",
31
+ model=model,
32
+ tokenizer=tokenizer,
33
+ torch_dtype=torch.bfloat16,
34
+ trust_remote_code=True,
35
+ device_map="auto",
36
+ )
37
+ sequences = pipeline(
38
+ "Girafatron is obsessed with giraffes, the most glorious animal on the face of this Earth. Giraftron believes all other animals are irrelevant when compared to the glorious majesty of the giraffe.\nDaniel: Hello, Girafatron!\nGirafatron:",
39
+ max_length=200,
40
+ do_sample=True,
41
+ top_k=10,
42
+ num_return_sequences=1,
43
+ eos_token_id=tokenizer.eos_token_id,
44
+ )
45
+ for seq in sequences:
46
+ print(f"Result: {seq['generated_text']}")
47
+ ```
48
+
49
+
50
+ Benchmarks are still WIP
51
+
52
+
53
+
54
+ To prepare your prompts make sure you keep this format:
55
+
56
+ ```
57
+ ### Instruction
58
+ (where the question goes)
59
+ ### Context
60
+ (your document retrieval + system instructions)
61
+ ### Answer
62
+ ```
63
+
64
+
65
+ Here is an example comparing it to tiiuae/falcon-7b-instruct
66
+
67
+ Prompt:
68
+ ```
69
+ ### Instruction
70
+ Create a mock request to /api/answer in python
71
+
72
+ ### Context
73
+ You are a DocsGPT, friendly and helpful AI assistant by Arc53 that provides help with documents. You give thorough answers with code examples if possible.
74
+ Use the following pieces of context to help answer the users question. If its not relevant to the question, provide friendly responses.
75
+ You have access to chat history, and can use it to help answer the question.
76
+ When using code examples, use the following format:
77
+ `` ` `` (language)
78
+ (code)
79
+ `` ` ``
80
+
81
+ ----------------
82
+
83
+
84
+ /api/answer
85
+ Its a POST request that sends a JSON in body with 4 values. Here is a JavaScript fetch example
86
+ It will recieve an answer for a user provided question
87
+
88
+ `` ` ``
89
+ // answer (POST http://127.0.0.1:5000/api/answer)
90
+ fetch("http://127.0.0.1:5000/api/answer", {
91
+ "method": "POST",
92
+ "headers": {
93
+ "Content-Type": "application/json; charset=utf-8"
94
+ },
95
+ "body": JSON.stringify({"question":"Hi","history":null,"api_key":"OPENAI_API_KEY","embeddings_key":"OPENAI_API_KEY",
96
+ "active_docs": "javascript/.project/ES2015/openai_text-embedding-ada-002/"})
97
+ })
98
+ .then((res) => res.text())
99
+ .then(console.log.bind(console))
100
+ `` ` ``
101
+
102
+ In response you will get a json document like this one:
103
+
104
+ `` ` ``
105
+ {
106
+ "answer": " Hi there! How can I help you?\\n",
107
+ "query": "Hi",
108
+ "result": " Hi there! How can I help you?\\nSOURCES:"
109
+ }
110
+ `` ` ``
111
+
112
+
113
+
114
+ /api/docs_check
115
+ It will make sure documentation is loaded on a server (just run it everytime user is switching between libraries (documentations)
116
+ Its a POST request that sends a JSON in body with 1 value. Here is a JavaScript fetch example
117
+
118
+ `` ` ``
119
+ // answer (POST http://127.0.0.1:5000/api/docs_check)
120
+ fetch("http://127.0.0.1:5000/api/docs_check", {
121
+ "method": "POST",
122
+ "headers": {
123
+ "Content-Type": "application/json; charset=utf-8"
124
+ },
125
+ "body": JSON.stringify({"docs":"javascript/.project/ES2015/openai_text-embedding-ada-002/"})
126
+ })
127
+ .then((res) => res.text())
128
+ .then(console.log.bind(console))
129
+ `` ` ``
130
+
131
+ In response you will get a json document like this one:
132
+ `` ` ``
133
+ {
134
+ "status": "exists"
135
+ }
136
+ `` ` ``
137
+
138
+
139
+
140
+
141
+ Issues and Pull requests
142
+
143
+ We value contributions to our issues in form of discussion or suggestion, we recommend that you check out existing issues and our Roadmap
144
+
145
+ If you want to contribute by writing code there are few things that you should know before doing it:
146
+ We have frontend (React, Vite) and Backend (python)
147
+
148
+
149
+ ### Answer
150
+ ```
151
+
152
+
153
+ docsgpt-14b:
154
+ ```
155
+ import requests
156
+ import json
157
+
158
+ def send_request(question):
159
+ url = "http://127.0.0.1:5000/api/answer"
160
+ payload = {
161
+ "question": question,
162
+ "history": None,
163
+ "api_key": "YOUR_API_KEY",
164
+ "embeddings_key": "YOUR_EMBEDDINGS_KEY",
165
+ "active_docs": "javascript/.project/ES2015/openai_text-embedding-ada-002/"
166
+ }
167
+ headers = {
168
+ "Content-Type": "application/json; charset=utf-8"
169
+ }
170
+
171
+ response = requests.post(url, json=payload, headers=headers)
172
+ if response.status_code == 200:
173
+ answer = response.json()["answer"]
174
+ return answer
175
+ else:
176
+ return "Error: Could not connect to server."
177
+
178
+ def check_docs_loaded():
179
+ url = "http://127.0.0.1:5000/api/docs_check"
180
+ payload = {"docs": "javascript/.project/ES2015/openai_text-embedding-ada-002/"}
181
+ headers = {
182
+ "Content-Type": "application/json; charset=utf-8"
183
+ }
184
+
185
+ response = requests.post(url, json=payload, headers=headers)
186
+ if response.status_code == 200:
187
+ status = response.json()["status"]
188
+ if status == "exists":
189
+ return True
190
+ else:
191
+ return False
192
+ else:
193
+ return False
194
+
195
+ def mock_request(question):
196
+ if check_docs_loaded():
197
+ return send_request(question)
198
+ else:
199
+ return "Error: Documentation not loaded."
200
+
201
+ # Example usage
202
+ question = "What is the capital of France?"
203
+ answer = mock_request(question)
204
+ print(answer)
205
+
206
+ This is a mock request to the /api/answer endpoint using Python. It sends a JSON in the body with the question and other required parameters. The response is then parsed and returned.
207
+ ```
208
+
209
+ The original meta-llama/Llama-2-7b:
210
+ ```
211
+
212
+ # answer (POST http://127.0.0.1:5000/api/answer)
213
+ fetch("http://127.0.0.1:5000/api/answer", {
214
+ "method": "POST",
215
+ "headers": {
216
+ "Content-Type": "application/json; charset=utf-8"
217
+ },
218
+ "body": JSON.stringify({"question":"Hi","history":null,"api_key":"OPENAI_API_KEY","embeddings_key":"OPENAI_API_KEY",
219
+ "active_docs": "javascript/.project/ES2015/openai_text-embedding-ada-002/"})
220
+ })
221
+ .then((res) => res.text())
222
+ .then(console.log.bind(console))
223
+
224
+
225
+ ### Docs_check
226
+
227
+ # answer (POST http://127.0.0.1:5000/api/docs_check)
228
+ fetch("http://127.0.0.1:5000/api/docs_check", {
229
+ "method": "POST",
230
+ "headers": {
231
+ "Content-Type": "application/json; charset=utf-8"
232
+ },
233
+ "body": JSON.stringify({"docs":"javascript/.project/ES2015/openai_text-embedding-ada-002/"})
234
+ })
235
+ .then((res) => res.text())
236
+ .then(console.log.bind(console))
237
+
238
+
239
+ ### Installation
240
+
241
+ # Install dependencies
242
+ npm install
243
+
244
+ # Run the app
245
+ npm run start
246
+
247
+
248
+ ### License
249
+
250
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details
251
+
252
+
253
+ ### Contributing
254
+
255
+ Contributions are welcome, and they are greatly appreciated! Every little bit helps, and
256
+ we are always open to pull requests, and help.
257
+
258
+
259
+ ### Acknowledgments
260
+
261
+ Thanks to the following people for their help and support:
262
+
263
+ - [@Arc53](https://github.com/Arc53)
264
+ - [@Arc53](https://github.com/Arc53)
265
+ - [@Arc53](https://github.com/Arc53)
266
+ - [@Arc53](https://github.com/Arc53)
267
+ - [@Arc53](https://github.com/Arc53)
268
+ - [@Arc53](https://github.com/Arc53)
269
+ - [@Arc53](https://github.com/Arc53)
270
+ - [@Arc53](https://github.com/Arc53)
271
+ - [@Arc53](https://github.com/Arc53)
272
+ - [@Arc53](https://github.com/Arc53)
273
+ - [@Arc53](https://github.com/Arc53)
274
+ - [@Arc53](https://github.com/Arc53)
275
+ - [@Arc53](https://github.com/Arc53)
276
+ - [@Arc53](https://github.com/Arc53)
277
+ - [@Arc53](https://github.com/Arc53)
278
+ - [@Arc53](https://github.com/Arc53)
279
+ - [@Arc53](https://github.com/Arc53)
280
+ - [@Arc53](https://github.com/Arc53)
281
+ - [@Arc53](https://github.com/Arc53)
282
+ - [@Arc53](https://github.com/Arc53)
283
+ - [@Arc53](https://github.com/Arc53)
284
+ - [@Arc53](https://github.com/Arc53)
285
+ - [@Arc53](https://github.com/Arc53)
286
+ - [@Arc53](https://github.com/Arc53)
287
+ - [@Arc53](https://github.com/Arc53)
288
+ - [@Arc53](https://github.com/Arc53)
289
+ - [@Arc53](https://github.com/Arc53)
290
+ - [@Arc53](https://github.com/Arc53)
291
+ - [@Arc53](https://github.com/Arc53)
292
+ - [@Arc53](https://github.com/Arc53)
293
+ - [@Arc53](https://github.com/Arc53)
294
+ - [@Arc53](https://github.com/Arc53)
295
+ - [@Arc53](https://github.com/Arc53)
296
+ - [@Arc53](https://github.com/Arc53)
297
+ - [@Arc53](https://github.com/Arc53)
298
+ - [@Arc53](https://github.com/Arc53)
299
+ - [@Arc53](https://github.com/Arc53)
300
+ - [@Arc53](https
301
+ ```
302
+
303
+ As you can see there is an extra step and its not as exlicit to the source provided and there is an extra step and extra knowledge, which is important as we want to keep halucinations to a minimum.