跳到正文
DEV Community· Anush Deotare·· 3 小時前AI 評分50

Sloth Sorter 用 Gemma 3:4B 和 Ollama 協助整理雜亂文件

Sloth Sorter: A Local AI That Organizes Your Messy Folders, Slowly (Gemma 3 + Ollama)

AI 導讀

作者 Anush Deotare 開發 Sloth Sorter,這款本地桌面網頁應用透過 Ollama 執行 Gemma 3:4B,為每個檔案建議新檔名及分類資料夾,用戶預覽並按 Apply 後,檔案才會移動。

正文

This is a submission for the Hacktoberfest Open-Source AI Challenge Week 3: Slow and Steady

What I Built

Everyone has that folder. Mine is full of Screenshot 2026-10-21 at 3.12.png, final_final_v2.docx and IMG_4821.jpg, and I have been "going to sort it" for months.

Sloth Sorter is a local web app that does the sorting for me. I point it at a messy folder, and a local AI model looks at each file and works out what it actually is. It then proposes a clean name and a category folder, so final_final_v2.docx becomes nexus-labs-design-agreement in Documents, and that Slack screenshot goes to Screenshots.

It works at a sloth's pace on purpose. Files are processed one at a time with a small pause between them, so it never hogs my laptop's GPU, and nothing moves until I review the preview and click Apply. Every run is logged, so one click undoes it.

It saves the chore I keep avoiding, and the people it suits are anyone whose Downloads folder has become a lifestyle.

Demo

Code

🦥 Sloth Sorter

"Does the chore so you don't have to. Slowly."

Sloth Sorter is an offline desktop web application that organizes messy folders using local multimodal AI (Gemma 3:4B running via Ollama). By processing files sequentially, one by one, with a gentle pacing delay, it brings order to chaotic downloads, desktops, and project dumps without bogging down your machine—designed specifically to run comfortably on everyday laptops with zero data ever leaving your device.

Sloth Sorter Demo


💻 Tested On

  • Hardware: NVIDIA GeForce RTX 3050 Laptop GPU (4GB VRAM), 16GB RAM
  • Operating System: Windows 11
  • Model: gemma3:4b running locally via Ollama
  • Python Requirement: Python 3.9+

📊 Measured Benchmark Results

These numbers are taken directly from actual benchmark runs on the repository's 26-file test set (sample_mess):

  • Dataset: 26 files (PDFs, DOCX documents, code scripts, screenshots, receipts, notes, and photos)
  • Fallbacks: 0 fallbacks (0.0%)…

How I Built It

The open-source pieces

  • Gemma 3 4B (open-weight, multimodal) runs locally through Ollama. It reads screenshots and photos directly and reads the text of PDFs, DOCX and code files.
  • FastAPI backend streams progress to a vanilla JS front end over Server-Sent Events, so file cards appear one by one as the model finishes each file.
  • Pillow, pypdf and python-docx handle extraction. Images are shrunk to 640px and documents are trimmed to about 800 characters, which keeps the model fast and inside the 4GB of VRAM on my RTX 3050 laptop.

Making a small model behave

A 4B model won't give you clean output on its own, so the model proposes and the code checks:

  • Ollama's JSON-schema output constrains the reply (the category must be one of my nine, confidence must be low, med or high), so it can't ramble or break the format.
  • A date verifier strips any date from a proposed name that doesn't appear in the file's content or original filename.
  • A few deterministic category rules apply, such as .sql, .py and .js always going to Code, and screenshots going to Screenshots.
  • Confidence is calibrated, so memes, avatars and corrected results show up as low or medium and get an amber highlight in the UI for a second look.

Where it went wrong first

My first benchmark on 26 messy sample files had 10 fallbacks. Five were a plain environment bug: the server ran on a different Python than the one I'd installed packages into, so PDFs and DOCX files never reached the model. I added a dependency check to the health endpoint so a missing library can't fail silently again. Constraining the output and trimming the prompt cleared the rest.

Next, I read the actual model outputs and found five unrelated files named with 2024-10-27. The date from one of my prompt examples was leaking into the answers. The fix was removing the dates from the examples, telling the model never to guess a date, and adding the verifier above.

First pass After fixes
Fallbacks (26 files) 10 0
Avg time per file 11.7 s under 5 s
Category agreement 69.2% 96.2% (25/26)
Invented dates 5 files 0

Be careful with that 96.2%. I labeled the 26 test files myself and tuned the rules against them, so it describes my test set and isn't a general accuracy claim. The one miss was a quarterly financial report that Gemma filed under Receipts-Bills. The first file also takes about 23 seconds while the model loads, and after that it settles at about 4 to 5 seconds each. The repo has a tiny eval script so you can rerun all of this yourself.

Why Does Open Innovation Matter?

Look at what ends up in a Downloads folder: bank statements, tax PDFs, ID scans, one-time codes, private chats. A tool that sorts those files has to read all of them, and I don't want that going to someone else's server.

With an open-weight model, the files never leave the machine. That also made a few other things possible:

  • It works with no internet. It sorts files on a train just as well as at home.
  • It costs nothing after setup. There's no per-token bill for a chore that runs on every file, and no rate limit.
  • The model is swappable. Set one environment variable (SLOTH_MODEL) and it runs a different Ollama model.
  • I could control the output. Running the model myself let me use schema-constrained decoding and tune the context window and keep-alive for a 4GB GPU.

I didn't benchmark a cloud model, so I won't claim it would be less accurate. The win here is what a local, open model makes possible: private, offline, and free to run forever.

Prize Categories

Best Use of Gemma: Sloth Sorter runs gemma3:4b locally through Ollama and uses its multimodal side to read screenshots and photos, all on a 4GB laptop GPU.

來源:DEV Community · dev.to