Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
- run: npm audit --audit-level=high
- run: npm test
- run: npm run test:chat-math
- run: npm run test:retrieval
- run: npm run test:thumbnails
- run: node --test scripts/test-word-files.cjs scripts/test-network-security.cjs scripts/test-release-build.mjs scripts/test-claude-path.cjs scripts/test-agy.cjs
- run: node --test scripts/test-link-history.mjs scripts/test-text-direction.mjs
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -372,3 +372,13 @@ privately, see [SECURITY.md](SECURITY.md).

[MIT](LICENSE). Folio includes third-party software under its own licenses; see
[THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md).

### Local semantic search (source build)

The Semantic search toolbar icon (Ctrl+Shift+F) opens a dedicated sidebar for
local Exact, Semantic and Hybrid passage search.
Install an optional embedding model in Settings → Semantic Search, then index
the PDF. Indexes persist independently of annotations and reuse shared text when
models change. No model or inference service is needed for normal reading/find.
See [architecture and limitations](docs/semantic-search.md) and the
[synthetic benchmark report](docs/retrieval-benchmarks.md).
18 changes: 18 additions & 0 deletions THIRD_PARTY_NOTICES.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ they cover, and Electron's and Chromium's licenses are in the app's installation
| [Electron](https://www.electronjs.org) | MIT | GitHub Inc., OpenJS Foundation and contributors |
| Chromium (bundled with Electron) | BSD-3-Clause and others | The Chromium Authors |
| [electron-updater](https://github.com/electron-userland/electron-builder) and its dependencies | MIT, ISC, BlueOak-1.0.0, Python-2.0 | electron-builder contributors and others |
| [Transformers.js](https://github.com/huggingface/transformers.js) and ONNX Runtime (optional local inference) | Apache-2.0, MIT | Hugging Face and Microsoft |
| [sharp](https://sharp.pixelplumbing.com) and its dynamically linked libvips distribution | Apache-2.0, LGPL-3.0-or-later and the dependency licenses listed in the bundled `@img/sharp-libvips-*/README.md` | sharp and libvips contributors |
| [sqlite-vec](https://github.com/asg017/sqlite-vec) (local vector retrieval) | MIT, Apache-2.0 | Alex Garcia |
| [mammoth](https://github.com/mwilliamson/mammoth.js) (Word document conversion) and its dependencies | BSD-2-Clause, MIT, ISC, Zlib, Python-2.0; JSZip under MIT (of MIT OR GPL-3.0-or-later) | Michael Williamson and others |

The sample document (`public/sample.pdf`) was written for Folio and is covered by Folio's MIT License.
Expand Down Expand Up @@ -78,3 +81,18 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

## Downloaded embedding models

Models are optional downloads, not bundled weights. The pinned model registry lists
source revisions, file digests and licenses. BGE Small EN v1.5 is MIT licensed;
all-MiniLM-L6-v2 is Apache-2.0 licensed. EmbeddingGemma uses the Gemma terms (explicit acceptance is required before download);
Qwen3 uses Apache-2.0. No ReadAny source
code is included. Backend dependency license texts ship inside their packages.

Native inference/vector license texts are also in `licenses/backend/`. Libvips
and its dependencies are dynamically linked and unpacked beside the application,
so these libraries can be replaced. Corresponding source and build configuration:
https://github.com/lovell/sharp-libvips (distribution 1.3.4; bundled versions are
listed in each platform package’s `versions.json`). LGPL and GPL license texts
for these library terms are included; Folio’s own code remains MIT.
674 changes: 674 additions & 0 deletions build/third-party/GPL-3.0.txt

Large diffs are not rendered by default.

165 changes: 165 additions & 0 deletions build/third-party/LGPL-3.0.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007

Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.


This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.

0. Additional Definitions.

As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.

"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.

An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.

A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".

The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.

The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.

1. Exception to Section 3 of the GNU GPL.

You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.

2. Conveying Modified Versions.

If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:

a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or

b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.

3. Object Code Incorporating Material from Library Header Files.

The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:

a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.

b) Accompany the object code with a copy of the GNU GPL and this license
document.

4. Combined Works.

You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:

a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.

b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.

c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.

d) Do one of the following:

0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.

1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.

e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)

5. Combined Libraries.

You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:

a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.

b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.

6. Revised Versions of the GNU Lesser General Public License.

The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.

Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.

If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
21 changes: 21 additions & 0 deletions build/third-party/onnxruntime-LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) Microsoft Corporation

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
21 changes: 21 additions & 0 deletions build/third-party/sqlite-vec-LICENSE-MIT.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Alex Garcia

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
90 changes: 90 additions & 0 deletions docs/retrieval-benchmarks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Local retrieval validation

Linux x86_64, AMD Ryzen 7 7735HS, 29 GiB RAM, Node 24.20.0 and
Electron 45.2.1. Measurements are local observations, not performance guarantees.
No production document or query was sent to an external inference service.

## Reproducible commands

```
npm run test:retrieval
npm run build
npm run smoke:retrieval
FOLIO_TEST_MODELS=1 npm run smoke:retrieval
```

The last command explicitly installs BGE and MiniLM in a temporary test profile,
verifies CPU inference/retrieval, uses offline mode, and deletes the profile.
`FOLIO_TEST_ALL_MODELS=1` also exercises enabled larger catalog entries.
`FOLIO_KEEP_TEST_PROFILE=1` retains test assets and prints the directory.
`FOLIO_MODEL_FIXTURE=/path/to/test/profile/retrieval/models` reuses already downloaded
models. These flags never point at the user's installed Folio profile.

```
FOLIO_MODEL_FIXTURE=/path/to/test/models npm run benchmark:retrieval
FOLIO_MODEL_FIXTURE=/path/to/test/models FOLIO_BENCHMARK_PAGES=7000 npm run benchmark:retrieval
```

The benchmark emits JSON under `release/`, excluded from Git. It opens the generated
PDF in the reader and indexes that same PDF through the utility process. Relevance
labels are manually assigned for five technical queries (DMA recovery, I2C enable,
software reset, watchdog timeout, PCIe BAR mapping). The four relevant pages are
followed by mechanical-assembly distractor pages. This intentionally simple dataset
checks retrieval mechanics, not general relevance quality or complex PDF layout.

## 7,000-page synthetic baseline

Measured after adding per-model embedding checkpoints. Default indexing: two CPU
threads, four passages per batch; measured semantic query runs use one CPU thread.
The PDF is 1.89 MB with one short passage per page. No images, scans or complex tables.
The large document was open throughout indexing.

| Mode/model | Index duration | First query | Warm mean |
| --- | ---: | ---: | ---: |
| Exact, no model | 11.80 s shared extraction | 8.75 ms | 7.61 ms |
| BGE semantic | 35.83 s embeddings only | 157.11 ms | 30.53 ms |
| BGE hybrid | same index | 27.86 ms | 23.76 ms |
| MiniLM semantic | 23.27 s embeddings only | 132.16 ms | 17.34 ms |
| MiniLM hybrid | same index | 17.79 ms | 17.79 ms |

Semantic first-query measurements include reloading the model after disposing its
session; filesystem caches may be warm. Hybrid reuses the loaded session.
Recall@5, Recall@10, MRR@10 and nDCG@10 were 1.0 for every mode on this small
five-query label set. This is not evidence of equivalent quality on real manuals.

Opening the document took 7.59 s. Peak search-process working set was 357 MiB;
peak sum of all Electron working sets was 1,457 MiB (shared pages can be counted
more than once). Database plus WAL occupied 33.3 MB, excluding model weights and
original PDF. Across 40 samples, reader input-to-navigation averaged 35.82 ms (30.39–54.44 ms).
These measure scripted input/Enter handling, not display-frame latency.

An earlier run without embedding checkpoints took 86.72 s for BGE and 72.01 s for
MiniLM. Profiling the work exposed repeated scans of already embedded chunks;
persisted per-model chunk cursors now bound that work without changing extraction.

## Provisional targets and remaining measurements

On this hardware, target warm retrieval below 250 ms, reader input below 100 ms,
and a search utility working set below 1 GiB for small CPU embedding models.
These provisional targets must be reassessed on dense real documentation. Model
download time depends on the network and is not characterized here.

Real 7,000–10,000-page technical manuals, multiple columns, long register tables,
image-heavy documents and OCR-backed indexing still need their own corpus and
reviewed relevance labels. Windows/macOS binaries and Linux installers require
platform execution beyond the local Linux ASAR harness; no release was published.

## Final package checks

Linux `.deb` (193 MiB) and AppImage (239 MiB) were generated locally with
publication disabled. The final ASAR inside the Linux output passed the hidden
Electron test with all four installed models, Italian-to-English retrieval,
passage highlighting, and pause/cancel/restart/resume over a 1,000-page fixture.
The installer scripts were inspected through Debian package metadata; they were
not executed and the existing installed Folio was not replaced.

The original baseline run stopped in the OCR selection fixture; an untouched
`0590fac` checkout also failed there. After rebasing onto `16f8da3` and making the
smoke's desktop viewport and bookmark starting page explicit, the full
`npm run smoke` passes on Linux, including OCR, printing and retrieval.
The benchmark measurements above were not rerun as part of that smoke validation.
Loading