Metadata-Version: 2.1
Name: gptj
Version: 2.2.2
Summary: A GPT-J api to use with python3 to generate text, blogs, code, and more
Home-page: https://github.com/TheProtaganist/gpt-j
Author: TheProtagonist (Michael Arana)
Author-email: MichaelGamer256@gmail.com
License: MIT
Keywords: python,text generation,chatbot framework,gpt-J,gpt-3,gpt-2,completion,code completion,language models,language model,nlp,natural language,natural language processing,meta-programming,story generation,story,API
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Natural Language :: English
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: Unix
Classifier: Operating System :: MacOS :: MacOS X
Classifier: Operating System :: Microsoft :: Windows
Description-Content-Type: text/markdown
Requires-Dist: requests
Requires-Dist: ProfanityDetector
Requires-Dist: cryptography

# GPT-J
A GPT-J API to use with python

## Installing gpt-j
```
pip install gptj
```

## Parameters
prompt: the prompt you wish to give to the model

tokens: the number of tokens to generate (values 2048 or less are recommended)

tempurature: controls the ramdomness of the model. higher values will be more random (suggestest to keep under 1.0 or less, something like 0.3 works)

top_p: top probability will use the most likely tokens

## Advanced Parameters 
user: the speaker the person who is giving gpt-j a prompt 

bot: an imaginary character of your choice

context: the part of the prompt that explains what is happening in the dialog

examples: a dictionary of user intentions and how the bot should respond


# Basic Usage

## In the prompt enter something you want to generate
```python
from GPTJ.Basic_api import SimpleCompletion

prompt = "def perfect_square(num):"
```

## The maximum length of the output response
```python
max_length = 100
```

## Temperature controls the creativity of the model
A low temperature means the model will take less changes when completing a prompt
A high temperature will make the model more creative
Both temperature and top probability most be a float

```python
temperature = 0.09
```

## top probability is an alternative way to control the randomness of the model
If you are using top probability set temperature one
If you are using temperature set top probability to one

```python
top_probability = 1.0
```

## Initializing the SimpleCompletion class
Here you set query equal to the desired values
Note values higher that 512 tend to take more time to generate

```python
query = SimpleCompletion(prompt, length=max_length, t=temperature, top=top_probability)
```

## Finally run the function below
```python
query.simple_completion()
```

## optional
You can assign the results to a string
```python
Query = query.simple_completion()

print(Query)
```

# Advanced Usage 

## Context is a string that is a description of the conversation
```python
from GPTJ.gptj_api import Completion

context = "This is a calculator bot that will answer basic math questions"
```


## Examples should be a dictionary of {user query: the way the model should respond to the given query} list of examples
Queries are to the left while target responses should be to the right
Here we can see the user is asking the model math related questions
The way the model should respond if given on the right

```python
examples = {
    "5 + 5": "10",
    "6 - 2": "4",
    "4 * 15": "60",
    "10 / 5": "2",
    "144 / 24": "6",
    "7 + 1": "8"}
```

## Here you pass in the context and the examples
```python
context_setting = Completion(context, examples)
```

## Enter a prompt relevant to previous defined user queries
```python
prompt = "48 / 6"
```

## Pick a name relevant to what you are doing

Below you can change student to "Task" for example and get similar results
```python
User = "Student"
```
## Name your imaginary friend anything you want

```python
Bot = "Calculator"
```

## Max tokens is the maximum length of the output response
```python
max_tokens = 50
```

## Temperature controls the randomness of the model
A low temperature means the model will take less changes when completing a prompt
A high temperature will make the model more creative and produce more random outputs
A Note both temperature and top probability most be a float

```python
temperature = 0.09
```

## Top probability is an alternative way to control the randomness of the model
If you are using it set temperature one
If you are using temperature set top probability to one

```python
top_probability = 1.0
```

## Set simply set all the give all the parameters
Unfilled parameters will be default values
I recommend all parameters are filled for better results
Once everything is done execute the the code below

```python
response = context_setting.completion(prompt,
              user=User,
              bot=Bot,
              max_tokens=max_tokens,
              temperature=temperature,
              top_p=top_probability)
```

## Last but not least print the response
Please be patient depending the given parameters it will take longer sometimes
For quick responses just use the Basic API which is a simplified version

```python
print(response)
```

Note: This a very small model of 6B paramters and won't always produce accurate results

# License and copyright 

## Cerdit 
This is all possible thanks to https://github.com/vicgalle/gpt-j-api
Feel free to check out the original api

## License
© Michael D Arana
licensed under the [MIT License](LICENSE).


