Skip to content

Repository files navigation

Qwenki

Upload a PDF or image, get an Anki deck. Pages go through GLM-OCR for markdown extraction, Qwen turns the markdown into flashcards, you review and edit them in a Streamlit UI, then export a .apkg.

Qwenki flashcard interface

How it works

upload → GLM-OCR (per page) → markdown → Qwen → JSON cards → edit → .apkg

Both models run locally via vLLM; the Streamlit app talks to them over OpenAI-compatible HTTP endpoints.

Setup

1. Python environment (conda)

conda create -n qwenki python=3.12 -y
conda activate qwenki
pip install -r requirements.txt

2. Host the models (Docker + vLLM)

Requires an NVIDIA GPU with the container toolkit installed. Models are pulled on first start and cached under ~/.cache/huggingface.

cd hosting
docker compose up -d

This starts two services:

Service Port Model
qwen_llm 8002 cyankiwi/Qwen3.5-4B-AWQ-4bit
glm_ocr 8003 zai-org/GLM-OCR

Tail logs while warmup happens (first run downloads weights):

docker compose logs -f

3. Run the app

From the repo root:

streamlit run app.py

Open the URL Streamlit prints. If your vLLM containers run on a different host or port, adjust the endpoints in the sidebar under Settings → Endpoints (or set OCR_BASE_URL / LLM_BASE_URL).

Using it

  1. Drop one or more PDFs / images into the uploader.
  2. Pick a generation mode in the sidebar:
    • Single call: one LLM request, best coherence, slower on long docs.
    • Parallel per page: concurrent requests, faster, card count is approximate.
  3. Hit Extract & generate, review the cards, edit as needed.
  4. Build .apkgDownload .apkg → import in Anki.

Project layout

app.py              Streamlit UI
pipeline.py         OCR + card generation (sync + parallel)
anki_export.py      genanki → .apkg
system_prompt.txt   editable prompt for the card author
hosting/            Docker Compose + Dockerfiles for the vLLM servers

Roadmap

  • Initial Release
  • [] Model Customization
  • [] ARM Support

Acknowledgements

This project is made possible thanks to the following incredible open-source models and tools. Please note that while the core logic and integration of this tool are licensed under the PolyForm Noncommercial 1.0.0 license, the underlying models remain under their respective licenses.

  • GLM-OCR: Developed by Z.ai (Zhipu AI). Used for high-precision, multimodal document layout analysis and text extraction.

  • Qwen3.5-4B-AWQ-4bit: The base model was developed by Alibaba Cloud (Qwen team), with this specific 4-bit AWQ quantized version provided by cyankiwi for efficient local inference.

About

Upload a PDF or image, get an Anki deck. Locally, on your own system.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages