Chat with your documents locally.
Project description
localrag
localrag
is a Python package enabling users to "chat" with their documents using a local Retrieval Augmented Generation (RAG) approach, without needing an external Large Language Model (LLM) provider.
It allows for quick, local, and easy interactions with text data, extracting and generating responses based on the content.
Features
- Local Processing: Runs entirely on your local machine - no need to send data externally.
- Customizable: Easy to set up with default models or specify your own.
- Versatile: Use it for a variety of applications, from automated Q&A systems to data mining. You add files, folders or websites to the index!
Prerequisites
Before you install and start using localrag
, make sure you meet the following requirements:
Ollama for Local Inference
localrag
uses Ollama for local inference, particularly beneficial for macOS users. Ollama allows for easy model serving and inference. To set up Ollama:
- Download and run the app
- From command line, fetch a model from this list of options: e.g.,
ollama pull llama2
- When the app is running, all models are automatically served on localhost:11434
Installation
To install localrag
, simply use pip:
pip install localrag
Quick Start
Here's a quick example of how you can use localrag to chat with your documents:
Here is an example in test.txt in the docs folder:
I have a dog
import localrag
# can set device to mps or cuda:0 e.g device="mps"
# can set index location e.g index_location="my_index_loc"
# Can set system prompt with system_prompt=
my_local_rag = localrag.init()
# Add docs
my_local_rag.add_to_index("./docs")
# Chat with docs
response = my_local_rag.chat("What type of pet do I have?")
print(response.answer)
print(response.context)
# Based on the context you provided, I can determine that you have a dog. Therefore, the type of pet you have is "dog."
# [Document(page_content='I have a dog', metadata={'source': 'docs/test.txt'})]
License
This library is licensed under the Apache 2.0 License. See the LICENSE file.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file localrag-0.1.41.tar.gz
.
File metadata
- Download URL: localrag-0.1.41.tar.gz
- Upload date:
- Size: 9.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4ae5ad6ba228516b209d153ddd35fc5c9962c002598b096e56263b3af4095640 |
|
MD5 | 4775a48c75a178a1b8ee3bdbc80900d1 |
|
BLAKE2b-256 | 214148fd51afa6cf1bd444c2e25674b4a364191ea205a66cd40e35b0e6a9d075 |
File details
Details for the file localrag-0.1.41-py3-none-any.whl
.
File metadata
- Download URL: localrag-0.1.41-py3-none-any.whl
- Upload date:
- Size: 10.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3a28e8d57615b714b8ab48c44e494b2c8825ff03c89d18b682e97270be47830f |
|
MD5 | db37be89e2dc30cebb6e0510e5c285b7 |
|
BLAKE2b-256 | 4a775edb7dca8a8d545381af879e74278c4c2dd2117780543ef8e532677c5fb1 |