|
5 | 5 |
|
6 | 6 | # WDoc |
7 | 7 |
|
8 | | -* **Goal and project specifications** use [LangChain](https://python.langchain.com/) to summarize, search or query documents. I'm a medical student so I need to be able to query from **tens of thousands** of documents, of different types ([Supported filetypes](#Supported-filetypes)). I also have little free time so I needed a tailor made summary feature to keep up with the news. |
9 | | -* **Current status**: **still under development**. |
10 | | - * I use it almost daily and have been for months now. |
11 | | - * Expect some breakage but they can be fixed usually in a few minutes if you open an issue here. |
12 | | - * The main branch is usually fine but the dev branch has more features. |
13 | | - * I accept feature requests and pull requests. |
14 | | - * Issues are extremely appreciated for any reason including typos etc. |
15 | | - * Prefer asking me before making a PR because I have many improvements in the pipeline but do this on my spare time. Do tell me if you have specific needs! |
| 8 | +WDoc is a powerful RAG (Retrieval-Augmented Generation) system designed to summarize, search, and query documents across various file types. It's particularly useful for handling large volumes of diverse document types, making it ideal for researchers, students, and professionals dealing with extensive information sources. |
| 9 | + |
| 10 | +* **Goal and project specifications**: WDoc uses [LangChain](https://python.langchain.com/) to process and analyze documents. It's capable of querying **tens of thousands** of documents across [various file types](#Supported-filetypes). The project also includes a tailored summary feature to help users efficiently keep up with large amounts of information. |
| 11 | + |
| 12 | +* **Current status**: **Under active development** |
| 13 | + * Used daily by the developer for several months |
| 14 | + * May have some instabilities, but issues can usually be resolved quickly |
| 15 | + * The main branch is stable, while the dev branch offers more features |
| 16 | + * Open to feature requests and pull requests |
| 17 | + * All feedback, including reports of typos, is highly appreciated |
| 18 | + * Please consult the developer before making a PR, as there may be ongoing improvements in the pipeline |
| 19 | + |
| 20 | +* **Key Features**: |
| 21 | + * Supports multiple file types for comprehensive document analysis |
| 22 | + * Utilizes both strong and query evaluation LLMs for accurate results |
| 23 | + * Customizable summarization capabilities |
| 24 | + * Efficient handling of large document corpora |
16 | 25 |
|
17 | 26 | ### Table of contents |
18 | 27 | - [Features](#features) |
19 | 28 | - [Planned Features](#planned-features) |
20 | 29 | - [Supported filetypes](#supported-filetypes) |
21 | 30 | - [Supported tasks](#supported-tasks) |
22 | 31 | - [Walkthrough and examples](#walkthrough-and-examples) |
| 32 | +- [Scripts made with WDoc](#scripts-made-with-wdoc) |
23 | 33 | - [Getting started](#getting-started) |
24 | 34 | - [FAQ](#faq) |
25 | 35 | - [Notes](#notes) |
26 | 36 | - [Known issues](#known-issues) |
27 | 37 |
|
28 | 38 | ## Features |
| 39 | +* **15+ filetypes**: also supports combination to load recursively or define complex heterogenous corpus like a list of files, list of links, using regex, youtube playlists etc. See [Supported filestypes](#Supported-filetypes). All filetype can be seamlessly combined in the same index, meaning you can query your anki collection at the same time as your work PDFs). It supports removing silence from audio files and youtube videos too! |
| 40 | +* **100+ LLMs**: OpenAI, Mistral, Claude, Ollama, Openrouter, etc. Thanks to [litellm](https://docs.litellm.ai/). |
| 41 | +* **Local and Private LLM**: take some measures to make sure no data leaves your computer and goes to an LLM provider: no API keys are used, all `api_base` are user set, cache are isolated from the rest, outgoing connections are censored by overloading sockets, etc. |
29 | 42 | * **Advanced RAG to query lots of diverse documents**: |
30 | 43 | 1. The documents are retrieved using embedding |
31 | 44 | 2. Then a weak LLM model ("Evaluator") is used to tell which of those document is not relevant |
|
37 | 50 | * Instead of unusable "high level takeaway" points, compress the reasoning, arguments, though process etc of the author into an easy to skim markdown file. |
38 | 51 | * The summaries are then checked again n times for correct logical indentation etc. |
39 | 52 | * The summary can be in the same language as the documents or directly translated. |
40 | | -* **Multiple LLM providers**: OpenAI, Mistral, Claude, Ollama, Openrouter, etc. Thanks to [litellm](https://docs.litellm.ai/). |
41 | | -* **Private LLM**: take some measures to make sure no data leaves your computer and goes to an LLM provider: no API keys are used, all `api_base` are user set, cache are isolated from the rest, outgoing connections are censored by overloading sockets, etc. |
42 | 53 | * **Many tasks**: See [Supported tasks](#Supported-tasks). |
43 | | -* **Many filetypes**: also supports combination to load recursively or define complex heterogenous corpus like a list of files, list of links, using regex, youtube playlists etc. See [Supported filestypes](#Supported-filetypes). All filetype can be seamlessly combined in the same index, meaning you can query your anki collection at the same time as your work PDFs). It supports removing silence from audio files and youtube videos too! |
| 54 | +* **Markdown formatted answers and summaries**: using [rich](https://github.com/Textualize/rich). |
44 | 55 | * **Sane embeddings**: By default use sophisticated embeddings like HyDE, parent retriever etc. Customizable. |
45 | | -* **Documented** Lots of docstrings, lots of in code comments, detailed `--help` etc. The full usage can be found in the file [USAGE.md](./WDoc/docs/USAGE.md) or via `python -m WDoc --help`. |
| 56 | +* **Fully documented** Lots of docstrings, lots of in code comments, detailed `--help` etc. The full usage can be found in the file [USAGE.md](./WDoc/docs/USAGE.md) or via `python -m WDoc --help`. I work hard to maintain an exhaustive documentation. |
| 57 | +* **Scriptable / Extensible**: You can use WDoc in other python project using `--import_mode`. Take a look at the examples [below](#scripts-made-with-wdoc). |
| 58 | +* **Statically typed**: Runtime type checking. Opt out with an environment flag: `WDOC_TYPECHECKING="disabled / warn / crash" WDoc` (by default: `warn`). Thanks to [beartype](https://beartype.readthedocs.io/en/latest/) it shouldn't even slow down the code! |
46 | 59 | * **Lazy imports**: Faster statup time thanks to lazy_import |
47 | 60 | * **LLM (and embeddings) caching**: speed things up, as well as index storing and loading (handy for large collections). |
48 | 61 | * **Sophisticated faiss saver**: [faiss](https://github.com/facebookresearch/faiss/wiki) is used to quickly find the documents that match an embedding. But instead of storing as a single file, WDoc splits the index into 1 document long index identified by deterministic hashes. When creating a new index, any overlapping document will be automatically reloaded instead of recomputed. |
49 | | -* **Easy model testing** Include an LLM name matcher that fuzzy finds the most appropriate model given an name. |
50 | 62 | * **Good PDF parsing** PDF parsers are notoriously unreliable, so 10 (!) different loaders are used, and the best according to a parsing scorer is kept. |
51 | | -* **Markdown formatted answers and summaries**: using [rich](https://github.com/Textualize/rich). |
52 | 63 | * **Document filtering**: based on regex for document content or metadata. |
53 | | -* **Fast**: Parallel document parsing and embedding. |
| 64 | +* **Fast**: Parallel document loading, parsing, embeddings, querying, etc. |
54 | 65 | * **Shell autocompletion** using [python-fire](https://github.com/google/python-fire/blob/master/docs/using-cli.md#completion-flag) |
55 | | -* **Static typed**: Runtime type checking. Opt out with an environment flag: `WDOC_TYPECHECKING="disabled / warn / crash" WDoc` (by default: `warn`). Thanks to [beartype](https://beartype.readthedocs.io/en/latest/) it shouldn't even slow down the code! |
56 | | -* **Scriptable**: You can use WDoc in other python project using `--import_mode` |
57 | 66 | * **Notification callback**: Can be used for example to get summaries on your phone using [ntfy.sh](ntfy.sh). |
58 | | -* **Fully documented**: I work hard to maintain an exhaustive documentation at `wdoc --help` |
59 | | -* Very customizable, with a friendly dev! Just open an issue if you have a feature request or anything else. |
| 67 | +* **Hacker mindset**: I'm a friendly dev! Just open an issue if you have a feature request or anything else. |
60 | 68 |
|
61 | 69 | ### Planned features |
62 | 70 | *(These don't include improvements, bugfixes, refactoring etc.)* |
|
66 | 74 | * More configurable HyDE. |
67 | 75 | * Web search retriever, online information lookup via jina.ai reader and search. |
68 | 76 | * LLM powered synonym expansion for embeddings search. |
69 | | -* Investigate switching to Milvus Lite instead of handling split faiss indexes. |
70 | 77 | * A way to specify at indexing time how trusting you are of a given set of document. |
71 | 78 | * A way to open the documents automatically, based on the platform used. For ex if okular is installed, open pdfs directly at the appropriate page. |
72 | 79 | * Improve the scriptability of WDoc. Add examples for how you use it with Logseq. |
73 | 80 | * Include a server example, that mimics the OpenAI's API to make your RAG directly accessible to other apps. |
74 | 81 | * Add a gradio GUI. |
75 | 82 | * Include the possible whisper/deepgram extra expenses when counting costs. |
76 | 83 | * Add support for user defined loaders. |
77 | | -* Add support for custom user prompt. |
78 | 84 | * Automatically caption document images using an LLM, especially nice for anki cards. |
79 | 85 |
|
80 | 86 | ### Supported filetypes |
|
118 | 124 | 7. There is a specific recursive filetype I should mention: `--filetype="link_file"`. Basically the file designated by `--path` should contain in each line (`#comments` and empty lines are ignored) one url, that will be parsed by WDoc. I made this so that I can quickly use the "share" button on android from my browser to a text file (so it just appends the url to the file), this file is synced via [syncthing](https://github.com/syncthing/syncthing) to my browser and WDoc automatically summarize them and add them to my [Logseq](https://github.com/logseq/logseq/). Note that the url is parsed in each line, so formatting is ignored, for example it works even in markdown bullet point list. |
119 | 125 | 8. If you want to make sure your data remains private here's an example with ollama: `wdoc --private --llms_api_bases='{"model": "http://localhost:11434", "query_eval_model": "http://localhost:11434"}' --modelname="ollama_chat/gemma:2b" --query_eval_modelname="ollama_chat/gemma:2b" --embed_model="BAAI/bge-m3" my_task` |
120 | 126 | 9. Now say you just want to summarize [Tim Urban's TED talk on procrastination](https://www.youtube.com/watch?v=arj7oStGLkU): `wdoc summary --path 'https://www.youtube.com/watch?v=arj7oStGLkU' --youtube_language="english" --disable_md_printing`: |
| 127 | + |
121 | 128 | > # Summary |
122 | 129 | > ## https://www.youtube.com/watch?v=arj7oStGLkU |
123 | 130 | > - The speaker, Tim Urban, was a government major in college who had to write many papers |
|
161 | 168 | > - Stay aware of the Instant Gratification Monkey |
162 | 169 | > - Start addressing procrastination soon |
163 | 170 | > - *Humorously* suggests not starting today, but 'sometime soon' |
| 171 | +> |
164 | 172 | > Tokens used for https://www.youtube.com/watch?v=arj7oStGLkU: '4365' ($0.00060) |
| 173 | +> |
165 | 174 | > Total cost of those summaries: '4365' ($0.00060, estimate was $0.00028) |
| 175 | +> |
166 | 176 | > Total time saved by those summaries: 8.4 minutes |
| 177 | +> |
167 | 178 | > Done summarizing. |
168 | 179 |
|
169 | 180 |
|
|
179 | 190 | * To ask questions about a document: `wdoc query --path="PATH/TO/YOUR/FILE" --filetype="auto"` |
180 | 191 | * If you want to reduce the startup time, you can use --saveas="some/path" to save the loaded embeddings from last time and --loadfrom "some/path" on every subsequent call. (In any case, the embeddings are always cached) |
181 | 192 | * For more: read the documentation at `wdoc --help` |
182 | | -* For shell autocompletion: `eval $(cat completion.cli.zsh)` and `eval $(cat completion.m.zsh)`. You can generate your own with `eval "$(wdoc -- --completion)"` and `eval "$(python -m WDoc -- --completion)"`. |
| 193 | +* For shell autocompletion: if you're using zsh: `eval $(cat completion.cli.zsh)` and `eval $(cat completion.m.zsh)`. You can generate your own with `eval "$(wdoc -- --completion)"` and `eval "$(python -m WDoc -- --completion)"`. |
| 194 | + |
| 195 | +## Scripts made with WDoc |
| 196 | +* *More to come in [the examples folder](./examples/)* |
| 197 | +* [Ntfy Summarizer](examples/NtfySummarizer): automatically summarize a document from your android phone using [ntfy.sh](ntfy.sh) |
| 198 | +* [TheFiche](examples/TheFiche): create summaries for specific notions directly as a [logseq](https://github.com/logseq/logseq) page. |
183 | 199 |
|
184 | 200 | ## FAQ |
185 | 201 | * **Who is this for?** |
|
205 | 221 | * I use it to query my personal documents using the `--private` argument. |
206 | 222 | * I sometimes use it to summarize a documents then go straight to asking questions about it, all in the same command. |
207 | 223 | * I use it to ask questions about entire youtube playlists. |
| 224 | + * Other use case are the reason I made the [scripts made with WDoc example section}(#scripts-made-with-wdoc) |
208 | 225 | * **What's up with the name?** One of my favorite character (and somewhat of a rolemodel is [Winston Wolf](https://www.youtube.com/watch?v=UeoMuK536C8) and after much hesitation I decided `WolfDoc` would be too confusing and `WinstonDoc` sounds like something micro$oft would do. Also `wd` and `wdoc` were free, whereas `doctools` was already taken. The initial name of the project was `DocToolsLLM`, a play on words between 'doctor' and 'tool'. |
209 | 226 |
|
210 | 227 | ## Notes |
|
0 commit comments