Skip to content
This repository has been archived by the owner on May 12, 2023. It is now read-only.

Commit

Permalink
Merge pull request #104 from 1Blademaster/main
Browse files Browse the repository at this point in the history
Fix description text for log_level for both models and fix bug in example usage in README
  • Loading branch information
AndriyMulyar committed May 10, 2023
2 parents b0b87bd + 5047921 commit 463037e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
32 changes: 19 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
# PyGPT4All

Official Python CPU inference for [GPT4All](https://github.com/nomic-ai/gpt4all) language models based on [llama.cpp](https://github.com/ggerganov/llama.cpp) and [ggml](https://github.com/ggerganov/ggml)

[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)
[![PyPi version](https://badgen.net/pypi/v/pygpt4all)](https://pypi.org/project/pygpt4all/)

<!-- TOC -->
* [Installation](#installation)
* [Tutorial](#tutorial)
* [Model instantiation](#model-instantiation)
* [Simple generation](#simple-generation)
* [Interactive Dialogue](#interactive-dialogue)
* [API reference](#api-reference)
* [License](#license)

- [Installation](#installation)
- [Tutorial](#tutorial)
- [Model instantiation](#model-instantiation)
- [Simple generation](#simple-generation)
- [Interactive Dialogue](#interactive-dialogue)
- [API reference](#api-reference)
- [License](#license)
<!-- TOC -->

# Installation

```bash
Expand All @@ -24,25 +27,27 @@ pip install pygpt4all
You will need first to download the model weights, you can find and download all the supported models from [here](https://github.com/nomic-ai/gpt4all-chat#manual-download-of-models).

### Model instantiation

Once the weights are downloaded, you can instantiate the models as follows:
* GPT4All model

- GPT4All model

```python
from pygpt4all import GPT4All

model = GPT4All('path/to/ggml-gpt4all-l13b-snoozy.bin')
```

* GPT4All-J model
- GPT4All-J model

```python
from pygpt4all import GPT4All_J

model = GPT4All_J('path/to/ggml-gpt4all-j-v1.3-groovy.bin')
```


### Simple generation

The `generate` function is used to generate new tokens from the `prompt` given as input:

```python
Expand All @@ -51,12 +56,13 @@ for token in model.generate("Tell me a joke ?\n"):
```

### Interactive Dialogue

You can set up an interactive dialogue by simply keeping the `model` variable alive:

```python
while True:
try:
prompt = input("You: ", flush=True)
prompt = input("You: ")
if prompt == '':
continue
print(f"AI:", end='')
Expand All @@ -68,9 +74,9 @@ while True:
```

# API reference
You can check the [API reference documentation](https://nomic-ai.github.io/pygpt4all/) for more details.

You can check the [API reference documentation](https://nomic-ai.github.io/pygpt4all/) for more details.

# License
This project is licensed under the MIT [License](./LICENSE).

This project is licensed under the MIT [License](./LICENSE).
2 changes: 1 addition & 1 deletion pygpt4all/models/gpt4all.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def __init__(self,
:param prompt_context: the global context of the interaction
:param prompt_prefix: the prompt prefix
:param prompt_suffix: the prompt suffix
:param log_level: logging level, set to INFO by default
:param log_level: logging level, set to ERROR by default
:param n_ctx: LLaMA context
:param seed: random seed
:param n_parts: LLaMA n_parts
Expand Down
2 changes: 1 addition & 1 deletion pygpt4all/models/gpt4all_j.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def __init__(self,
:param prompt_context: the global context of the interaction
:param prompt_prefix: the prompt prefix
:param prompt_suffix: the prompt suffix
:param log_level: logging level
:param log_level: logging level, set to ERROR by default
"""
# set logging level
set_log_level(log_level)
Expand Down

0 comments on commit 463037e

Please sign in to comment.