-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
17 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,30 @@ | ||
# A knowledge database in your command line | ||
`kdb` is a knowledgebase command line tool that relies on [Ollama](https://github.com/ollama/ollama). You can use it as is or integrate it with 3rd party tools to make your own Retrieval Augmented Generation (RAG) system. | ||
|
||
## How to query information? | ||
Simply use the `query` parameter to retrieve relevant informations. You can use the `--limit` parameter to indicate how many of most relevant entries you want to retrieve. | ||
``` | ||
./kdb query "What is the meaning of life?" --limit 1 | ||
``` | ||
as you can see it doesn't return anything, because it doesn't have any knowledge yet. | ||
|
||
|
||
## How to add knowledge? | ||
You can use the `embed` paramter to pass a piece of knowledge to the database. | ||
``` | ||
./kdb embed "Here is a sample piece of information to be remembered!" | ||
``` | ||
There is a script in the `test_content` directory which you can use to add some sample knowledge. | ||
``` | ||
cd test_content/ | ||
chmod +x ./train.sh | ||
./train.sh | ||
``` | ||
## Dependencies | ||
* [Ollama](https://github.com/ollama/ollama) | ||
|
||
This will add a bunch of sample knowledge. You can now ask questions about it: | ||
``` | ||
./kdb query "how many times Alpha is smaller than Gamma?" --top 3 | ||
``` | ||
and it returns the revelant piece of informations. | ||
|
||
## How to ask questions? | ||
You can connect the outcome of `./kdb query "your question"` to Ollama to retrieve the information in a friendly way. It would be exactly like a simple Retrieval-augmented generation (RAG) solution. There is an `ask` command in this repo that makes life easier. For example: | ||
```bash | ||
$ ask "how many times Alpha is smaller than Gamma?" | ||
``` | ||
Should return a reply like: | ||
``` | ||
Since Alpha is half of Beta, and Beta is smaller than Gamma (which is three times of Beta), we can conclude that Alpha is | ||
one-sixth of Gamma. Therefore, Alpha is six times smaller than Gamma. | ||
``` | ||
Or you can make your own prompt for it: | ||
``` | ||
echo "Answer to the question by following the given context. IF you don't know the answer simply say you don't know. Do not do yapping. The Context: $(./kdb query "What is the meaning of life?" --limit 3)" | ollama run llama3 | ||
``` | ||
## Building the project | ||
1. Clone the repository | ||
2. `make build` | ||
3. Your binaries are at `bin/` directory | ||
|
||
## How to list all entries? | ||
You can do this by using `list` parameter and pass the max number of entries to be listed as `--limit`. | ||
## Run | ||
Here is the list of available commands | ||
``` | ||
./kdb --list --limit 100 | ||
kdb --help | ||
``` | ||
|
||
## How to delete an entry? | ||
You can simply use the `delete` option: | ||
## How embedding works? | ||
``` | ||
./kdb delete "b1827d5a-16d2-4f74-acfa-29864434859a" | ||
kdb embed "here is some text" | ||
``` | ||
![Image](docs/kdb-embed-diagram.png) | ||
[source](https://www.plantuml.com/plantuml/dumla/RO_BJiCm44Nt_eghY0MLqj3oO16XgekoO4CHBIj0gfEPWjN4hk8n3o7-7LkbFAIiHXgVETTtwaLt4jf6wI3EXhRYJkbQN8S0xP7TUUuojOsGgSrMMy66AaLQTAKzWoeaQXRgpQpwpsNpfj6jpXBWb0eOJj9jYTL1ck2OHSYUkMCO3-zQXl2RP2kLdeTxt5WZkyq4hiJDVB74qUxu0vMZzx9FWa_bVXqld2gLk1yLu-EJ7AFYzEmyHr4KZtjrmgwk5vUtopYMyzttoDWd_s0FQsU5hUJVea5SzMJcVVw1-bjcZCwzUkZrEegOVfg662xSGXCnbRW8mT14JTbIQ9il) | ||
|
||
## Need the list of parameters? | ||
You can run `kdb` with the `--help` parameter to get the list of parameters. | ||
## How data is retrieved? | ||
``` | ||
./kdb --help | ||
kdb query "find something" | ||
``` | ||
![Image](docs/kdb-query-diagram.png) | ||
[source](https://www.plantuml.com/plantuml/dumla/RO-zJlCm68LtNyLHz0tVa8Ro0qC6L47B10fAou0eedRy0bOJkzYlaIh4lLC7HO1WikJpdCS-ay3IS-nQ8ICx6pj5NiY6dKU43CXk0lbCR7QGQSn6MiPQAw4bIoK3GQkUciPcFLK_kQngMzd9B05EY8ZHQUgMMFrB9ruY-IsoHsCrWkk8durzobOYPQE1DTPmkabbL-AwcY-mHvqYZJSefxVbBmFUXViIl58QK-9kNEmV7EOO5qV79pcAehWVl0cRpovdvmiqpZ9PpY6zbzi7RG9Bsz3_Jqk-j7zeS55NL-Z_f7VlXwMjwkcinjajXdxYnFTPDONOCW9nIeR5SJVG6ylmVHp4XAoENVi1) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.