Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LitExtract

LitExtract is a desktop application for AI-assisted systematic literature review extraction. It automates the most time-consuming parts of a systematic review: screening papers for relevance, extracting structured data from PDFs according to a custom schema, and compiling results into an Excel spreadsheet and a LaTeX report. The schema is designed collaboratively with an LLM based on your research question and a sample of your papers, so the extracted fields are always tailored to your study rather than a generic template.

The entire pipeline runs locally. LitExtract communicates with a model running in LM Studio over its OpenAI-compatible API, so no data leaves your machine. The GUI is built with ttkbootstrap and all LLM calls, PDF parsing, and Excel operations run in background threads so the interface stays responsive throughout long extractions.


Prerequisites

  • Python 3.10 or later
  • LM Studio (https://lmstudio.ai) with at least one model loaded and the local server running (default port 1234)
  • A folder of PDF papers to review

Installation

git clone https://github.com/your-username/litextract
cd litextract
pip install -r requirements.txt
python main.py

First-Run Walkthrough

1. New Project

On first launch the project picker opens immediately. Click New Project and complete the three-step wizard:

  • Step 1 – Research Context: Enter a project name, your research question, and optional domain notes (e.g., "RCTs only", "paediatric population"). Be specific — the LLM uses this text to design the schema.
  • Step 2 – LM Studio Setup: Enter the server URL, click Connect & Load Models, choose a model, and set the context window. Click Test Connection to confirm the model responds.
  • Step 3 – Add PDFs: Click Add Files to select your PDF corpus. Files are copied into the project folder.

2. Design Schema

Switch to the Schema tab. Select 2–5 representative papers (diverse enough to cover all the fields you expect), then click Design Extraction Schema. The LLM reads the first 2 000 characters of each PDF and proposes a list of extraction fields complete with keys, labels, types, and descriptions.

Review the proposed fields in the editor:

  • Change field types (categorical, free_text, numeric, boolean)
  • Add allowed values for categorical fields (comma-separated)
  • Reorder fields with ↑/↓
  • Add or delete fields
  • Edit descriptions via the button

When satisfied, click Save Schema & Generate Excel Template. This writes the schema to disk and creates the extraction spreadsheet.

3. Screen PDFs

Go to the Queue tab. Select all pending papers and click Screen Selected Papers. The screener asks the LLM whether each paper is relevant to your research question and records a score and reason. Irrelevant papers are automatically de-selected (toggle off with the checkbox).

4. Extract

With relevant papers selected, click Extract Selected Papers. Progress is shown paper by paper. Each extracted paper is appended to the Excel file immediately. Use Pause after current or Stop if you need to interrupt.

5. Review

Switch to the Review tab to inspect results in the table. Double-click any row to open the paper detail dialog where you can edit individual field values, re-extract the whole paper, or re-extract specific fields only.

Use the filter buttons (Flagged, Missing Fields, Done) to focus on papers that need attention. Click Open Excel to open the spreadsheet directly.

6. Generate Report

Expand the Generate LaTeX Report panel at the bottom of the Review tab. Select which sections to include, choose a citation style, and click Generate Report. The output is a report.tex file and a references.bib file in the project folder.


Schema Design Tips

  • Be specific in your research question. "What interventions reduce hospital readmission in heart failure patients?" produces a more targeted schema than "What are the outcomes of heart failure treatment?".
  • Vary your sample PDFs. Pick papers that cover the range of study designs, populations, and interventions present in your corpus so the LLM proposes fields that apply broadly.
  • Prefer categorical over free_text for anything countable. Fields like "study design" work best as categorical with values ["RCT", "observational", "meta-analysis", "other"]. Free-text answers for categorical concepts are hard to analyse in Excel.
  • Use domain notes to constrain the schema. Notes like "all papers are clinical trials; no animal studies" or "outcome of interest is 30-day mortality" steer the LLM away from irrelevant fields.
  • Add a description to every field. The description is included in the LLM extraction prompt, so a precise description ("number of participants randomised, not including drop-outs") produces far better results than a blank description.

Recommended LM Studio Models

Model Context window Notes
Llama-3-8B-Instruct 8 192 Good balance of speed and quality; works well for most schemas
Mistral-7B-Instruct-v0.2 32 768 Longer context means fewer batches for long PDFs
Phi-3-medium-128k 128 000 Best quality for complex schemas; slower on CPU

Load the model in LM Studio, start the local server, then use Connect & Load Models in LitExtract to select it.


Context Window and Max Tokens Guide

LitExtract automatically splits each PDF into batches sized to fit the model context. The formula is:

max_paper_tokens = max(2000, int(context_window * 0.75) - 1000)
Context window Max paper tokens per batch
4 096 2 072
8 192 5 144
16 384 11 288
32 768 23 576
128 000 95 000

A larger context window means fewer batches per paper and faster extraction, but requires more VRAM. For most 8–16 page clinical papers an 8 192-token context is sufficient.


LaTeX Report

After generating a report you will find two files in your project folder:

  • report.tex — the main report with all sections
  • references.bib — BibTeX bibliography entries for the extracted papers

To compile to PDF:

  1. Overleaf (recommended): Upload both files to a new Overleaf project and click Compile.
  2. Local LaTeX: Run pdflatex report.tex twice (or use the included compile.bat if present).

The report includes an introduction summarising your research question, a methods section describing the extraction process and schema, a results section with a summary table of all extracted papers, a discussion, and a conclusion. All sections can be toggled on or off before generation.


Troubleshooting

Connection refused (LM Studio) Verify LM Studio is running and the server is started. The default URL is http://localhost:1234/v1. Check that no firewall is blocking port 1234. If you changed the port in LM Studio, update the URL in the Project tab.

Slow responses / timeouts Large models on CPU are slow. Use a smaller quantisation (Q4_K_M instead of Q8) or switch to a model with a smaller parameter count. Increase the LM Studio timeout in its settings if responses are being cut off.

Poor JSON / extraction results are empty Some models do not reliably follow JSON formatting instructions. Try:

  • A temperature of 0.0 or 0.05
  • A model specifically fine-tuned for instruction following (look for "Instruct" in the model name)
  • Shorter, simpler field descriptions

Back-fill failures If back-filling runs but fields remain empty, the model may have returned malformed output. Check the queue log for error messages. Re-run the back-fill with a lower temperature or different model.

LaTeX compile errors If pdflatex reports errors, the most common cause is special characters (%, &, #, _) in extracted text that were not escaped. Open report.tex in a text editor, search for the problematic line, and escape the character (e.g. \%). Future versions will sanitise output automatically.

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages