Skip to main content

Automatically annotates research PDFs with citations and abbreviation expansions.

Project description

glosser

Automatically annotate research PDFs with citation titles and abbreviation expansions, right in the margins.

PyPI Python License: MIT


🤔 What is Glosser?

Ever read a dense research paper and had to constantly flip to the references section just to see what [17] is? Or wondered what LSTM stands for on page 8?

Glosser solves this. It reads your PDF, identifies every citation marker (like [1], [2], …) and every uppercase abbreviation, then writes their full titles and expansions directly into the page margins, producing a new, self-contained PDF you can read without jumping around.

Before → After

Without Glosser With Glosser
...as shown in [14]... ...as shown in [14]... ← margin: "Attention Is All You Need (2017)"
...using the BERT model... ...using the BERT model... ← margin: "Bidirectional Encoder Representations from Transformers"

✨ Features

  • 📄 Citation Annotations: Extracts titles and years from the references section using LLM and writes them next to each [n] marker in the margins.
  • 🔤 Abbreviation Expansion: Finds uppercase abbreviations (3–5 chars), looks up their full forms via RAG + LLM, and annotates them in the margins.
  • 🎨 Color-Coded: Green for context-extracted definitions, red for LLM-inferred ones, so you know the confidence level at a glance.
  • 🔑 API Key Saved Locally: Enter your Groq API key once; it's stored at ~/.glosser_config for future runs.

🚀 Installation

pip install -q glosser

Note: The -q flag keeps the install output clean. Glosser has ML dependencies (PyTorch, Transformers, FAISS) so the first install may take a few minutes.

Requirements


📖 Usage

CLI (recommended)

Simply run:

glosser

As a Python Library

import asyncio
from glosser.main import annotate

async def main():
    out_path, count = await annotate(
        path="paper.pdf",
        GROQ_API_KEY="gsk_...",
        scaling=1.2,               # margin width multiplier (default: 1.2)
        find_references=True,      # annotate [n] citations
        find_abbreviation=True,    # annotate abbreviations
    )
    print(f"Saved {count} annotations to {out_path}")

asyncio.run(main())

⚙️ How It Works

PDF Input
   │
   ├─ 1. Scale pages horizontally to create side margins
   │
   ├─ 2. Extract references section → LLM extracts title + year for each [n]
   │
   ├─ 3. Find all [n] markers in body text → write citation info in nearest margin
   │
   ├─ 4. Find all uppercase abbreviations (≥2 occurrences)
   │
   ├─ 5. RAG pipeline: chunk PDF → embed with MiniLM → FAISS similarity search
   │     └─ LLM resolves full form from retrieved context
   │
   └─ 6. Write abbreviation expansions in margins → save new PDF

Tech stack: PyMuPDF · LangChain · Groq (Kimi K2) · HuggingFace Embeddings (MiniLM-L6-v2) · FAISS


🛠️ Configuration

Option Default Description
scaling 1.2 How much to widen pages for margins (1.0 = no extra margin)
find_references True Annotate [n] citation markers
find_abbreviation True Annotate uppercase abbreviations

Your Groq API key is stored locally at ~/.glosser_config after the first run.
To reset it, simply delete that file.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

glosser-0.0.3.tar.gz (14.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

glosser-0.0.3-py3-none-any.whl (16.5 kB view details)

Uploaded Python 3

File details

Details for the file glosser-0.0.3.tar.gz.

File metadata

  • Download URL: glosser-0.0.3.tar.gz
  • Upload date:
  • Size: 14.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for glosser-0.0.3.tar.gz
Algorithm Hash digest
SHA256 e446935daedbb9afc0f8d976b037df9343e18459249776cee6d9f87c6a4a08b2
MD5 83129d6e87677d1a0cac5aee04b627bb
BLAKE2b-256 1ab8dde9270f7b0359136f76b97caeb55a1db038d08f25ada53f2b9287b22dcd

See more details on using hashes here.

File details

Details for the file glosser-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: glosser-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 16.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for glosser-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 26f21a8999c4440deb6faf2e3e473b7ee96ab60d1867985eec295a74b682fd69
MD5 a521622490fef1168b2f8da269faac31
BLAKE2b-256 db294d209f7a6dce9d90d8aaf33c34be1e7fb08930191cc0014557fcb3d1a6a4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page