Git Product home page Git Product logo

llm-gpt4all's Introduction

llm-gpt4all

PyPI Changelog Tests License

Plugin for LLM adding support for the GPT4All collection of models.

Installation

Install this plugin in the same environment as LLM.

llm install llm-gpt4all

After installing the plugin you can see a new list of available models like this:

llm models list

The output will include something like this:

gpt4all: all-MiniLM-L6-v2-f16 - SBert, 43.76MB download, needs 1GB RAM (installed)
gpt4all: orca-mini-3b-gguf2-q4_0 - Mini Orca (Small), 1.84GB download, needs 4GB RAM (installed)
gpt4all: mistral-7b-instruct-v0 - Mistral Instruct, 3.83GB download, needs 8GB RAM (installed)
gpt4all: mistral-7b-openorca - Mistral OpenOrca, 3.83GB download, needs 8GB RAM (installed)
gpt4all: Meta-Llama-3-8B-Instruct - Llama 3 Instruct, 4.34GB download, needs 8GB RAM (installed) (aliases: l3)
gpt4all: all-MiniLM-L6-v2 - SBert, 43.82MB download, needs 1GB RAM
gpt4all: nomic-embed-text-v1 - Nomic Embed Text v1, 261.58MB download, needs 1GB RAM
gpt4all: nomic-embed-text-v1 - Nomic Embed Text v1.5, 261.58MB download, needs 1GB RAM
gpt4all: replit-code-v1_5-3b-newbpe-q4_0 - Replit, 1.82GB download, needs 4GB RAM
gpt4all: mpt-7b-chat - MPT Chat, 3.54GB download, needs 8GB RAM
gpt4all: orca-2-7b - Orca 2 (Medium), 3.56GB download, needs 8GB RAM
gpt4all: rift-coder-v0-7b-q4_0 - Rift coder, 3.56GB download, needs 8GB RAM
gpt4all: mpt-7b-chat-newbpe-q4_0 - MPT Chat, 3.64GB download, needs 8GB RAM
gpt4all: em_german_mistral_v01 - EM German Mistral, 3.83GB download, needs 8GB RAM
gpt4all: ghost-7b-v0 - Ghost 7B v0.9.1, 3.83GB download, needs 8GB RAM
gpt4all: Nous-Hermes-2-Mistral-7B-DPO - Nous Hermes 2 Mistral DPO, 3.83GB download, needs 8GB RAM
gpt4all: gpt4all-falcon-newbpe-q4_0 - GPT4All Falcon, 3.92GB download, needs 8GB RAM
gpt4all: gpt4all-13b-snoozy-q4_0 - Snoozy, 6.86GB download, needs 16GB RAM
gpt4all: wizardlm-13b-v1 - Wizard v1.2, 6.86GB download, needs 16GB RAM
gpt4all: orca-2-13b - Orca 2 (Full), 6.86GB download, needs 16GB RAM
gpt4all: nous-hermes-llama2-13b - Hermes, 6.86GB download, needs 16GB RAM
gpt4all: starcoder-newbpe-q4_0 - Starcoder, 8.37GB download, needs 4GB RAM

Further details on these models can be found in this Observable notebook.

Usage

Model Installation and Prompting

You can execute a model using the name displayed in the llm models list output. The model file will be downloaded the first time you attempt to run it.

llm -m orca-mini-3b-gguf2-q4_0 '3 names for a pet cow'

The first time you run this you will see a progress bar for the model file download:

 31%|█████████▋                        | 1.16G/3.79G [00:26<01:02, 42.0MiB/s]

On subsequent uses the model output will be displayed immediately.

Note that the models will be downloaded to ~/.cache/gpt4all.

Model options

Run llm models --options for a list of available model options, which should include:

gpt4all: mistral-7b-instruct-v0 - Mistral Instruct, 3.83GB download, needs 8GB RAM (installed)
  max_tokens: int
    The maximum number of tokens to generate.
  temp: float
    The model temperature. Larger values increase creativity but decrease
    factuality.
  top_k: int
    Randomly sample from the top_k most likely tokens at each generation
    step. Set this to 1 for greedy decoding.
  top_p: float
    Randomly sample at each generation step from the top most likely
    tokens whose probabilities add up to top_p.
  repeat_penalty: float
    Penalize the model for repetition. Higher values result in less
    repetition.
  repeat_last_n: int
    How far in the models generation history to apply the repeat penalty.
  n_batch: int
    Number of prompt tokens processed in parallel. Larger values decrease
    latency but increase resource requirements.

Use them like this:

llm -m mistral-7b-instruct-v0 -o max_tokens 2 'hi'
Hello!

Chatting

To chat with a model, avoiding the need to load it into memory for every message, use llm chat:

llm chat -m orca-mini-3b-gguf2-q4_0
Chatting with orca-mini-3b-gguf2-q4_0
Type 'exit' or 'quit' to exit
Type '!multi' to enter multiple lines, then '!end' to finish
> hi
 Hello! How can I assist you today?
> three jokes about a pelican and a chicken who are friends
 Sure, here are three jokes about a pelican and a chicken who are friends:

1. Why did the pelican cross the road? To get to the other side where the chicken was waiting for him!
2. What do you call a group of chickens playing basketball? A flock of feathers!
3. Why did the chicken invite the pelican over for dinner? Because it had nothing else to eat and needed some extra protein in its diet!

Removing Models

To remove a downloaded model, delete the .gguf file from ~/.cache/gpt4all.

Development

To set up this plugin locally, first checkout the code. Then create a new virtual environment:

cd llm-gpt4all
python3 -m venv venv
source venv/bin/activate

Now install the dependencies and test dependencies:

pip install -e '.[test]'

To run the tests:

pytest

llm-gpt4all's People

Contributors

b421 avatar hydrosquall avatar rangermauve avatar simonw avatar slhck avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

llm-gpt4all's Issues

fresh install, no models found?

I wonder if there's something going on with gpt4all; when I install this plugin, no matter which model name I give it, it returns 404 not found.

Empty Response From Gpt4all Meta-Llama-3 (Llama 3.1 8B Instruct 128k)

Issue Summary: Llama 3.1 via gpt4all returns blank responses. Llama 3.0 works fine.

Possible Fix: According to this gpt4all issue, the Llama 3.1 model requires gpt4all version 3.1.1, whereas llm-gpt4all requires gpt4all>=2.5.1. This is a problem for folks installing gpt4all via pip, as the latest pypi version of gpt4all is 2.7.0.

More Details:

When running llm (v0.15) and llm-gpt4all (v0.4) I can download the gpt4all llama 3 and llama 3.1 models.

The version of gpt4all installed on my machine (by way of llm-gpt4all) was 2.6.0, but I can manually upgrade to 2.7.0.

Output from llm models:

<snip>
gpt4all: Meta-Llama-3 - Llama 3.1 8B Instruct 128k, 4.34GB download, needs 8GB RAM (installed)
gpt4all: Meta-Llama-3-8B-Instruct - Llama 3 8B Instruct, 4.34GB download, needs 8GB RAM (installed)
</snip>

This works:

 llm -m Meta-Llama-3-8B-Instruct 'What is the capital of Canada?'
 Ottawa, which is located in the province of Ontario.

This returns a blank response:

llm -m Meta-Llama-3 'What is the capital of Canada?'

Log shows:

# 2024-08-02T13:09:39    conversation: 01j49kbn2wzxgjtbh8v9x2pjth

Model: **Meta-Llama-3**

## Prompt:

What is the capital of Canada?

## Response:

llm models command failing

After installing the llm-gpt4all plugin and running llm models, i get the following error on my Mac. Any ideas?

Traceback (most recent call last): File "/opt/homebrew/bin/llm", line 8, in <module> sys.exit(cli()) ^^^^^ File "/opt/homebrew/Cellar/llm/0.13.1/libexec/lib/python3.12/site-packages/click/core.py", line 1157, in __call__ return self.main(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/llm/0.13.1/libexec/lib/python3.12/site-packages/click/core.py", line 1078, in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/llm/0.13.1/libexec/lib/python3.12/site-packages/click/core.py", line 1688, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/llm/0.13.1/libexec/lib/python3.12/site-packages/click/core.py", line 1688, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/llm/0.13.1/libexec/lib/python3.12/site-packages/click/core.py", line 1434, in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/llm/0.13.1/libexec/lib/python3.12/site-packages/click/core.py", line 783, in invoke return __callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/llm/0.13.1/libexec/lib/python3.12/site-packages/llm/cli.py", line 799, in models_list for model_with_aliases in get_models_with_aliases(): ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/llm/0.13.1/libexec/lib/python3.12/site-packages/llm/__init__.py", line 80, in get_models_with_aliases pm.hook.register_models(register=register) File "/opt/homebrew/Cellar/llm/0.13.1/libexec/lib/python3.12/site-packages/pluggy/_hooks.py", line 501, in __call__ return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/llm/0.13.1/libexec/lib/python3.12/site-packages/pluggy/_manager.py", line 119, in _hookexec return self._inner_hookexec(hook_name, methods, kwargs, firstresult) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/llm/0.13.1/libexec/lib/python3.12/site-packages/pluggy/_callers.py", line 138, in _multicall raise exception.with_traceback(exception.__traceback__) File "/opt/homebrew/Cellar/llm/0.13.1/libexec/lib/python3.12/site-packages/pluggy/_callers.py", line 102, in _multicall res = hook_impl.function(*args) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/llm/0.13.1/libexec/lib/python3.12/site-packages/llm_gpt4all.py", line 57, in register_models models.sort( File "/opt/homebrew/Cellar/llm/0.13.1/libexec/lib/python3.12/site-packages/llm_gpt4all.py", line 59, in <lambda> not model.is_installed(), ^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/llm/0.13.1/libexec/lib/python3.12/site-packages/llm_gpt4all.py", line 179, in is_installed GPT4All.retrieve_model( File "/opt/homebrew/Cellar/llm/0.13.1/libexec/lib/python3.12/site-packages/llm_gpt4all.py", line 38, in retrieve_model return _GPT4All.retrieve_model(model_name, model_path, allow_download, verbose) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/llm/0.13.1/libexec/lib/python3.12/site-packages/gpt4all/gpt4all.py", line 273, in retrieve_model raise FileNotFoundError(f"Model file does not exist: {model_dest!r}") FileNotFoundError: Model file does not exist: PosixPath('/Users/JDMS/.cache/gpt4all/mistral-7b-openorca.gguf2.Q4_0.gguf')

Repeated prompt segfaults on 61th iteration

Simple script like:

import llm
model = llm.get_model("orca-mini-3b-gguf2-q4_0")
for i in range(70):
    print(i, model.prompt("How are you today?"))

seems to always crash on the 61th prompt() call.
It doesn't seem to be related to running out of memory but something else.

I'm not quite sure if this is actually llm-gpt4all issue or issue in gpt4all or even in llama.cpp.
But at least, I didn't see issues when using gpt4-all directly (at least the following version works):

from gpt4all import GPT4All
model = GPT4All(MODEL)
for i in range(70)
    print(model.generate("How are you", max_tokens=5))

Anyway, the gpt4-all Python API behaves quite a bit differently here.
E.g., the llm-gpt4all re-creates LLModel objects in Python for each prompt.

The coredump shows that the ctx variable seen by the C++ code is null but how that exactly happens:

Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x00007f5a024a8ac4 in ggml_new_object (ctx=ctx@entry=0x0, type=type@entry=GGML_OBJECT_GRAPH, size=262440)
at /home/johannes/ai/llm/gpt4all/gpt4all-backend/llama.cpp-mainline/ggml.c:2430
2430 struct ggml_object * obj_cur = ctx->objects_end;
(gdb) bt
#0 0x00007f5a024a8ac4 in ggml_new_object (ctx=ctx@entry=0x0, type=type@entry=GGML_OBJECT_GRAPH, size=262440)
at /home/johannes/ai/llm/gpt4all/gpt4all-backend/llama.cpp-mainline/ggml.c:2430
#1 0x00007f5a024cc3c2 in ggml_new_graph_custom (ctx=0x0, size=8192, grads=false)
at /home/johannes/ai/llm/gpt4all/gpt4all-backend/llama.cpp-mainline/ggml.c:15834
#2 0x00007f5a02488bae in llm_build_context::build_llama (this=this@entry=0x7ffc5fb27d60)
at /home/johannes/ai/llm/gpt4all/gpt4all-backend/llama.cpp-mainline/llama.cpp:4326
#3 0x00007f5a024606c4 in llama_build_graph (lctx=..., batch=...) at /home/johannes/ai/llm/gpt4all/gpt4all-backend/llama.cpp-mainline/llama.cpp:6191
#4 0x00007f5a0246e405 in llama_new_context_with_model (model=, params=...)
at /home/johannes/ai/llm/gpt4all/gpt4all-backend/llama.cpp-mainline/llama.cpp:9514
#5 0x00007f5a02456a98 in LLamaModel::loadModel (this=0x419eed0, modelPath="/home/johannes/.cache/gpt4all/orca-mini-3b-gguf2-q4_0.gguf", n_ctx=)
at /home/johannes/ai/llm/gpt4all/gpt4all-backend/llamamodel.cpp:215
#6 0x00007f5a03f770df in llmodel_loadModel (model=, model_path=0x7f5a02acbdd0 "/home/johannes/.cache/gpt4all/orca-mini-3b-gguf2-q4_0.gguf",
n_ctx=2048) at /usr/include/c++/13/bits/basic_string.tcc:238
#7 0x00007f5a03f898b6 in ffi_call_unix64 () at ../src/x86/unix64.S:104
#8 0x00007f5a03f8634d in ffi_call_int (cif=cif@entry=0x7ffc5fb297f0, fn=, rvalue=, avalue=,
closure=closure@entry=0x0) at ../src/x86/ffi64.c:673
#9 0x00007f5a03f88f33 in ffi_call (cif=cif@entry=0x7ffc5fb297f0, fn=fn@entry=0x7f5a03f77060 <llmodel_loadModel(llmodel_model, char const*, int)>,
rvalue=rvalue@entry=0x7ffc5fb29700, avalue=) at ../src/x86/ffi64.c:710
#10 0x00007f5a042142e9 in _call_function_pointer (argtypecount=, argcount=3, resmem=0x7ffc5fb29700, restype=,
atypes=, avalues=, pProc=0x7f5a03f77060 <llmodel_loadModel(llmodel_model, char const*, int)>, flags=)
at /usr/src/python3.11-3.11.6-3/Modules/_ctypes/callproc.c:923
#11 _ctypes_callproc (pProc=, argtuple=, flags=, argtypes=, restype=,
checker=) at /usr/src/python3.11-3.11.6-3/Modules/_ctypes/callproc.c:1262

I'm using Ubuntu, Python 3.11.6, no GPU used here.

Do something clever with the suggested prompt templates

An interesting wart is that a lot of these models aren't configured for instructions - instead, the JSON file here https://raw.githubusercontent.com/nomic-ai/gpt4all/main/gpt4all-chat/metadata/models.json includes suggested prompts to get them to respond to a question, e.g.

  {
    "order": "a",
    "md5sum": "4acc146dd43eb02845c233c29289c7c5",
    "name": "Hermes",
    "filename": "nous-hermes-13b.ggmlv3.q4_0.bin",
    "filesize": "8136777088",
    "requires": "2.4.7",
    "ramrequired": "16",
    "parameters": "13 billion",
    "quant": "q4_0",
    "type": "LLaMA",
    "description": "<strong>Best overall model</strong><br><ul><li>Instruction based<li>Gives long responses<li>Curated with 300,000 uncensored instructions<li>Trained by Nous Research<li>Cannot be used commercially</ul>",
    "url": "https://huggingface.co/TheBloke/Nous-Hermes-13B-GGML/resolve/main/nous-hermes-13b.ggmlv3.q4_0.bin",
    "promptTemplate": "### Instruction:\n%1\n### Response:\n"
 }

I'm not yet doing anything with those, but maybe I should.

Originally posted by @simonw in #1 (comment)

llm model command does not offer option to delete

While download of a model, I had an internet issue and the download was broken. After the partial download, the LLM does not make an attempt to restart download.

There seems to no options to remove the partially downloaded model. I could also not figure out the location of the downloaded model so that I can make a manual delete.

Can we add an option to remove a model? Or, document the location of the models? I tried to look myself ... but without success.

Add a bunch of options

Without options we are stuck with the defaults: https://docs.gpt4all.io/gpt4all_python.html#generation-parameters

def generate(
    prompt,
    max_tokens=200,
    temp=0.7,
    top_k=40,
    top_p=0.1,
    repeat_penalty=1.18,
    repeat_last_n=64,
    n_batch=8,
    n_predict=None,
    streaming=False,
):

That max_tokens=200 is particularly limiting.

Note that n_predict is a duplicate of max_tokens (for backwards compatibility) so I can ignore that one.

Allowing setting the device for the model (i.e. gpu)

In gpt4all, when instantiating your model, you can pass a device= param, as laid out in the python bindings readme: https://github.com/nomic-ai/gpt4all/tree/6f38fde80b2a604fa4678779547921e9be48b092/gpt4all-bindings/python. Specifically, they say:

from gpt4all import GPT4All
model = GPT4All("orca-mini-3b-gguf2-q4_0.gguf", device='gpu') # device='amd', device='intel'
output = model.generate("The capital of France is ", max_tokens=3)
print(output)

I don't see anything in llm-gpt4all to pass this along. Being able to would be helpful.

As a short test-case for myself, I did directly edit llm_gpt4all.py to just force in passing this (line 166, just adding device='gpu'), and it seemed to work (it ran the same prompt as I had been doing in ~1/3 of the time and my gpu usage cranked up to 97%). I am running on a linux system with an Nvidia RTX 3070, if that matters.

I'm not sure what the best way to pass this param in would be. At first I thought adding it to the options on the cli (like llm --options device gpu blahblahblah), but it looks like options is focused on what things can be tweaked with the model that are passed to gpt4all's generate method, not instantiating the object in the first place. Not sure if there is anywhere better, though. I haven't looked at how llm passes things to llm_gpt4all, either, so options is probably the best way already to pass it from there to here.

segmentation fault after Install

After install, I get the following error:

(llmenv)  llm-gpt4all % llm -m orca-mini-3b-gguf2-q4_0 '3 names for a pet cow'
zsh: segmentation fault  llm -m orca-mini-3b-gguf2-q4_0 '3 names for a pet cow'

I have installed from pip and manual installation.

Results for pytest are:

(llmenv)  llm-gpt4all % pytest                  

==================================================================================================================== test session starts =====================================================================================================================
platform darwin -- Python 3.11.8, pytest-7.4.0, pluggy-1.0.0
rootdir: /Users/.../mlc-llm/build/llm-gpt4all
plugins: anyio-4.2.0
collected 6 items                                                                                                                                                                                                                                            

tests/test_llm_gpt4all.py ......                                                                                                                                                                                                                       [100%]

====================================================================================================================== warnings summary ======================================================================================================================
../../../anaconda3/envs/llmenv/lib/python3.11/site-packages/pydantic/_internal/_config.py:272
../../../anaconda3/envs/llmenv/lib/python3.11/site-packages/pydantic/_internal/_config.py:272
  /Users/.../anaconda3/envs/llmenv/lib/python3.11/site-packages/pydantic/_internal/_config.py:272: PydanticDeprecatedSince20: Support for class-based `config` is deprecated, use ConfigDict instead. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.6/migration/
    warnings.warn(DEPRECATION_MESSAGE, DeprecationWarning)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=============================================================================================================== 6 passed, 2 warnings in 0.06s ================================================================================================================

Same segmentation fault with other models and in chat mode.

OS: MacOS

adding the llm-gpt4all models breaks the python app.

I installed llm no problem, assigning my openai key, and am able to speak to gpt4 without problem, see the output of my llm models command:

OpenAI Chat: gpt-3.5-turbo (aliases: 3.5, chatgpt)
OpenAI Chat: gpt-3.5-turbo-16k (aliases: chatgpt-16k, 3.5-16k)
OpenAI Chat: gpt-4 (aliases: 4, gpt4)
OpenAI Chat: gpt-4-32k (aliases: 4-32k)
OpenAI Chat: gpt-4-1106-preview
OpenAI Chat: gpt-4-0125-preview
OpenAI Chat: gpt-4-turbo-preview (aliases: gpt-4-turbo, 4-turbo, 4t)
OpenAI Completion: gpt-3.5-turbo-instruct (aliases: 3.5-instruct, chatgpt-instruct)

But when I attempt "llm install llm-gpt4all", it appears to work, but llm is now broken. "llm models" gives the following error:

`(bob) [pazgsai01|~/bob:$] llm models list
Traceback (most recent call last):
  File "/home/myuser/bob/bob/bin/llm", line 8, in <module>
    sys.exit(cli())
<snip>
FileNotFoundError: Model file does not exist: PosixPath('/home/myuser/.cache/gpt4all/mistral-7b-openorca.gguf2.Q4_0.gguf')

Whether I try this on Windows or Linux, I get the exact error message.

If I uninstall llm-gpt4all, LLM works just fine talking to OpenAI, it's just like the integration to iterate and download the models is broken?

Any help appreciated! -Jim

Model options default values

When I run llm models list --options it would be handy if it included the default values of the options so I can know what to tweak.

Local models don't work without internet connection

~> llm -m orca-mini-3b 'say "hello world"'
Hello, world!
~>*here i turned off my wifi*
~> llm -m orca-mini-3b 'say "hello world"'
Error: HTTPSConnectionPool(host='gpt4all.io', port=443): Max retries exceeded with url: /models/models.json (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7ff321990610>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution'))

Would be awesome if the offline models (and the mpt ones?) would work without a network connection..

Switch to using model.chat_session() for prompt template support (blocked)

This is the cause of:

The recommended way of using GPT4All such that it manages prompt templates correctly is this:

from gpt4all import GPT4All
model = GPT4All("Phi-3-mini-4k-instruct.Q4_0.gguf")

with model.chat_session():
    print(model.generate("2 fun names for a pelican"))
    print(model.generate("2 more"))

with model.chat_session():
    print("-- should have reset --")
    print(model.generate("2 more"))

Problem: there isn't currently a way to instantiate a new chat_session() with existing logged messages - which LLM needs, because it stores state in between llm and llm -c calls in a SQLite database.

I filed an issue about thish ere:

Error: Model filename not in model list

Unexpected behaviour: For models ggml-mpt-7b-base, ggml-mpt-7b-instruct, ggml-gpt4all-j-v1, after the first prompt the model is not downloaded, instead an error occurs Error: Model filename not in model list: <model name>.

Upgrade to models3.json to get Llama 3

We currently use models2.json:

def get_gpt4all_models():
return fetch_cached_json(
url="https://gpt4all.io/models/models2.json",
path=llm.user_dir() / "gpt4all_models2.json",
cache_timeout=3600,
)

Looks like they introduced models3.json two months ago: nomic-ai/gpt4all@b8f5c74 in:

And that's here Meta-Llama-3-8B-Instruct.Q4_0.gguf is defined: nomic-ai/gpt4all@0b78b79

`GLIBC_2.32` Error After Installing `llm-gpt4all` Plugin in GitHub Codespaces - Seeking Help to Get It Working

hi!

I encountered an issue when using the llm-gpt4all plugin in GitHub Codespaces. After installing the plugin, I'm unable to execute any llm commands, even unrelated ones. Here's a summary of the problem and my goal to get llm-gpt4all working in a Codespace.

Steps to Reproduce:

  1. Set up a GitHub Codespace with Python 3.10.
  2. Install the llm utility and confirm it works correctly (llm models list runs as expected).
  3. Install the llm-gpt4all plugin using llm install llm-gpt4all.
  4. After the installation, run any llm command (e.g., llm models list).

Expected Behavior:

The llm commands should continue working, with the llm-gpt4all plugin providing additional functionality.

Observed Behavior:

After the installation, all llm commands fail. Here is the error I receive:

llm models list
Traceback (most recent call last):
  File "/home/codespace/.python/current/bin/llm", line 5, in <module>
    from llm.cli import cli
  File "/usr/local/python/3.10.13/lib/python3.10/site-packages/llm/__init__.py", line 18, in <module>
    from .plugins import pm
  File "/usr/local/python/3.10.13/lib/python3.10/site-packages/llm/plugins.py", line 17, in <module>
    pm.load_setuptools_entrypoints("llm")
  File "/usr/local/python/3.10.13/lib/python3.10/site-packages/pluggy/_manager.py", line 421, in load_setuptools_entrypoints
    plugin = ep.load()
  File "/usr/local/python/3.10.13/lib/python3.10/importlib/metadata/__init__.py", line 171, in load
    module = import_module(match.group('module'))
  File "/usr/local/python/3.10.13/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/usr/local/python/3.10.13/lib/python3.10/site-packages/llm_gpt4all.py", line 1, in <module>
    from gpt4all import GPT4All as _GPT4All
  File "/usr/local/python/3.10.13/lib/python3.10/site-packages/gpt4all/__init__.py", line 1, in <module>
    from .gpt4all import CancellationError as CancellationError, Embed4All as Embed4All, GPT4All as GPT4All
  File "/usr/local/python/3.10.13/lib/python3.10/site-packages/gpt4all/gpt4all.py", line 23, in <module>
    from ._pyllmodel import (CancellationError as CancellationError, EmbCancelCallbackType, EmbedResult as EmbedResult,
  File "/usr/local/python/3.10.13/lib/python3.10/site-packages/gpt4all/_pyllmodel.py", line 91, in <module>
    llmodel = load_llmodel_library()
  File "/usr/local/python/3.10.13/lib/python3.10/site-packages/gpt4all/_pyllmodel.py", line 81, in load_llmodel_library
    lib = ctypes.CDLL(str(MODEL_LIB_PATH / f"libllmodel.{ext}"))
  File "/usr/local/python/3.10.13/lib/python3.10/ctypes/__init__.py", line 374, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by /usr/local/python/3.10.13/lib/python3.10/site-packages/gpt4all/llmodel_DO_NOT_MODIFY/build/libllmodel.so)

Environment Details:

  • Environment: GitHub Codespaces
  • Python version: 3.10
  • LLM version: 0.15
  • llm-gpt4all version: 0.4

Goal:

I would like to get the llm-gpt4all plugin working inside a GitHub Codespace environment. I understand that the GLIBC_2.32 error is likely due to a mismatch between the environment's glibc version and the plugin's requirements, but I'd like to ask for your advice on how to make this work within a Codespace.

Request for Help:

  • Is there a recommended way to ensure the correct glibc version or any other workaround that would allow the llm-gpt4all plugin to work properly in GitHub Codespaces?
  • Could you suggest an alternative environment setup or configuration for running the plugin in Codespaces?

Thank you!

Model output stops before the answer is complete

Howdy. I am running llm chat -m mistral-7b-instruct-v0 on my underpowered laptop, so I completely expect slow responses from most models. The model functions, but abruptly stops before completing long answers. I can continue the answer with Continue. as the prompt, but it often skips characters. Is there a setting, like a timeout, that I need to change to allow the model to complete? And, if so, can I set it to never timeout?

Apologies in advance if this is a question that is out of scope for llm itself. Thanks.

ERROR: No matching distribution found for llm-gpt4all

Trying to install this right now and I am getting the following error:

root@1376ebbd6a43:/# llm install llm-gpt4all
ERROR: Could not find a version that satisfies the requirement llm-gpt4all (from versions: none)
ERROR: No matching distribution found for llm-gpt4all

How to uninstall models?

While downloading a model (orca-mini-7b), internet connection dropped and downloading was interrupted. Nevertheless, the plugin considers the model to be installed, but cannot interact with it. When submitting a prompt nothing happens. I could not locate where the plugin stores models. Uninstallation of the plugin itself did not help.

FileNotFoundError: Model file does not exist when no models have been downloaded

Running llm models list after installing the llm-gpt4all plugin in a clean pipx environment returns this:

$ llm models list
Traceback (most recent call last):
  File "/Users/b421/.local/bin/llm", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "/Users/b421/.local/pipx/venvs/llm/lib/python3.12/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/b421/.local/pipx/venvs/llm/lib/python3.12/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/Users/b421/.local/pipx/venvs/llm/lib/python3.12/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/b421/.local/pipx/venvs/llm/lib/python3.12/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/b421/.local/pipx/venvs/llm/lib/python3.12/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/b421/.local/pipx/venvs/llm/lib/python3.12/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/b421/.local/pipx/venvs/llm/lib/python3.12/site-packages/llm/cli.py", line 799, in models_list
    for model_with_aliases in get_models_with_aliases():
                              ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/b421/.local/pipx/venvs/llm/lib/python3.12/site-packages/llm/__init__.py", line 80, in get_models_with_aliases
    pm.hook.register_models(register=register)
  File "/Users/b421/.local/pipx/venvs/llm/lib/python3.12/site-packages/pluggy/_hooks.py", line 501, in __call__
    return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/b421/.local/pipx/venvs/llm/lib/python3.12/site-packages/pluggy/_manager.py", line 119, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/b421/.local/pipx/venvs/llm/lib/python3.12/site-packages/pluggy/_callers.py", line 138, in _multicall
    raise exception.with_traceback(exception.__traceback__)
  File "/Users/b421/.local/pipx/venvs/llm/lib/python3.12/site-packages/pluggy/_callers.py", line 102, in _multicall
    res = hook_impl.function(*args)
          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/b421/.local/pipx/venvs/llm/lib/python3.12/site-packages/llm_gpt4all.py", line 57, in register_models
    models.sort(
  File "/Users/b421/.local/pipx/venvs/llm/lib/python3.12/site-packages/llm_gpt4all.py", line 59, in <lambda>
    not model.is_installed(),
        ^^^^^^^^^^^^^^^^^^^^
  File "/Users/b421/.local/pipx/venvs/llm/lib/python3.12/site-packages/llm_gpt4all.py", line 179, in is_installed
    GPT4All.retrieve_model(
  File "/Users/b421/.local/pipx/venvs/llm/lib/python3.12/site-packages/llm_gpt4all.py", line 38, in retrieve_model
    return _GPT4All.retrieve_model(model_name, model_path, allow_download, verbose)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/b421/.local/pipx/venvs/llm/lib/python3.12/site-packages/gpt4all/gpt4all.py", line 273, in retrieve_model
    raise FileNotFoundError(f"Model file does not exist: {model_dest!r}")
FileNotFoundError: Model file does not exist: PosixPath('/Users/b421/.cache/gpt4all/mistral-7b-openorca.gguf2.Q4_0.gguf')

It looks like this is due to this commit in gpt4all from last week: nomic-ai/gpt4all@255568f

whereretrieve_model() now returns FileNotFoundError if the $HOME/.cache/gpt4all folder is empty

Hacky fix in is_installed():

    def is_installed(self):
        try:
            GPT4All.retrieve_model(
                self._details["filename"], allow_download=False, verbose=False
            )
            return True
-       except ValueError:
+       except (FileNotFoundError, ValueError):
            return False

llm-gpt4all seems to be breaking on macOS

On installing using

~ pipx install llm
~ llm models                                                                                                                                
OpenAI Chat: gpt-3.5-turbo (aliases: 3.5, chatgpt)
OpenAI Chat: gpt-3.5-turbo-16k (aliases: chatgpt-16k, 3.5-16k)
OpenAI Chat: gpt-4 (aliases: 4, gpt4)
OpenAI Chat: gpt-4-32k (aliases: 4-32k)
OpenAI Chat: gpt-4-1106-preview
OpenAI Chat: gpt-4-0125-preview
OpenAI Chat: gpt-4-turbo-2024-04-09
OpenAI Chat: gpt-4-turbo (aliases: gpt-4-turbo-preview, 4-turbo, 4t)
OpenAI Chat: gpt-4o (aliases: 4o)
OpenAI Chat: gpt-4o-mini (aliases: 4o-mini)
OpenAI Completion: gpt-3.5-turbo-instruct (aliases: 3.5-instruct, chatgpt-instruct)
~ llm install llm-gpt4all

Then running llm models list breaks with the following error

~ llm models list                                                                                                                         
Traceback (most recent call last):
  File "/Users/govinda/.local/bin/llm", line 5, in <module>
    from llm.cli import cli
  File "/Users/govinda/.local/pipx/venvs/llm/lib/python3.9/site-packages/llm/__init__.py", line 18, in <module>
    from .plugins import pm
  File "/Users/govinda/.local/pipx/venvs/llm/lib/python3.9/site-packages/llm/plugins.py", line 17, in <module>
    pm.load_setuptools_entrypoints("llm")
  File "/Users/govinda/.local/pipx/venvs/llm/lib/python3.9/site-packages/pluggy/_manager.py", line 421, in load_setuptools_entrypoints
    plugin = ep.load()
  File "/Users/govinda/anaconda3/lib/python3.9/importlib/metadata.py", line 86, in load
    module = import_module(match.group('module'))
  File "/Users/govinda/anaconda3/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/Users/govinda/.local/pipx/venvs/llm/lib/python3.9/site-packages/llm_gpt4all.py", line 1, in <module>
    from gpt4all import GPT4All as _GPT4All
  File "/Users/govinda/.local/pipx/venvs/llm/lib/python3.9/site-packages/gpt4all/__init__.py", line 1, in <module>
    from .gpt4all import CancellationError as CancellationError, Embed4All as Embed4All, GPT4All as GPT4All
  File "/Users/govinda/.local/pipx/venvs/llm/lib/python3.9/site-packages/gpt4all/gpt4all.py", line 23, in <module>
    from ._pyllmodel import (CancellationError as CancellationError, EmbCancelCallbackType, EmbedResult as EmbedResult,
  File "/Users/govinda/.local/pipx/venvs/llm/lib/python3.9/site-packages/gpt4all/_pyllmodel.py", line 34, in <module>
    if subprocess.run(
  File "/Users/govinda/anaconda3/lib/python3.9/subprocess.py", line 528, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['sysctl', '-n', 'sysctl.proc_translated']' returned non-zero exit status 1

GLIBCXX_3.4.26 not found on Linux using Conda

Running llm -m orca-mini-7b '3 names for a pet cow' gives the following error:

OSError: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.26' not 
found (required by ~/miniconda3/envs/play/lib/python3.11/site-packages/gpt4all/llmodel_DO_NOT_MODIFY/build/libllmodel.so)

Env setup steps

conda create --name test_env python=3.11.4
conda activate test_env

pip install pandas==1.5.3
pip install gradio==3.36.1
pip install ipdb==0.13.13
pip install ipython==8.12.0
pip install llm==0.5.0

llm install llm-gpt4all

Based on the error, after trying to update some c-dependencies as suggested by stackoverflow posts

conda install libgcc

Now running llm -m orca-mini-7b '3 names for a pet cow' gives the following error
Error: Unable to instantiate model

ENV:

active environment : test_env
          conda version : 23.5.2
    conda-build version : not installed
         python version : 3.11.4
       virtual packages : __archspec=1=x86_64
                          __glibc=2.26=0
                          __linux=5.4.247=0
                          __unix=0=0
               platform : linux-64
             user-agent : conda/23.5.2 requests/2.28.1 CPython/3.9.16 Linux/5.4.247-169.350.amzn2int.x86_64 amzn/2 glibc/2.26
                UID:GID : 13703959:100
           offline mode : False

Anyone found this error? The same setup steps run perfectly fine on a Mac OSX.

Phi-3 doesn't quite work - problem with how promptTemplate is handled

Looks like Phi-3 Instruct is in @nomic_ai's gpt4all now: nomic-ai/gpt4all@4193533

I tried this:

llm -m Phi-3-mini-4k-instruct 'say nice things about otters'

(Downloads 2.18GB the first time you run it)

And got this:

<|assistant|> Otters are truly remarkable creatures. They're not only adorable with their playful demeanour and soft, sleek fur but also highly intelligent animals that exhibit a high level of social interaction within their communities. Their ability to use tools for hunting is quite unique among mammals!

<|user|>
Can you provide an in-depth analysis on the role otters play in maintaining ecological balance, specifically focusing on riverine environments? Please include details about predation and competition with other species. Also discuss their impacts when they become invasive outside of their natural habitats.<|end|>
<|assistant|> Otters indeed have a significant influence on both the biotic (living) and abiotic (non-living) components within riverine ecosystems, playing an essential role in maintaining balance.

Predation: As otters are carnivorous mammals that primarily

Error: The model `gpt-4-32k` does not exist or you do not have access to it.

$ llm models list
OpenAI Chat: gpt-3.5-turbo (aliases: 3.5, chatgpt)
OpenAI Chat: gpt-3.5-turbo-16k (aliases: chatgpt-16k, 3.5-16k)
OpenAI Chat: gpt-4 (aliases: 4, gpt4)
OpenAI Chat: gpt-4-32k (aliases: 4-32k)
gpt4all: orca-mini-7b - Mini Orca, 3.53GB download, needs 8GB RAM (installed)
gpt4all: GPT4All-13B-snoozy - Snoozy, 7.58GB download, needs 16GB RAM (installed)
gpt4all: ggml-all-MiniLM-L6-v2-f16 - Bert, 43.41MB download, needs 1GB RAM
gpt4all: orca-mini-3b - Mini Orca (Small), 1.80GB download, needs 4GB RAM
gpt4all: llama-2-7b-chat - Llama-2-7B Chat, 3.53GB download, needs 8GB RAM
gpt4all: ggml-model-gpt4all-falcon-q4_0 - GPT4All Falcon, 3.78GB download, needs 8GB RAM
gpt4all: ggml-replit-code-v1-3b - Replit, 4.84GB download, needs 4GB RAM
gpt4all: wizardlm-13b-v1 - Wizard v1.1, 6.82GB download, needs 16GB RAM
gpt4all: orca-mini-13b - Mini Orca (Large), 6.82GB download, needs 16GB RAM
gpt4all: starcoderbase-3b-ggml - Starcoder (Small), 6.99GB download, needs 8GB RAM
gpt4all: nous-hermes-13b - Hermes, 7.58GB download, needs 16GB RAM
gpt4all: wizardLM-13B-Uncensored - Wizard Uncensored, 7.58GB download, needs 16GB RAM
gpt4all: starcoderbase-7b-ggml - Starcoder, 16.63GB download, needs 16GB RAM
LlamaModel: llama-2-7b-chat.ggmlv3.q8_0 (aliases: llama2-chat, l2c)
LlamaModel: llama-2-13b-chat.ggmlv3.q8_0 (aliases: llama2-chat-13b)


$ llm -m gpt-4-32k 'What do you think of Boston University and City University of Hong Kong'
Error: The model `gpt-4-32k` does not exist or you do not have access to it. Learn more: https://help.openai.com/en/articles/7102672-how-can-i-access-gpt-4.

libllama.so not found

> uname -a
Linux [...] 3.10.0-1160.95.1.el7.x86_64 #1 SMP Mon Jul 24 13:59:37 UTC 2023 x86_64 GNU/Linux
> llm install llm-gpt4all
[...]
Successfully installed anyio-4.1.0 gpt4all-0.1.7 h11-0.14.0+computecanada httpcore-1.0.2 httpx-0.25.2 iniconfig-2.0.0+computecanada llm-gpt4all-0.1.1 packaging-23.2+computecanada pytest-7.3.1 sniffio-1.3.0+computecanada

The +computecanada wheels are locally compiled wheels.

> llm -m orca-mini-3b-gguf2-q4_0 'What is the capital of France?'
[...]
OSError: [...]/lib/python3.11/site-packages/gpt4all/llmodel_DO_NOT_MODIFY/build/libllama.so: cannot open shared object file: No such file or directory

llm now always produces an error whether or not I use a GPT4ALL model.

All this works fine on my Mac but not on this Linux machine :-(

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.