Skip to content
Back to search

litdb

A literature database

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked yesterday

Check it deeper on your machine

It has changed since its scan on 18 Nov 2026.

As a Claude Code plugin, install it and then ask Claude Code:

/plugin marketplace add keithmackay/mackayi/plugin install scanskillsafety@mackayiDo a deep scan of https://github.com/jkitchin/litdb with scanskillsafety

Or from a terminal, clone it and run it:

git clone https://github.com/keithmackay/scanskillsafety-skill ~/.claude/skills/scanskillsafetynode ~/.claude/skills/scanskillsafety/cli.cjs --deep 'https://github.com/jkitchin/litdb'

It checks the exact commit: every file, its packages against OSV (api.osv.dev), how it compares with this page's scan (findsafeskills.com receives the repository's address), and, if you agree, Claude reading every file with your own Claude subscription. It never runs the code.

Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/jkitchin--litdb/badge.svg)](/listings/jkitchin--litdb)

HTML

<a href="/listings/jkitchin--litdb"><img src="/api/listings/jkitchin--litdb/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

uvx knowhow add jkitchin/litdb --skill litdb

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

README.org · README · 1,175 lines
  1. #+title: litdb - a literature and document database
  2. #+attr_org: :width 600
  3. [[./litdb.png]]
  4. #+BEGIN_html
  5. <a href="https://github.com/jkitchin/litdb/actions/workflows/build.yml">
  6. <img src="https://github.com/jkitchin/litdb/actions/workflows/build.yml/badge.svg" alt="Build Status">
  7. </a>
  8. <img src="https://img.shields.io/badge/tests-133_passed,_66_skipped-brightgreen" alt="Tests">
  9. <a href="https://doi.org/10.5281/zenodo.23514948">
  10. <img src="https://zenodo.org/badge/DOI/10.5281/zenodo.23514948.svg" alt="DOI">
  11. </a>
  12. #+END_HTML
  13. * litdb concept
  14. litdb is a tool to help you curate and use your collection of scientific literature. You use it to collect and search papers. You can use it to collect older articles, and to keep up with newer articles. litdb uses https://openalex.org for searching the scientific literature, and https://turso.tech/libsql to store results in a local database.
  15. The idea is you add papers to your database, and then you can search it with natural language queries, and interact with it via an ollama GPT application. It will show you the papers that best match your query. You can read those papers, get bibtex entries for them, or add new papers based on the references, papers that cite that paper, or related papers. You can also set up filters that you update when you want to get new papers created since the last time you checked.
  16. ** videos
  17. 1. https://www.youtube.com/live/e-J3Bh2Uti4 Introduction to litdb
  18. 2. https://www.youtube.com/live/teW68WogulU local files (volume is very low for some reason)
  19. 3. https://youtube.com/live/3LltpiiQaR8 CrossRef, reviewer suggestions, COA
  20. 4. https://youtube.com/live/ZkKKuvVUWkE litdb and Emacs
  21. 5. https://youtube.com/live/j7rItPwWDaY litdb and Jupyter Lab
  22. 6. https://youtube.com/live/SUtvtc7l6y0 litdb + GPT enhancements
  23. 7. https://youtube.com/live/3FZ1ROnCC6Y litdb + LiteLLM and streamlit
  24. 8. https://www.youtube.com/live/IKKTQSTXQmc litdb + Youtube and audio
  25. 9. https://youtube.com/live/MEf9rPI0Z1M litdb + Image search with text and image queries using CLIP
  26. 10. https://youtube.com/live/C4qCam0shf8 litdb + deep research
  27. 11. https://youtube.com/live/6Wpy7KM3wIM litdb + LLM-augmented search of OpenAlex
  28. 12. https://www.youtube.com/live/eS0D-Aje_6A litdb + Claude Desktop
  29. ** installation
  30. litdb is on PyPi.
  31. #+BEGIN_SRC sh
  32. pip install litdb
  33. #+END_SRC
  34. To get the cutting edge package, you can install it directly from GitHUB.
  35. #+BEGIN_SRC sh
  36. pip install git+https://github.com/jkitchin/litdb
  37. #+END_SRC
  38. litdb relies on a lot of ML-related packages, and conflicts with version are common. If you have any issues, I recommend you install it with uv (https://github.com/astral-sh/uv) like this:
  39. #+BEGIN_SRC sh
  40. uv venv --python 3.13
  41. source .venv/bin/activate
  42. uv pip install litdb
  43. #+END_SRC
  44. You have to activate that virtual env to use litdb, which may be annoying. An alternative is to install litdb as a uv tool, which puts ~litdb~ and ~litdb_mcp~ on your PATH in their own environment:
  45. #+BEGIN_SRC sh
  46. uv tool install litdb
  47. #+END_SRC
  48. This is also the easiest way to make the MCP server available to AI agents. See [[*Using litdb with AI agents (skill and MCP server)]].
  49. ** Recent additions
  50. *** Version 2.1.8
  51. - *fromtext command*: Extract and add references from pasted text using LLM parsing and CrossRef matching. See [[./FROMTEXT_USAGE.md][detailed documentation]].
  52. - *summary command*: Generate newsletter-style summaries of recent articles with automatic topic extraction and classification.
  53. - *extract command*: Extract tables from PDF files.
  54. - *schema command*: Extract structured data from documents using a flexible schema DSL or JSON format.
  55. - *Bug fix*: Corrected OpenAlex API parameter from ~email~ to ~mailto~ for proper API compliance.
  56. - *Security fix*: Replaced unsafe ~eval()~ with ~ast.literal_eval()~ in schema parsing.
  57. ** configuration
  58. You have to create a toml configuration file. This file is called litdb.toml. The directory this file is in is considered the root directory. All commands will start in the current working directory and look up to find this file. You can put this file in your home directory, or you can have sub-directories, e.g. a per project litdb.
  59. There are a few choices you have to make. You have to choose a SentenceTransformer model, and specify the size of the vectors it makes. You also have to specify the chunk_size and chunk_overlap settings that are used to break documents up to compute document level embedding vectors.
  60. You will need an OpenAlex premium key if you want to use the update-filters feature.
  61. #+BEGIN_EXAMPLE
  62. [embedding]
  63. # SentenceTransformer model for vector search
  64. model = 'all-MiniLM-L6-v2'
  65. cross-encoder = 'cross-encoder/ms-marco-MiniLM-L-6-v2'
  66. chunk_size = 1000
  67. chunk_overlap = 200
  68. [openalex]
  69. # Email for OpenAlex API (polite pool access)
  70. email = "you@example.com"
  71. # Optional: Premium API key for update-filters feature
  72. api_key = "..."
  73. [gpt]
  74. # Model for the 'litdb gpt' command (uses ollama)
  75. model = "llama2"
  76. [llm]
  77. # Model for LiteLLM-based commands (chat, fromtext, summary, schema, research)
  78. # Supports any provider: ollama/*, openai/*, anthropic/*, google_genai/*, etc.
  79. model = "ollama/llama2"
  80. #+END_EXAMPLE
  81. Configuration sections and their usage:
  82. - *[embedding]*: Used by all vector search operations (~vsearch~, ~hybrid-search~, etc.)
  83. - *[openalex]*: Required for OpenAlex searches and updates
  84. - *[gpt]*: Used by the ~litdb gpt~ command (ollama-only)
  85. - *[llm]*: Used by ~chat~, ~fromtext~, ~summary~, ~schema~, and ~research~ commands (supports all LiteLLM providers)
  86. You can define an environment variable to the root of your default litdb project. This should be a directory with a litdb.toml file in it.
  87. #+BEGIN_SRC sh
  88. export LITDB_ROOT="/path/to/your/default/litdb"
  89. #+END_SRC
  90. When you run a litdb command, it will look for a dominating litdb.toml file, which means you are running the command in a litdb project. If one is not found, it will check for the LITDB_ROOT environment variable and use that if it is found. Finally, if that does not exist, it will prompt you to make a new project in the current directory.
  91. * Using litdb
  92. Your litdb starts out empty. You have to add articles that are relevant to you. It is an open question of the best way to build a litdb. The answer surely depends on what your aim is. You have to compromise on breadth and depth with the database size. The CLI makes it pretty easy to do this
  93. litdb has a cli with an entry command of litdb and subcommands (like git) for interacting with it. You can see all the options with this command.
  94. #+BEGIN_SRC sh :dir example
  95. litdb --help
  96. #+END_SRC
  97. ** Command Organization
  98. litdb's 43 commands are organized into logical groups:
  99. - *Management*: init, add, remove, index, reindex, update_embeddings
  100. - *Search*: vsearch, fulltext, hybrid_search, lsearch, similar, image_search, screenshot
  101. - *Export*: bibtex, citation, show, visit, about, sql
  102. - *Tags*: add_tag, rm_tag, delete_tag, show_tag, list_tags
  103. - *Review*: review, summary
  104. - *Filters*: add_filter, rm_filter, update_filters, list_filters
  105. - *OpenAlex*: openalex, author_search, follow, watch, citing, related, unpaywall
  106. - *Research*: fhresearch, research, suggest_reviewers
  107. - *Data Processing*: crossref, fromtext, extract, schema, crawl
  108. - *Utilities*: web, audio, chat, app, version, coa
  109. ** Searching the web
  110. You have to start somewhere. You can use this to open a search in OpenAlex.
  111. #+BEGIN_SRC sh
  112. litdb web query
  113. #+END_SRC
  114. You can also open searches with these options:
  115. | option | source |
  116. |-----------------------+----------------|
  117. | -g, --google | Google |
  118. | -gs, --google-scholar | Google Scholar |
  119. | -ar, --arxiv | Arxiv |
  120. | -pm, --pubmed | Pubmed |
  121. | -cr, --chemrxiv | ChemRxiv |
  122. | -br, --biorxiv | BioRxiv |
  123. | -a, --all | All |
  124. You can find starting points this way.
  125. *** Fine-tuned search in OpenAlex
  126. This is a default query in Open Alex. It does not change your litdb, it just does a simple text search query on works.
  127. #+BEGIN_SRC sh
  128. litdb openalex query
  129. #+END_SRC
  130. You can get more specific with a filter:
  131. #+BEGIN_SRC sh
  132. litdb openalex -f 'author.orcid:https://orcid.org/0000-0003-2625-9232'
  133. #+END_SRC
  134. You can also search other endpoints and use fulters. Here we perform a search on Sources for display_names that contain the word discovery.
  135. #+BEGIN_SRC sh
  136. litdb openalex -e sources -f display_name.search:discovery
  137. #+END_SRC
  138. *** LLM-enhanced search of OpenAlex
  139. The previous command lets you define a precise keyword or filter search for OpenAlex. An alternative is the ~lsearch~ sub-command. This command uses a LLM to generate a set of keyword searches for OpenAlex. Then, for each keyword search it returns results that are sorted in ascending and descending citation counts, publication year, and it performs a random sample search. Each result is scored by vector similarity to the original query, and the top results are printed.
  140. #+BEGIN_SRC sh
  141. litdb lsearch "some query of interest"
  142. #+END_SRC
  143. some options include:
  144. - -q :: integer count of number of keyword queries to generate
  145. - -n :: integer count of results to retrieve for each keyword query
  146. - -k :: integer count of how many results to display
  147. ** One-time additions of articles to litdb
  148. You add an article by its DOI. There are optional arguments to also add references, citing and related articles.
  149. #+BEGIN_SRC sh
  150. litdb add doi --references --citing --related
  151. #+END_SRC
  152. To add an author, use their orcid. You can use ~litdb author-search firstname lastname~ to find an orcid for a person.
  153. #+BEGIN_SRC sh
  154. litdb add orcid
  155. #+END_SRC
  156. To add entries from a bibtex file, use the path to the file.
  157. #+BEGIN_SRC sh
  158. litdb add /path/to/bibtex.bib
  159. #+END_SRC
  160. You can provide more than one source and even mix them like this.
  161. #+BEGIN_SRC sh
  162. litdb add doi1 doi2 orcid
  163. #+END_SRC
  164. These are all one-time additions.
  165. You can also add things like YouTube videos and podcasts. We use ML to extract the audio from these to text so they become searchable!
  166. *** Adding references from text
  167. You can paste text containing academic references and litdb will use an LLM to extract and add them automatically. This is useful when copying reference lists from PDFs, papers, or websites.
  168. #+BEGIN_SRC sh
  169. litdb fromtext "Kitchin, Examples of Effective Data Sharing in Scientific Publishing, ACS Catalysis, 2015, DOI: 10.1021/acscatal.5b00538"
  170. #+END_SRC
  171. You can also add multiple references at once:
  172. #+BEGIN_SRC sh
  173. litdb fromtext "Recent work by Smith et al. (Nature, 2020) showed...
  174. Another study by Jones (Science, 2019) demonstrated..."
  175. #+END_SRC
  176. The command supports the same options as ~litdb add~ for adding related works:
  177. #+BEGIN_SRC sh
  178. litdb fromtext "TEXT" --references --related --citing
  179. #+END_SRC
  180. You can also specify which LLM model to use:
  181. #+BEGIN_SRC sh
  182. litdb fromtext "TEXT" --model "gpt-4o"
  183. #+END_SRC
  184. The LLM extracts structured reference information, then litdb uses CrossRef to find DOIs and match references. High-confidence matches are added automatically, while lower-confidence matches prompt for confirmation.
  185. See [[./FROMTEXT_USAGE.md][detailed documentation]] for more information on supported citation formats and how the matching works.
  186. ** Adding filters
  187. litdb provides several convenient ways to add queries to update your litdb in the future.
  188. *** Follow an author
  189. To get new papers by an author, you can follow them.
  190. #+BEGIN_SRC sh
  191. litdb follow orcid
  192. #+END_SRC
  193. *** Watch a query
  194. #+BEGIN_SRC sh
  195. litdb watch "filter to query"
  196. #+END_SRC
  197. *** Citations on a paper
  198. #+BEGIN_SRC sh
  199. litdb citing doi
  200. #+END_SRC
  201. *** Related papers
  202. #+BEGIN_SRC sh
  203. litdb related doi
  204. #+END_SRC
  205. *** A custom filter
  206. A filter is used in OpenAlex to search for relevant articles. Here is an example of adding a filter for articles in the journal Digital Discovery. This doesn't add any entries directly, it simply stores the filter in the database. The main difference of this vs the watch command above is the explicit description.
  207. #+BEGIN_SRC sh
  208. litdb add-filter "primary_location.source.id:https://openalex.org/S4210202120" -d "Digital Discovery"
  209. #+END_SRC
  210. *** Managing and updating the filters
  211. You can get a list of your filters like this.
  212. #+BEGIN_SRC sh
  213. litdb list-filters
  214. #+END_SRC
  215. You can update the filters like this.
  216. #+BEGIN_SRC sh
  217. litdb update-filters
  218. #+END_SRC
  219. This adds papers that have been created since the last time you ran the filter. You need an OpenAlex premium API key for this. This will update the last_updated field.
  220. You can remove a filter like this:
  221. #+BEGIN_SRC sh
  222. litdb rm-filter "filter-string"
  223. #+END_SRC
  224. ** Review your litdb
  225. I find it helpful to review your litdb. To get a list of articles added in the last week, you can run this command.
  226. #+BEGIN_SRC sh
  227. litdb review -s "1 week ago"
  228. #+END_SRC
  229. This works best when you update your litdb regularly. You might want to redirect that into a file so you can review it in an editor of your choice.
  230. ** Generating newsletter summaries
  231. You can generate a newsletter-style summary of recently added articles. This command uses an LLM to analyze articles, extract topics, aggregate them into themes, and create narrative summaries organized by topic.
  232. #+BEGIN_SRC sh
  233. litdb summary -s "1 week" -o newsletter.org
  234. #+END_SRC
  235. The default time period is "1 week", but you can specify different periods using natural language:
  236. #+BEGIN_SRC sh
  237. litdb summary -s "2 weeks"
  238. litdb summary -s "1 month"
  239. litdb summary -s "3 days"
  240. #+END_SRC
  241. You can specify which LLM model to use (defaults to the model in your ~litdb.toml~ config):
  242. #+BEGIN_SRC sh
  243. litdb summary -s "1 week" --model "gpt-4o"
  244. litdb summary -s "2 weeks" --model "anthropic/claude-3-5-sonnet-20241022"
  245. #+END_SRC
  246. If you omit the ~-o~ option, the summary is written to a file with an auto-generated name based on the date range.
  247. The output is an org-mode formatted newsletter with:
  248. 1. Main topic sections (5-10 automatically identified themes)
  249. 2. Subtopic subsections with narrative summaries
  250. 3. Numbered references within the narrative text
  251. 4. Bibliography of articles for each subtopic
  252. This command works best with articles that have abstracts. It only processes entries classified as articles (journal articles, reviews, preprints, etc.), skipping other entry types like books or datasets.
  253. The process:
  254. 1. Fetches articles added since the specified date
  255. 2. Extracts 3-5 topics from each article using an LLM
  256. 3. Aggregates all topics into 5-10 main themes with subtopics
  257. 4. Classifies each article into the most relevant topic/subtopic
  258. 5. Generates narrative summaries for each subtopic, referencing the articles
  259. 6. Formats everything as an org-mode document
  260. ** Searching litdb
  261. There are several search options.
  262. *** vector search
  263. The main way litdb was designed to be searched is with by natural language queries. The way this works is your query is converted to a vector using SentenceTransformers, and then a vector search identifies entries in the database that are similar to your query.
  264. #+BEGIN_SRC sh
  265. litdb vsearch "natural language query"
  266. #+END_SRC
  267. The default number of entries returned is 3. You can change that with an optional argument
  268. #+BEGIN_SRC sh
  269. litdb vsearch "natural language query" -n 5
  270. #+END_SRC
  271. There is an iterative version of vsearch called isearch. This finds the closest entries, then downloads the citations, references and related entries for each one, and repeats the query until you tell it to stop, or it doesn't find any new results.
  272. #+BEGIN_SRC sh
  273. litdb isearch "some query"
  274. #+END_SRC
  275. *** full text search
  276. There is a full text search (full on the text in litdb) available. The command looks like this.
  277. #+BEGIN_SRC sh
  278. litdb fulltext "query"
  279. #+END_SRC
  280. See https://sqlite.org/fts5.html for information on what the query might look like. The search is done with this SQL command:
  281. #+BEGIN_SRC sql
  282. select source, text from fulltext where text match ? order by rank
  283. #+END_SRC
  284. The default number of entries returned is 3. You can change that with an optional argument
  285. #+BEGIN_SRC sh
  286. litdb fulltext "natural language query" -n 5
  287. #+END_SRC
  288. *** hybrid search
  289. Vector and full text search have complementary strengths and weaknesses. We combine them in the hybrid-search subcommand. This performs two searches on two different queries, and combines them with a unified score that is used to rank all the matches. This ensures you get some results that match the full search, and the vector search. It is worth trying if you aren't finding what you want by vector or text search alone.
  290. #+BEGIN_SRC sh
  291. litdb hybrid-search "vector query" "text query"
  292. #+END_SRC
  293. *** ollama GPT
  294. You can use litdb as a RAG source for ollama. This looks up the three most related papers to your query, and uses them as context in a prompt to ollama (with the llama2 model). I find this quite slow (it can be minutes to generate a response on an old Intel Mac). I also find it makes up things like references, and that it is usually necessary to actually read the three papers. The three papers come from the same vector search described above.
  295. #+BEGIN_SRC sh
  296. litdb gpt "what is the state of the art in automated laboratories for soft materials"
  297. #+END_SRC
  298. *** Integration with litellm
  299. litdb supports litellm so you can use almost any LLM provider you want: OpenAI, Anthropic, Gemini, whatever you have an API key for.
  300. The free tier of the API includes 1,500 requests per day with Gemini 1.5 Flash.
  301. It uses a different command than the ollama gpt command.
  302. #+BEGIN_SRC sh
  303. litdb chat "what is the state of the art in automated laboratories for soft materials"
  304. #+END_SRC
  305. There are some fancy things you can do with the prompt:
  306. 1. Avoid using RAG if --norag is in your prompt.
  307. 2. If you surround python objects with backticks, it will try expanding that to the documentation from Python.
  308. 3. A line that starts with < indicates a shell command to run and the output will be expanded into the prompt.
  309. 4. A prompt of !save will save the current chat to a file.
  310. 5. You can use this syntax to expand a file or url in the prompt for context:
  311. #+BEGIN_EXAMPLE
  312. [[file/url]]
  313. #+END_EXAMPLE
  314. Your prompt history is saved in your litdb, so you can go back to them if you want.
  315. *** Web app for litdb
  316. If you prefer a browser, you can now launch a streamlit app for litdb:
  317. #+BEGIN_SRC sh
  318. litdb app
  319. #+END_SRC
  320. This should launch the app in your browser and you can search litdb from it. The terminal application is more advanced in terms of prompt expansion.
  321. *** search with audio
  322. This command will record audio, transcribe that audio to text, and then do a vector search on that text. You will be prompted when the recording starts, and you press return to stop it. litdb will show you what it heard, and ask if you want to do a vector search on it.
  323. #+BEGIN_SRC sh
  324. litdb audio -p
  325. #+END_SRC
  326. I haven't found the transcription to be that good on technical scientific terms. This is a proof of concept capability.
  327. Note that you need to install these libraries for this feature to work:
  328. pyaudio, SpeechRecognition
  329. These are not trivial to install, and pyaudio relies on external libraries like portaudio that may not be easy to install. These are currently commented out in pyproject.toml because of these difficulties.
  330. *** search from a screenshot
  331. You can copy a screenshot to the clipboard, and then use OCR to extract text from it, and do a vector search on that text.
  332. #+BEGIN_SRC sh
  333. litdb screenshot
  334. #+END_SRC
  335. If you can copy and paste text, you should do that instead. This is helpful to get text from images, or pdfs where the text is stored in an image, maybe from videos, or screen share from online meetings, etc.
  336. Eventually, if images get integrated into litdb, this is also an entry point for image searches.
  337. ** Tagging entries
  338. litdb supports tagging entries so you can group them. To tag a source with tag1 and tag2, use this syntax.
  339. #+BEGIN_SRC sh
  340. litdb add-tag source -t tag1 -t tag2
  341. #+END_SRC
  342. You can remove tags like this.
  343. #+BEGIN_SRC sh
  344. litdb rm-tag source -t tag1 -t tag2
  345. #+END_SRC
  346. You can delete a tag from the database.
  347. #+BEGIN_SRC sh
  348. litdb delete-tag tag1
  349. #+END_SRC
  350. To see all the tags do this.
  351. #+BEGIN_SRC sh
  352. litdb list-tags
  353. #+END_SRC
  354. To see entries with a tag:
  355. #+BEGIN_SRC sh
  356. litdb show-tag tag1
  357. #+END_SRC
  358. You can use this to export tagged entries into bibtex entries like this.
  359. #+BEGIN_SRC sh
  360. litdb show-tag workflow -f '{{ source }}' | litdb bibtex
  361. #+END_SRC
  362. ** Exporting entries
  363. You can use these commands to export bibtex entries or citation strings.
  364. *** Get a bibtex entry
  365. This command will try to generate a bibtex entry for entries in your litdb.
  366. #+BEGIN_SRC sh
  367. litdb bibtex doi1 doi2
  368. #+END_SRC
  369. The output can be redirected to a file.
  370. You can also use a search like this and pipe the output to litdb bibtex.
  371. #+BEGIN_SRC sh
  372. litdb vsearch "machine learning in catalysis
  373. " -f "{{ source }}" | litdb bibtex
  374. #+END_SRC
  375. *** Get a citation string
  376. This command will output a citation for the sources. It is mostly a convenience function. There is not currently a way to customize the citation.
  377. #+BEGIN_SRC sh
  378. litdb citation doi1 doi2
  379. #+END_SRC
  380. You can also use a search like this and pipe the output to litdb bibtex.
  381. #+BEGIN_SRC sh
  382. litdb vsearch "machine learning in catalysis
  383. " -f "{{ source }}" | litdb citations
  384. #+END_SRC
  385. ** Find free pdfs
  386. You can use litdb to find freely available PDFs via https://unpaywall.org/.
  387. #+BEGIN_SRC sh
  388. litdb unpaywall doi
  389. #+END_SRC
  390. These do not always work, and sometimes you get a version from arxiv or pubmed.
  391. ** Low-level interaction with litdb
  392. litdb is just a sqlite database (although you need to use the libsql executable for vector search). There is a CLI way to run a sql command. For example, to find all entries with a null bibtex field and their types use a query like this.
  393. #+BEGIN_SRC sh
  394. litdb sql "select source, json_extract(extra, '$.type'), json_extract(extra, '$.bibtex') as bt from sources where bt is null"
  395. #+END_SRC
  396. You might also use this for very specific queries. For example, here I search the citation strings for my name.
  397. #+BEGIN_SRC sh
  398. litdb sql "select source, json_extract(extra, '$.citation') as citation from sources where citation like '%kitchin%'"
  399. #+END_SRC
  400. ** Deep research
  401. Deep research is one of the newer ideas in LLMs. It is a combination of web and other searches to find relevant information, coupled with an LLM to synthesize that information into a textual response. Litdb supports deep research with your database using [[https://docs.gptr.dev/][gpt-researcher]] with this command:
  402. #+BEGIN_SRC sh
  403. litdb research "some query"
  404. #+END_SRC
  405. litdb will generate some documents from your database from your query, and use this in a research task with gpt_researcher. This takes longer than a simple chat, but is often much richer in detail, and summarizes across documents.
  406. The default setup is to use a local ollama model, with arxiv as a search tool. You will get better results most likely if you use a cloud LLM. To use these you can add this new section to litdb.toml:
  407. #+BEGIN_SRC text
  408. [gpt-researcher]
  409. FAST_LLM = "google_genai:gemini-2.0-flash"
  410. SMART_LLM = "google_genai:gemini-2.0-flash"
  411. STRATEGIC_LLM = "google_genai:gemini-2.0-flash"
  412. EMBEDDING = "google_genai:models/text-embedding-004"
  413. #+END_SRC
  414. See https://docs.gptr.dev/docs/gpt-researcher/llms/llms for other configurations.
  415. The default search engine in litdb for deep research is DuckDuckGo and arxiv. If you setup these API keys you can also use pubmed (https://www.ncbi.nlm.nih.gov/account/), google (https://developers.google.com/custom-search/v1/overview), and [[https://app.tavily.com/home][Tavily]] for search.
  416. #+BEGIN_SRC sh
  417. export NCBI_API_KEY=
  418. export GOOGLE_CX_KEY=
  419. export TAVILY_API_KEY=
  420. #+END_SRC
  421. I have not tried the other retrievers at https://github.com/assafelovic/gpt-researcher/tree/master/gpt_researcher/retrievers.
  422. You can do research on local documents with this command:
  423. #+BEGIN_SRC sh
  424. litdb research "some query" --doc-path=/path/to/documents
  425. #+END_SRC
  426. It is not currently possible to use litdb do research with and use a local directory full of documents at the same time.
  427. The default is to print the report to stdout. To write to a file instead use:
  428. #+BEGIN_SRC sh
  429. litdb research "some query" -o report.md
  430. #+END_SRC
  431. You specify other output formats, anything pandoc can convert to. However, I found pdf a challenge for pypandoc, and use md2pdf for that instead. On Mac, if you see errors related to gobject, you probably have do run something like this to fix it.
  432. #+BEGIN_SRC sh
  433. brew list pango gobject-introspection
  434. export DYLD_LIBRARY_PATH=$(brew --prefix)/lib:$DYLD_LIBRARY_PATH
  435. #+END_SRC
  436. ** Extracting tables from PDFs
  437. You can extract tables from PDF files using the ~extract~ command. This uses computer vision and machine learning to identify and extract tables.
  438. #+BEGIN_SRC sh
  439. litdb extract paper.pdf
  440. #+END_SRC
  441. This will extract all tables from the PDF. To extract specific tables (using 1-based indexing):
  442. #+BEGIN_SRC sh
  443. litdb extract paper.pdf -t 1 -t 3
  444. #+END_SRC
  445. This extracts only tables 1 and 3. You can specify an output format with the ~-f~ option:
  446. #+BEGIN_SRC sh
  447. litdb extract paper.pdf -t 1 -f markdown
  448. #+END_SRC
  449. The extracted tables are returned as pandas DataFrames, which can be formatted in various ways.
  450. ** Extracting structured data with schemas
  451. You can extract structured information from documents (PDFs, web pages, etc.) using the ~schema~ command. This uses an LLM to parse the document and extract data according to a schema you define.
  452. *** Using the schema DSL
  453. The schema command supports a simple domain-specific language (DSL) for defining schemas:
  454. #+BEGIN_SRC sh
  455. litdb schema paper.pdf "title:str, authors:list, year:int, doi?:str"
  456. #+END_SRC
  457. Schema DSL syntax:
  458. - ~fieldName:type~ - Required field with type
  459. - ~fieldName?:type~ - Optional field (can be None)
  460. - ~fieldName:type=defaultValue~ - Field with default value
  461. - ~fieldName?:type=defaultValue~ - Optional field with default
  462. Supported types: ~str~, ~int~, ~float~, ~bool~, ~list~, ~dict~
  463. Examples:
  464. #+BEGIN_SRC sh
  465. # Extract basic paper metadata
  466. litdb schema paper.pdf "title:str, authors:list, year:int"
  467. # Extract with optional DOI and default value for journal
  468. litdb schema paper.pdf "title:str, doi?:str, journal:str=Unknown"
  469. # Extract experimental data
  470. litdb schema data.pdf "temperature:float, pressure:float, yield:float, catalyst:str"
  471. #+END_SRC
  472. *** Using JSON schemas
  473. You can also provide a schema as a JSON object:
  474. #+BEGIN_SRC sh
  475. litdb schema paper.pdf '{"title": ["str", None], "year": ["int", 2024]}'
  476. #+END_SRC
  477. The schema command first converts the document to markdown using Docling, then uses an LLM with structured output to extract the requested fields. The LLM model used is configured in the ~[llm]~ section of your ~litdb.toml~ file.
  478. ** Using litdb with AI agents (skill and MCP server)
  479. litdb comes with two things for AI coding agents such as Claude Code, VS Code (GitHub Copilot), Cursor, Codex, OpenCode and Gemini CLI:
  480. - An *agent skill* ([[./skills/litdb/SKILL.md][skills/litdb/SKILL.md]]) that teaches the agent how to use the litdb CLI: adding papers, searching, filters, tags, exporting BibTeX, and so on.
  481. - An *MCP server* (~litdb_mcp~) that gives the agent direct, read-only tools for your database: ~vsearch~, ~fulltext_search~, ~find_similar~, ~openalex~, ~get_source_details~, ~get_citation~, ~get_bibtex~, ~list_tags~, ~get_tagged_articles~ and ~generate_nsf_coa~.
  482. The easiest way to install both is [[https://github.com/jkitchin/knowhow][knowhow]], which needs nothing installed besides [[https://github.com/astral-sh/uv][uv]]. The skill follows the [[https://agentskills.io/specification][Agent Skills specification]], so it also works with ~npx skills~.
  483. *** Install the skill
  484. #+BEGIN_SRC sh
  485. # See what litdb offers
  486. uvx knowhow add jkitchin/litdb --list
  487. # Install the skill in the current project
  488. uvx knowhow add jkitchin/litdb --skill litdb
  489. # or for your user, in every project
  490. uvx knowhow add jkitchin/litdb --skill litdb -g
  491. #+END_SRC
  492. The skill is copied to ~.agents/skills/litdb~ (read by VS Code, Codex, OpenCode, Gemini CLI, Cursor and Copilot) and linked into ~.claude/skills/litdb~ for Claude Code. Then ask your agent things like "add the references of 10.1021/jp047349j to my litdb" or "make a bibtex file of everything tagged thesis".
  493. Keep it up to date with ~uvx knowhow check~ and ~uvx knowhow upgrade~, and remove it with ~uvx knowhow remove litdb~.
  494. If you work from a clone of this repository, ~litdb install claude-skill~ also copies the skill to ~~/.claude/skills/litdb~.
  495. *** Install the MCP server
  496. The MCP server runs the ~litdb_mcp~ command, so first make sure it is on your PATH (~uv tool install litdb~ does this). The server is defined in [[./mcp/litdb.json][mcp/litdb.json]], and knowhow translates it into each agent's config format:
  497. #+BEGIN_SRC sh
  498. # Claude Code, in this project (writes .mcp.json)
  499. uvx knowhow add jkitchin/litdb --mcp litdb -a claude-code
  500. # Claude Code for all your projects
  501. uvx knowhow add jkitchin/litdb --mcp litdb -a claude-code -g
  502. # Several agents at once
  503. uvx knowhow add jkitchin/litdb --mcp litdb -a claude-code -a vscode -a cursor -a codex
  504. #+END_SRC
  505. knowhow shows you the server config and asks for confirmation before installing it (add ~-y~ to skip the prompt).
  506. The server needs to know which database to use. It looks for:
  507. 1. the ~litdb~ environment variable, the path to a ~litdb.libsql~ file;
  508. 2. a ~litdb.toml~ in the agent's working directory or one of its parents;
  509. 3. the ~LITDB_ROOT~ environment variable, the directory that contains ~litdb.toml~.
  510. The installed config passes ~LITDB_ROOT~ through from your environment, so set it in your shell profile before starting the agent:
  511. #+BEGIN_SRC sh
  512. export LITDB_ROOT=~/litdb # the directory with litdb.toml and litdb.libsql
  513. #+END_SRC
  514. To check it works in Claude Code, run ~/mcp~ and look for ~litdb~, or ask "what is in my litdb about alloy segregation?". Remove the server with ~uvx knowhow remove --mcp litdb~.
  515. If you prefer to configure an agent by hand, this is the config (Claude Code ~.mcp.json~ format):
  516. #+BEGIN_SRC json
  517. {
  518. "mcpServers": {
  519. "litdb": {
  520. "command": "litdb_mcp",
  521. "env": {"LITDB_ROOT": "/path/to/your/litdb"}
  522. }
  523. }
  524. }
  525. #+END_SRC
  526. or with the Claude Code CLI:
  527. #+BEGIN_SRC sh
  528. claude mcp add litdb --scope user -e LITDB_ROOT=/path/to/your/litdb -- litdb_mcp
  529. #+END_SRC
  530. *** Claude Desktop
  531. Claude Desktop is not supported by knowhow. Instead, run this from your litdb directory (the one with ~litdb.toml~), or pass ~--db /path/to/litdb.libsql~:
  532. #+BEGIN_SRC sh
  533. litdb install mcp-server
  534. #+END_SRC
  535. Then restart Claude Desktop. Now you can use prompts like "Search my litdb for references on alloy segregation" or "Search OpenAlex for articles on alloy segregation." Uninstall it with ~litdb install uninstall-mcp~.
  536. * Adding local files
  537. The idea of using local files is that it is likely you have collected information in the form of files on your hard drive, and you want to be able to find information in those files.
  538. It is possible to add any file that can be turned into text to litdb. That includes:
  539. - pdf
  540. - docx
  541. - pptx
  542. - html
  543. - ipynb
  544. - org / md
  545. - bib
  546. - url
  547. This limits portability because you need a path if you want to be able to open that file.
  548. The same vector, fulltext and gpt search commands are available for local file entries. These tend to be longer documents than the OpenAlex entries, and I am not sure how well the search works at the document level embeddings. Search at a chunk level is very precise; odds are you want paragraph level similarity to your query.
  549. An early version of litdb stored each chunk. This is possible, but I used another table for it. You could munge the source to be something like f.pdf::chunk-1 so each one is unique, but that seems more complicated and you would need to do some experiments to see if it is warranted.
  550. You can combine this with the OpenAlex entries in a single database.
  551. You can walk a directory and add files from it with this command.
  552. #+BEGIN_SRC sh
  553. litdb index dir1
  554. #+END_SRC
  555. This directory is saved and you can update all the previously indexed directories like this.
  556. #+BEGIN_SRC sh
  557. litdb reindex
  558. #+END_SRC
  559. Some annoying things that may happen are duplicate content, e.g. because you have the same file in multiple formats like docx and pdf, or because you have literal copies of files in multiple places.
  560. You should also be careful sharing a litdb that has indexed local files. It may have sensitive information that you don't want others to be able to find.
  561. * Emacs integration
  562. Of course there is some Emacs integration. I made a new link for litdb.
  563. [[litdb:https://doi.org/10.1021/jp047349j]]
  564. The links export as \cite{source}, and there is a function ~litdb-generate-bibtex~ to export bibtex entries for all links in the buffer. These entries are not certain to be valid, most likely from the keys (some DOIs are probably invalid keys).
  565. You can easily insert a link like this:
  566. M-x litdb
  567. See [[./litdb.el]] for details. This is not a package on MELPA yet. You should just load the .el file in your config. You can also use ~litdb-fulltext~, ~litdb-vsearch~, and ~litdb-gpt~ from Emacs to interact with your litdb.
  568. litdb.el is under active development, and will be an alternative UI to the terminal eventually. It is too early to tell if it will replace org-ref. It has potential, but that would be a very large undertaking.
  569. * Database design
  570. litdb uses a sqlite database with libsql. libsql is a sqlite fork with additional capabilities, most notably integrated vector search.
  571. The main table in litdb is called sources.
  572. - sources
  573. - source (url to source location)
  574. - text (the text for the source)
  575. - extra (json data)
  576. - embedding (float32 blob in bytes)
  577. - date_added string
  578. This table has an embedding_idx index for vector search.
  579. There is also a virtual table fulltext for fulltext search.
  580. - fulltext
  581. - source
  582. - text
  583. And a table called queries.
  584. - queries
  585. - filter
  586. - description
  587. - last_updated
  588. This database is automatically created when you use litdb.
  589. * Limitations
  590. The text that is stored for each entry comes from OpenAlex and is typically limited to the title and abstract. For the text in each entry The first line is typically a citation including the title, and the rest is the abstract if there is one. I feel like I see more and more entries with no abstract. This will certainly limit the quality of search, and could bias results towards entries with more text in them.
  591. The quality of the vector search depends on several things. First, litdb stores a document level embedding vector that is computed by averaging the embedding vectors of overlapping chunks. We use Sentence Transformers to compute these. There are many choices to make on the model, and these have not been tested exhaustively. So far 'all-MiniLM-L6-v2' works well enough. There are other models you could consider like getting embeddings from ollama, but at the moment litdb can only use SentenceTransformers.
  592. I guess that document level embeddings are less effective on longer documents. The title+abstract from OpenAlex is pretty short, and so far there isn't evidence this is a problem.
  593. Second, we rely on defaults in libsql for the vector search, notably finding the top k nearest vectors based on cosine similarity. There are other distance metrics you could use like L2, but we have not considered these.
  594. The query is based on vector similarity between your query and the texts. So, you should write the query so it looks like what you want to find, rather than as a question. It is less clear how you should structure your query if you are using the GPT capability. It is more natural to ask a question, or give instructions. The RAG is still done by similarity though.
  595. Finally, the search can only find things that are in your database. If you haven't added it there, you won't find it. That definitely means you will miss some papers. I try to use a mesh of approaches to cover the most likely papers. This includes:
  596. 1. Follow authors
  597. 2. add references, related, and citing papers to the most relevant papers.
  598. 3. Use text search filters
  599. 4. Add papers I find from X, bluesky, LinkedIn, etc. (and their references, related, etc)
  600. 5. If read a paper in litdb that is good, add its references, related, etc.
  601. It is an iterative process, and you have to make a judgment call about when to stop it. You can always come back later. There might even be newer papers to find.
  602. ** Local file limitations
  603. Similar limitations exist for local files. There are additionally the following known limitations:
  604. 1. The quality of document to text influences the ultimate embedding. This varies by type of document, and the library used to convert it.
  605. 2. Local files tend to be longer documents and this can lead to hundreds of text chunks per document. These chunk embeddings are averaged into one embedding. It is not obvious this is as effective as vector search on each chunk, but it is more memory efficient.
  606. For PDF to text we use [[https://pymupdf.readthedocs.io/en/latest/pymupdf4llm/][pymupd4fll]] which works for this proof of concept. There is a Pro version of that package which supports more file formats. It is not obvious what it would cost to use that. I used [[https://ds4sd.github.io/docling/][docling]] in an early prototype. It also worked pretty well, but it was a little slower I think, and would occasionally segfault so I stopped using it. Spacy is integrating PDF to structured data using docling (https://explosion.ai/blog/pdfs-nlp-structured-data). There is plenty of room for improvement in this dimension, with trade offs in performance and accuracy.
  607. There is a new package from Microsoft to convert Office files to Markdown (https://github.com/microsoft/markitdown) that they specifically mention using in the context of LLMs.
  608. The embedding model we use is trained on text. It is probably not as good at finding code, and the gpt we use is also probably not good at generating code. I guess you would need another table in the database for code, and a different model for embedding and generation. This only matters if you index jupyter notebooks (and later if other code files are supported).
  609. ** sqlite + sqlite-vec vs libsql
  610. Vector search is the core requirement for litdb. There are many ways to achieve this. I only considered local solutions so the options are:
  611. - sqlite + vectorlite (https://github.com/1yefuwang1/vectorlite)
  612. - sqlite + sqlite-vec (https://github.com/asg017/sqlite-vec)
  613. - libsql https://github.com/tursodatabase/libsql
  614. vectorlite aims to be faster than sqlite-vec, but it relies on hnsw for vector search, and I was uncomfortable figuring out how to set the size of the db for this application.
  615. sqlite-vec is nice, and early versions of litdb used it and its precursor. This approach requires a virtual table for the embeddings. This is installed as an extension, and is still considered in early stages of adoption.
  616. libsql is a fork of sqlite with integrated vector search, and potential for using it as a cloud database. It is supported by a company, with freemium cloud services. In libsql you store the vectors in a regular table, and search on an embedding index. The code is on GitHUB, and can also be used locally.
  617. * Roadmap
  618. These are ideas for future expansion.
  619. ** PDFs and notes
  620. I am not sure what the best way to do this is. The records in litdb are stored by the source, often a url, or path. The PDFs would be stored outside the database, and we would need some way to link them. The keys aren't suitable for naming, but maybe a hash of the keys would be suitable. This would add a fuller opportunity to search larger, local documents too. In org-ref, I only had one pdf per entry. I guess here I would have a new table, so you could have multiple documents linked to an entry, although it won't be easy to tell what they are from the hash-based filenames.
  621. Notes on the other hand, might be small enough that they could be stored in the database. Then they would be easily searchable. They could also be stored externally to make them easy to edit. I haven't found the notes feature in org-ref that helpful, and usually I take notes in various places. What I should do is add a search to find the litdb links in your org-files. This is already a feature of org-db.
  622. ** Jupyter lab integration
  623. An alternative to the CLI and Emacs would be to run this in Jupyter Lab with magic commands and rich output.
  624. ** graph visualization
  625. It might be helpful to have a graph representation of a paper that shows nodes of citing, references, and related papers, with edge length related to a similarity score, and node size related to number of citations.
  626. ResearchRabbit and Litmaps do this pretty well.
  627. ** ollama and agents
  628. There might be a way to get better results using agents and / or tools. For example, you might have a tool that can lookup new articles on OpenAlex, or augment with google search somehow. Or there might be some iterative prompt building tool that refines the search for related articles based on output results.
  629. Here are some references for when I get back to this.
  630. - https://github.com/ollama/ollama-python
  631. - https://github.com/MikeyBeez/Ollama_Agents
  632. - https://github.com/premthomas/Ollama-and-Agents
  633. - https://medium.com/@lifanov.a.v/integrating-langgraph-with-ollama-for-advanced-llm-applications-d6c10262dafa
  634. - https://medium.com/@abhilasha.sinha/building-a-crew-of-agents-with-open-source-llm-using-ollama-to-analyze-fund-documents-as-multi-page-756d8fd9fbf0
  635. - https://blog.paperspace.com/building-local-ai-agents-a-guide-to-langgraph-ai-agents-and-ollama/
  636. I don't use llamaindex (maybe I should see what it does), but it has this section on agents https://docs.llamaindex.ai/en/stable/understanding/agent/
  637. ** web app / fast-api
  638. It might be nice to have a flask app with an API. This would facilitate interaction with Emacs.
  639. ** async operations
  640. Almost everything is done synchronously and it blocks the program. At least some things could be done asynchronously I think, and that might speed things up (especially for local files), or at least let you do other things while it happens.
  641. The only thing to be careful about is not exceeding rate limits to OpenAlex. This is handled in the synchronous code.
  642. ** application specific encoders
  643. I use a generic embedding model, and there are others that are better suited for specific tasks. For example:
  644. - MatBERT [[cite:&trewartha-2022-quant-advan]]
  645. - Scibert [[cite:&beltagy-2019-sciber]]
  646. - Matscibert [[cite:&gupta-2022-matsc]]
  647. - Specter cite:&cohan-2020-spect https://www.sbert.net/docs/sentence_transformer/pretrained_models.html#scientific-similarity-models
  648. - PaECTER [[cite:&ghosh-2024-paect]] for patents
  649. These might have a variety of uses with litdb that range from extracting data, named entity recognition, specific searches on materials, etc.
  650. It is not essential to use SentenceTransformers for embedding, they are just easy to use. An alternative is something like ollama embeddings (https://ollama.com/blog/embedding-models) or llama.cpp https://github.com/abetlen/llama-cpp-python?tab=readme-ov-file#embeddings. The main reason to use on of these would be performance, and maybe better integration with a chat llm.
  651. It is not that easy to just switch models; you would need to either add new columns and compute embeddings for everything, or update all the embeddings for a new model. The SPECTER embedding is much bigger than the all-MiniLM-L6-v2 embedding.
  652. #+BEGIN_SRC jupyter-python :restart
  653. from sentence_transformers import SentenceTransformer
  654. m = SentenceTransformer('allenai-specter')
  655. print(m.encode(['test']).shape)
  656. #+END_SRC
  657. #+RESULTS:
  658. : (1, 768)
  659. ** merge databases
  660. I have setup litdb to be project based. There may come a time when it is desirable to merge some set of databases. It might not be necessary, I think you can attach databases in sqlite (https://www.sqlitetutorial.net/sqlite-attach-database/) to achieve basically the same effect. litdb doesn't store version info at the moment, so it could be tricky to ensure compatibility.
  661. Still it might be interesting to sync two databases, e.g. https://www.sqlite.org/rsync.html. I don't know if this works with libsql, but it might allow there to be a central db that users pull from.
  662. ** remote db
  663. The first version of litdb with libsql used a fully remote db on their cloud. The main benefit of that is you can update the db from another machine, keeping your working machine load low. A secondary benefit would be using the db from different machines more easily. Right now I use Dropbox to sync it; that mostly works but I get some conflict files here and there if I change it on one machine while it is open on another machine. It is a little more complex to set up though, and I got several api errors on long running scripts, and with network issues, so I switched to this local setup. I think you could specify this in the litdb.toml file and have it do the right thing on a project basis.
  664. ** image and text models
  665. One day it might be possible to include images in this (https://www.sbert.net/docs/sentence_transformer/pretrained_models.html#image-text-models). At the moment, OpenAlex entries do not have any images, but other web resources and local files could. I have an image database in org-db, but I don't use it a lot.
  666. ** DONE combine full text and vector search
  667. CLOSED: [2024-12-09 Mon 13:59]
  668. Vector search might miss some things. Full text search is hard to do with meaning. There are several ways to do a hybrid search, e.g. do a full text search on keywords, and a vector search, and use some kind of union on those results.
  669. https://www.meilisearch.com/blog/full-text-search-vs-vector-search
  670. ** DONE tag system
  671. CLOSED: [2024-12-09 Mon 13:58]
  672. It could be useful to have a tag system where you could label entries, or they could be auto-tagged when updating filters. This would allow you to tag entries by a project, or select entries for some kind of bulk action like update, export to bibtex, or delete.
  673. You might also build a scoring system, e.g. for like/dislike tags.
  674. #+BEGIN_SRC sh
  675. litdb tag doi -t "tag1" "tag2" # add tag
  676. litdb tab doi -r "tag" "tag2" # rm tags
  677. #+END_SRC
  678. ** DONE Integrate with audio input
  679. CLOSED: [2024-12-05 Thu 09:11]
  680. This would use your microphone to record and transcribe a query for search.
  681. ** DONE Integrate with screenshot + OCR
  682. CLOSED: [2024-12-05 Thu 09:11]
  683. Do the search from the results. I did this with tesseract (https://pypi.org/project/pytesseract/)
  684. #+BEGIN_SRC jupyter-python
  685. import pyautogui
  686. # Prompt the user to move the mouse to the first corner and press Enter
  687. input("Move the mouse to the first corner and press Enter...")
  688. x1, y1 = pyautogui.position()
  689. # Prompt the user to move the mouse to the opposite corner and press Enter
  690. input("Move the mouse to the opposite corner and press Enter...")
  691. x2, y2 = pyautogui.position()
  692. # Calculate the region
  693. left = min(x1, x2)
  694. top = min(y1, y2)
  695. width = abs(x2 - x1)
  696. height = abs(y2 - y1)
  697. region = (left, top, width, height)
  698. print(f"Selected region: {region}")
  699. #+END_SRC
  700. #+RESULTS:
  701. : Selected region: (26, 332, 473, 69)
  702. #+BEGIN_SRC jupyter-python
  703. import pyscreeze
  704. im = pyscreeze.screenshot(region=(left, top, width, height))
  705. im.save('screenshot.png')
  706. #+END_SRC
  707. #+RESULTS:
  708. see mss also.
  709. #+BEGIN_SRC jupyter-python
  710. from PIL import Image
  711. import pytesseract
  712. # Open an image file
  713. img = Image.open('screenshot.png')
  714. # Use Tesseract to extract text
  715. text = pytesseract.image_to_string(img)
  716. # Print the extracted text
  717. print(text)
  718. #+END_SRC
  719. #+RESULTS:
  720. : ++RESULTS:
  721. : ; Selected region: (26, 332, 473, 69)
  722. :
  723. This might be nice later when we have image embeddings.
  724. ** DONE review process
  725. #+BEGIN_SRC sh
  726. litdb review --since '1 week ago'
  727. #+END_SRC
  728. You need to have a way to review what comes in to litdb; it is part of learning about what is current. I currently do this with Emacs and scimax-org-feed. You could integrate review with update-filters, or by entries added in the past few days, or some other kind of query. Then you just need to add some format information to get what you want, e.g. org, maybe html?
  729. #+BEGIN_SRC sqlite :db example/litdb.libsql
  730. select source, date_added from sources where date(date_added) > '2024-11-28' limit 5
  731. #+END_SRC
  732. #+RESULTS:
  733. | https://doi.org/10.1021/jp047349j | 2024-11-29 17:21:51 |
  734. | https://doi.org/10.1149/1.1856988 | 2024-11-29 17:21:52 |
  735. | https://doi.org/10.1002/cctc.201000397 | 2024-11-29 17:21:53 |
  736. | https://doi.org/10.1088/1361-648x/aa680e | 2024-11-29 17:21:53 |
  737. | https://doi.org/10.1103/physrevlett.93.156801 | 2024-11-29 17:21:54 |
  738. ** DONE semantic similarity
  739. CLOSED: [2024-12-04 Wed 13:12]
  740. litdb uses cosine similarity as the distance metric for the nearest neighbors. It might be useful to re-rank these with cross-encoding.
  741. https://www.sbert.net/examples/applications/cross-encoder/README.html
  742. * Related projects
  743. - LitSuggest :: https://www.ncbi.nlm.nih.gov/research/litsuggest/
  744. - Browser tool that suggests literature for you based on positive and negative PMIDs. Hosted by NIH.
  745. - paper-qa :: https://github.com/Future-House/paper-qa
  746. - This project by Andrew White uses LLM+RAG to explore a paper.
  747. - ColBERT :: https://github.com/stanford-futuredata/ColBERT
  748. - ColBERT is a fast retrieval model for large text collections. In theory it can probably be integrated with litdb. litdb is so simple, and works well enough so far without it.
  749. Many of these projects require you to make an account. There are freemium levels in each one.
  750. - ResearchRabbit :: https://www.researchrabbit.ai/
  751. - This is a browser tool to navigate the scientific literature graphically. You can make collections, and papers that are related by citations are shown in a graph
  752. - LitMaps :: https://www.litmaps.com/
  753. - Another browser tool to graphically interact with scientific literature
  754. - Keenious :: https://keenious.com/explore
  755. - Browser / Google Docs and Word plugin. Finds related articles to the text in your document. I like Keenious when in Google Docs.
  756. - scite.ai :: https://scite.ai/
  757. - Browser tool that integrates GPT with the scientific literature, integration with Zotero
  758. - Scopus AI :: https://www.scopus.com/search/form.uri?display=basic#scopus-ai
  759. - Sponsored by Elsevier
  760. - Dimensions AI :: https://app.dimensions.ai/discover/publication
  761. - Seems similar to Scopus AI
  762. - khoj :: https://khoj.dev/
  763. - This is a desktop app that can be totally local, or in the cloud. It can index your files, and then you can chat with them. There is a freemium level.
  764. - AnythingLLM :: https://anythingllm.com/
  765. - Another tool that runs LLMs locally, and says it can index your files so you can chat with them.
  766. - gpt4all :: https://www.nomic.ai/gpt4all
  767. - Another tool that runs LLMs locally, and says it can index your files so you can chat with them.
  768. With all these options, why does litdb exist? There are a lot of answers to that. First, I wanted to make it. I learned a lot about vector search by doing it. Second, I wanted a free, extensible solution for literature search that could also work for my local files while never putting data in the cloud, and that would work in Emacs. The projects above are very nice, easy to use, no or low-code solutions, and if that is what you are looking for, look there! If you want to hack on things yourself, look here.

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.