File size: 5,329 Bytes
60edbfc
 
8850ce7
 
 
3c10c11
60edbfc
3c10c11
 
8850ce7
9f21c83
8850ce7
9f21c83
8850ce7
 
3c10c11
8850ce7
527e7f8
 
8850ce7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
527e7f8
3c10c11
8850ce7
3c10c11
 
 
8850ce7
3c10c11
8850ce7
 
 
 
 
 
3c10c11
 
 
8850ce7
3c10c11
8850ce7
3c10c11
8850ce7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3c10c11
8850ce7
9dec0f1
8850ce7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3c10c11
 
 
 
8850ce7
d0bd4c6
8850ce7
3c10c11
8850ce7
 
3c10c11
 
8850ce7
 
 
 
 
 
 
3c10c11
8850ce7
 
3c10c11
8850ce7
 
 
 
 
3c10c11
8850ce7
 
 
 
 
 
 
 
3c10c11
8850ce7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
---
license: apache-2.0
language:
- en
library_name: transformers
pipeline_tag: text-generation
---


This model is fine tuned on top of llama-2-7b

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.

We used 50k high quality examples to finetune it over 1.5 days on A10G GPU.
We used lora fine tuning process.

Its an apache-2.0 license so you can use it for commercial purposes too.


# How to run it
```
from transformers import AutoTokenizer, AutoModelForCausalLM
import transformers
import torch

model = "Arc53/docsgpt-7b"

tokenizer = AutoTokenizer.from_pretrained(model)
pipeline = transformers.pipeline(
    "text-generation",
    model=model,
    tokenizer=tokenizer,
    torch_dtype=torch.bfloat16,
    trust_remote_code=True,
    device_map="auto",
)
sequences = pipeline(
   "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:",
    max_length=200,
    do_sample=True,
    top_k=10,
    num_return_sequences=1,
    eos_token_id=tokenizer.eos_token_id,
)
for seq in sequences:
    print(f"Result: {seq['generated_text']}")
```


Benchmarks are still WIP



To prepare your prompts make sure you keep this format:

```
 ### Instruction
(where the question goes)
### Context
(your document retrieval + system instructions)
### Answer
```


Here is an example comparing it to meta-llama/Llama-2-7b

Prompt:
```
### Instruction
Create a mock request to /api/answer in python

### Context
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.
Use the following pieces of context to help answer the users question. If its not relevant to the question, provide friendly responses.
You have access to chat history, and can use it to help answer the question.
When using code examples, use the following format:
`` ` `` (language)
(code)
`` ` ``

----------------


/api/answer
Its a POST request that sends a JSON in body with 4 values. Here is a JavaScript fetch example
It will recieve an answer for a user provided question

`` ` ``
// answer (POST http://127.0.0.1:5000/api/answer)
fetch("http://127.0.0.1:5000/api/answer", {
      "method": "POST",
      "headers": {
            "Content-Type": "application/json; charset=utf-8"
      },
      "body": JSON.stringify({"question":"Hi","history":null,"api_key":"OPENAI_API_KEY","embeddings_key":"OPENAI_API_KEY",
      "active_docs": "javascript/.project/ES2015/openai_text-embedding-ada-002/"})
})
.then((res) => res.text())
.then(console.log.bind(console))
`` ` ``

In response you will get a json document like this one:

`` ` ``
{
  "answer": " Hi there! How can I help you?\\n",
  "query": "Hi",
  "result": " Hi there! How can I help you?\\nSOURCES:"
}
`` ` ``

 

/api/docs_check
It will make sure documentation is loaded on a server (just run it everytime user is switching between libraries (documentations)
Its a POST request that sends a JSON in body with 1 value. Here is a JavaScript fetch example

`` ` ``
// answer (POST http://127.0.0.1:5000/api/docs_check)
fetch("http://127.0.0.1:5000/api/docs_check", {
      "method": "POST",
      "headers": {
            "Content-Type": "application/json; charset=utf-8"
      },
      "body": JSON.stringify({"docs":"javascript/.project/ES2015/openai_text-embedding-ada-002/"})
})
.then((res) => res.text())
.then(console.log.bind(console))
`` ` ``

In response you will get a json document like this one:
`` ` ``
{
  "status": "exists"
}
`` ` ``




Issues and Pull requests

We value contributions to our issues in form of discussion or suggestion, we recommend that you check out existing issues and our Roadmap

If you want to contribute by writing code there are few things that you should know before doing it:
We have frontend (React, Vite) and Backend (python)


### Answer
```


docsgpt-7b:
```
To create a mock request to `/api/answer` in Python, you can use the `requests` library. Here's an example:

`` ` ``python
import requests

# Set up the URL and headers
url = "http://127.0.0.1:5000/api/answer"
headers = {
    "Content-Type": "application/json; charset=utf-8"
}

# Set up the JSON data to send in the request body
data = {
    "question": "Hi",
    "history": null,
    "api_key": "OPENAI_API_KEY",
    "embeddings_key": "OPENAI_API_KEY",
    "active_docs": "javascript/.project/ES2015/openai_text-embedding-ada-002/"
}

# Send the request and get the response
response = requests.post(url, headers=headers, json=data)

# Print the response
print(response.text)
`` ` ``

This will send a POST request to `/api/answer` with the specified `question`, `history`, `api_key`, `embeddings_key`, and `active_docs` parameters. The response will be printed to the console.

Note that you will need to replace `127.0.0.1:5000` with the actual URL and port of your server. Also, make sure you have the necessary dependencies installed for `requests`.
```

The original meta-llama/Llama-2-7b:
```
### DocsGPT


### DocsGPT


### DocsGPT


### DocsGPT


```