Giter Site home page Giter Site logo

sorokinvld / pygpt4all Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nomic-ai/pygpt4all

0.0 1.0 0.0 1.64 MB

Official supported Python bindings for llama.cpp + gpt4all

Home Page: https://nomic-ai.github.io/pygpt4all/

License: MIT License

Shell 0.61% C++ 55.26% Python 21.63% C 15.76% Swift 0.02% Nix 0.07% Makefile 0.66% CMake 5.15% Batchfile 0.82% Dockerfile 0.03%

pygpt4all's Introduction

PyGPT4All

Official Python CPU inference for GPT4All language models based on llama.cpp and ggml

License: MIT PyPi version

Installation

pip install pygpt4all

Tutorial

You will need first to download the model weights, you can find and download all the supported models from here.

Model instantiation

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

  • GPT4All model
from pygpt4all import GPT4All

model = GPT4All('path/to/ggml-gpt4all-l13b-snoozy.bin')
  • GPT4All-J model
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:

for token in model.generate("Tell me a joke ?\n"):
    print(token, end='', flush=True)

Interactive Dialogue

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

while True:
    try:
        prompt = input("You: ", flush=True)
        if prompt == '':
            continue
        print(f"AI:", end='')
        for token in model.generate(prompt):
            print(f"{token}", end='', flush=True)
        print()
    except KeyboardInterrupt:
        break

API reference

You can check the API reference documentation for more details.

License

This project is licensed under the MIT License.

pygpt4all's People

Contributors

abdeladim-s avatar parisneo avatar nuance1979 avatar kasimir123 avatar bmschmidt avatar rguo123 avatar deadredmond avatar mkinney avatar andrewmelis avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.