[Feature] Able to operate when temporarily offline if model is already cached
jithware opened this issue · comments
Description
When a model is already cached, it would be better if the python interface continued to operate even when temporarily offline. Currently when model.generate(...)
is used, a request to /models/models3.json is made every time. Though this is good for usage statistics, it would be preferable that the python interface first checked if the model has already been cached and if so, do not request models3.json
again. This presumably would allow the application to continue to operate should network connectivity be disrupted temporarily.
Steps to reproduce
Call model.generate(...)
python -c 'from gpt4all import GPT4All
model = GPT4All("Meta-Llama-3-8B-Instruct.Q4_0.gguf") # downloads / loads a 4.66GB LLM
with model.chat_session():
print(model.generate("Can gpt4all be used offline?", max_tokens=1024))'
GPT-4 is a cloud-based AI model, which means it requires an internet connection to function. As such, GPT-4 cannot be used entirely offline...
Verify model is cached
ls ~/.cache/gpt4all/
Meta-Llama-3-8B-Instruct.Q4_0.gguf
Disconnect network temporarily
Call model.generate(...)
again
python -c 'from gpt4all import GPT4All
model = GPT4All("Meta-Llama-3-8B-Instruct.Q4_0.gguf") # downloads / loads a 4.66GB LLM
with model.chat_session():
print(model.generate("Can gpt4all be used offline?", max_tokens=1024))'
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='gpt4all.io', port=443): Max retries exceeded with url: /models/models3.json (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f01e6c0f7d0>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution'))
Expected result
GPT4all continues to operate even during temporary network connectivity loss.
Another thing to consider is how often are the models updated. Perhaps there could be a configuration that only checks for model updates at a periodic interval instead of every time.
curl -I https://gpt4all.io/models/gguf/Meta-Llama-3-8B-Instruct.Q4_0.gguf | grep -i last-modified
last-modified: Fri, 19 Apr 2024 16:53:24 GMT