Lurker News
Hi folks, we're Debanjum and Saba. We created Khoj as a hobby project 2+ years ago because: (1) Search on the desktop sucked; we just had keyword search on the desktop vs google for the internet; and (2) Natural language search models had become good and easy to run on consumer hardware by this point.

Once we made Khoj search incremental, I completely stopped using the default incremental search (C-s) in Emacs. Since then Khoj has grown to support more content types, deeper integrations and chat (using ChatGPT). With Llama 2 released last week, chat models are finally good and easy enough to use on consumer hardware for the chat with docs scenario.
Khoj is a desktop application to search and chat with your personal notes, documents and images. It is accessible from within Emacs, Obsidian or your Web browser. It works with org-mode, markdown, pdf, jpeg files and notion, github repositories. It is open-source and can work without internet access (e.g on a plane).
Our chat feature allows you to extract answers and create content from your existing knowledge base. Example: "What was that book Trillian mentioned at Zaphod's birthday last week". We personally use the chat feature regularly to find links, names and addresses (especially on mobile) and collate content across multiple, messy notes. It works online or offline: you can chat without internet using Llama 2 or with internet using GPT3.5+ depending on your requirements.
Our search feature lets you quickly find relevant notes, documents or images using natural language. It does not use the internet. Example: Search for "bought flowers at grocery store" will find notes about "roses at wholefoods".
Quickstart:

  pip install khoj-assistant && khoj
See https://docs.khoj.dev/#/setup for detailed instructions

We also have desktop apps (in beta) at https://github.com/khoj-ai/khoj/releases/tag/0.10.0 if you want to try them out.
Please do try out Khoj and let us know if it works for your use cases? Looking forward to the feedback!

Comments (150) 37 threads

Earlier comments
yberreby1 reply#
Cool project. I tried it last time this got posted, but it was still a bit buggy. Giving it another shot - I'm mainly interested in the local chat.

Could you elaborate on the incremental search feature? How did you implement it? Don't you need to re-encode the full query through a SBERT or such as each token is written (perhaps with debouncing)?
Also, having an easily-extended data connector interface would be awesome, to connect to custom data sources.

110#
Buggy for setup? We've done some improvements and have desktop apps (in beta) too now to simplify this. Feel free to report any issues on the khoj github. I can have a look.

Yes, we don't do optimizations on the query encoding yet. So SBERT just re-encodes the whole query every time. It gets results in <100ms which is good enough for incremental search.
I did create a plugin system, so that a data plugin just has to convert the source data into a standardized intermeditate jsonl format. But this hasn't been documented or extensively tested yet.

IshKebab1 reply#
Interesting. The obvious question you haven't answered anywhere (as far as I can see) is what are the hardware requirements to run this locally?
1102 replies#
Ah, you're right, forgot to mention that. We use the Llama 2 7B 4 bit quantized model. The machine requirements are:

Ideal: 16Gb (GPU) RAM
Less Ideal: 8GB RAM and CPU

danparsonson1 reply#
So just to clarify, is that: Ideal is running the model on a GPU (any brand? Nvidia, AMD, etc.?) with 16GB of GPU RAM, less ideal is running it on the CPU, for which it needs 8GB system RAM? Presumably it will occupy all that memory while it's running?

What about if I have a GPU with 8GB?

110#
Khoj uses Llama 2 7B, 4bit quantized. So it just needs 3.5Gb of RAM (GPU or System) [1].

Khoj and your other apps need more RAM themselves, so practically 8GB of System or GPU RAM should suffice.
Khoj has been tested with CUDA and Metal capable GPUs. So Nvidia and Mac M1+ GPUs should work. I'm think it'll work with AMD GPUs out of the box too but let me know if it doesn't for you? I can look into what needs to be done to get that to work.
[1]: The calculation is [params] * [bytes] GB RAM, so 7 * 0.5 = 3.5Gb

HexDecOctBin1 reply#
Sorry for the repetition, but do you mean 16 GB VRAM? That is a very high requirement, a RTX 4060 only has 8GB and even a RTX 4070 only ships with 12GB. Any upcoming further optimizations for reducing memory usage?

PS. Nice to see an Hindi name for a software. For those who don't speak Hindi: https://en.m.wiktionary.org/wiki/%E0%A4%96%E0%A5%8B%E0%A4%9C...

intended#
One of the reasons 4090 / 3090s are expensive these days. It’s an issue with the models, not with Khoj.
thangngoc891 reply#
I’m in search of a new Macbook Mx. what is the requirements for running these model locally without breaking the bank? Would 32GB be enough?
1101 reply#
You do not need to break the bank to use Khoj for local chat, 16Gb RAM should be good enough
DoctorOetker1 reply#
How slow would that be on an old non-Apple laptop, but also 16Gb RAM?

lscpu output: Architecture: x86_64

  CPU op-mode(s):        32-bit, 64-bit

  Address sizes:         36 bits physical, 48 bits virtual

  Byte Order:            Little Endian
CPU(s): 8

  On-line CPU(s) list:   0-7
Vendor ID: GenuineIntel

  Model name:            Intel(R) Core(TM) i7-3630QM CPU @ 2.40GHz

    CPU family:          6

    Model:               58

    Thread(s) per core:  2

    Core(s) per socket:  4

    Socket(s):           1

    Stepping:            9

    CPU(s) scaling MHz:  35%

    CPU max MHz:         3400.0000

    CPU min MHz:         1200.0000

    BogoMIPS:            4791.90

    Flags:               fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cp

                         uid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm cpuid_fault epb pti ssbd ibrs ibpb stibp tpr
                         _shadow vnmi flexpriority ept vpid fsgsbase smep erms
xsaveopt dtherm ida arat pln pts md_clear flush_l1d

  L1d:                   128 KiB (4 instances)

  L1i:                   128 KiB (4 instances)

  L2:                    1 MiB (4 instances)

  L3:                    6 MiB (1 instance)
NUMA:

  NUMA node(s):          1

  NUMA node0 CPU(s):     0-7
110#
It should work but not sure how fast. Best way to find out would be to try it.

We also have some fixes and perf improvements we plan to release later today in version 0.10.1

jigneshdarji912 replies#
This would be even great if available as a Spotlight Search replacement (with some additional features that Spotlight supports).
tough1 reply#
Should be easy to plug it in with a Raycast.app or Alfred.app plugin.
110#
Khoj exposes a local API. Hopefully that makes it easy to integrate with Raycast, Alfred (or even Spotlight)?
110#
Yeah, this would be ideal for Mac users. Just need to look into what is required and how much work it is

Load more comments