piratos
commited on
Commit
•
40c2b41
1
Parent(s):
6051064
init files
Browse files- README.md +301 -0
- config.json +6 -0
- generation_config.json +9 -0
- model.bin +3 -0
- special_tokens_map.json +23 -0
- tokenizer.json +0 -0
- tokenizer_config.json +33 -0
- vocabulary.json +0 -0
README.md
ADDED
@@ -0,0 +1,301 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 llama-2-13b
|
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 meta-llama/Llama-2-14b
|
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-14b:
|
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 |
+
```
|
config.json
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"bos_token": "<s>",
|
3 |
+
"eos_token": "</s>",
|
4 |
+
"layer_norm_epsilon": 1e-05,
|
5 |
+
"unk_token": "<unk>"
|
6 |
+
}
|
generation_config.json
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"bos_token_id": 1,
|
3 |
+
"eos_token_id": 2,
|
4 |
+
"max_length": 4096,
|
5 |
+
"pad_token_id": 0,
|
6 |
+
"temperature": 0.9,
|
7 |
+
"top_p": 0.6,
|
8 |
+
"transformers_version": "4.31.0"
|
9 |
+
}
|
model.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:8475090736c339953bd63acb8a7d9e065339f239357ad9db18709a0f9fdf24a0
|
3 |
+
size 13025087966
|
special_tokens_map.json
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"bos_token": {
|
3 |
+
"content": "<s>",
|
4 |
+
"lstrip": false,
|
5 |
+
"normalized": false,
|
6 |
+
"rstrip": false,
|
7 |
+
"single_word": false
|
8 |
+
},
|
9 |
+
"eos_token": {
|
10 |
+
"content": "</s>",
|
11 |
+
"lstrip": false,
|
12 |
+
"normalized": false,
|
13 |
+
"rstrip": false,
|
14 |
+
"single_word": false
|
15 |
+
},
|
16 |
+
"unk_token": {
|
17 |
+
"content": "<unk>",
|
18 |
+
"lstrip": false,
|
19 |
+
"normalized": false,
|
20 |
+
"rstrip": false,
|
21 |
+
"single_word": false
|
22 |
+
}
|
23 |
+
}
|
tokenizer.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
tokenizer_config.json
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"bos_token": {
|
3 |
+
"__type": "AddedToken",
|
4 |
+
"content": "<s>",
|
5 |
+
"lstrip": false,
|
6 |
+
"normalized": false,
|
7 |
+
"rstrip": false,
|
8 |
+
"single_word": false
|
9 |
+
},
|
10 |
+
"clean_up_tokenization_spaces": false,
|
11 |
+
"eos_token": {
|
12 |
+
"__type": "AddedToken",
|
13 |
+
"content": "</s>",
|
14 |
+
"lstrip": false,
|
15 |
+
"normalized": false,
|
16 |
+
"rstrip": false,
|
17 |
+
"single_word": false
|
18 |
+
},
|
19 |
+
"legacy": false,
|
20 |
+
"model_max_length": 1000000000000000019884624838656,
|
21 |
+
"pad_token": null,
|
22 |
+
"padding_side": "right",
|
23 |
+
"sp_model_kwargs": {},
|
24 |
+
"tokenizer_class": "LlamaTokenizer",
|
25 |
+
"unk_token": {
|
26 |
+
"__type": "AddedToken",
|
27 |
+
"content": "<unk>",
|
28 |
+
"lstrip": false,
|
29 |
+
"normalized": false,
|
30 |
+
"rstrip": false,
|
31 |
+
"single_word": false
|
32 |
+
}
|
33 |
+
}
|
vocabulary.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|