kenmandal commited on
Commit
1c7085b
Β·
verified Β·
1 Parent(s): d817494

Add blog post: Teaching small AI models to run the back office

Browse files
Files changed (1) hide show
  1. BLOG.md +116 -0
BLOG.md ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Teaching small AI models to run the back office
2
+
3
+ Earlier this season we took part in **Build Small**, a hackathon run by **Hugging Face** and
4
+ **Gradio**. The premise was refreshingly contrarian: don't reach for the biggest model you can
5
+ rent β€” build something genuinely useful on models small enough to run on hardware you already own.
6
+ That single rule changed how we thought about the whole project, and we came away convinced that
7
+ "small" is a feature, not a compromise.
8
+
9
+ Here's what we built, why it matters, and a few things we learned along the way that might be new
10
+ to you too.
11
+
12
+ ![The app, live on Hugging Face](https://huggingface.co/spaces/build-small-hackathon/ERP-DocIQ/resolve/main/blog/01-space.png)
13
+
14
+ ## The business problem
15
+
16
+ Walk into the back office of almost any retailer and you'll find two things in abundance:
17
+ paperwork, and people waiting on answers. Invoices, purchase orders, receipts and contracts
18
+ arrive as scans, photos and PDFs that someone has to read and key in by hand. And every time a
19
+ manager asks "why did our spending jump last quarter?" or "which suppliers keep paying us late?",
20
+ that question turns into a ticket for the analytics team and a wait of hours or days.
21
+
22
+ Most companies patch this with heavy automation suites. They work, but they are expensive to
23
+ license, they break the moment a vendor changes their invoice layout or a web page moves a button,
24
+ and they lock you into one company's way of doing things. The intelligence lives somewhere else,
25
+ on someone else's servers, behind someone else's bill.
26
+
27
+ We wanted to know: could a small, open model β€” one light enough to run on a single machine β€” do
28
+ this work instead?
29
+
30
+ ## The solution approach
31
+
32
+ We built an assistant for the retail back office that does three jobs, and we leaned on small
33
+ models for every one of them.
34
+
35
+ **It reads documents.** This was the first surprise. A modern *vision* model can look at a messy,
36
+ crumpled, rotated invoice the way a person does β€” not by guessing at fonts, but by actually
37
+ understanding the layout β€” and hand back clean, structured fields: vendor, dates, line items,
38
+ totals. The trick we'd encourage anyone to borrow is to *combine* two sources of truth. When a
39
+ document already carries a digital text layer, we use it directly because it's exact and free; when
40
+ it's a scan or a photo, the vision model reads the image. Fusing the two gives you the accuracy of
41
+ real text where it exists and the flexibility of a vision model where it doesn't. Classic optical
42
+ character recognition alone simply can't keep up with the messy real-world documents that pile up
43
+ in a back office.
44
+
45
+ ![A messy scanned invoice read into clean fields](https://huggingface.co/spaces/build-small-hackathon/ERP-DocIQ/resolve/main/blog/02-read-document.png)
46
+
47
+ **It answers questions in plain English.** This is the part we're proudest of, and the idea worth
48
+ taking away. Instead of building yet another dashboard, we let people just *ask* β€” "why did spend
49
+ rise last quarter?", "who are our top vendors?", "what's our late-payment situation?" The model
50
+ translates the question into a database query, runs that query against the real data, and then
51
+ explains the result in ordinary language. The important detail is the order of those steps: the
52
+ numbers come from the database, not from the model's imagination. Because the model only narrates
53
+ figures it was handed, it can't quietly make one up β€” a property that matters enormously the moment
54
+ you trust a system with real money. We also kept a plain, rule-based path that answers the common
55
+ questions even with no model running at all, so the assistant is dependable first and clever second.
56
+
57
+ ![Ask in plain English; the model writes a query and explains the real answer](https://huggingface.co/spaces/build-small-hackathon/ERP-DocIQ/resolve/main/blog/03-ask-erp.png)
58
+
59
+ **We taught a small model the language of the business.** Out of the box, a general model doesn't
60
+ know your vendors, your accounts, or how your team phrases a question. So we *fine-tuned* one β€” we
61
+ took a small open model and trained it further on examples drawn from this specific domain. Here's
62
+ the encouraging lesson: fine-tuning is no longer the preserve of giant labs with warehouses of
63
+ GPUs. Using a lightweight technique that only nudges a small slice of the model, we could adapt it
64
+ cheaply β€” and we built a version of the training that even runs on an ordinary laptop, so the
65
+ before-and-after improvement is something anyone can reproduce rather than take on faith.
66
+
67
+ **It automates the clicks, too.** For the tasks that still live in a browser, a small model drives
68
+ the page itself β€” reading what's on screen, deciding the next step, and acting β€” instead of
69
+ following a brittle, pre-recorded script that snaps the first time the layout shifts.
70
+
71
+ ### How we shipped it β€” Gradio and the open-AI toolkit
72
+
73
+ The whole thing is wrapped in a **Gradio** app, which is what made it shareable in an afternoon:
74
+ Gradio turned our Python functions into a clean, hosted interface with tabs, file uploads and a
75
+ chat box, with no front-end work. Behind it, **OpenBMB's MiniCPM** family is the workhorse β€” one
76
+ compact model handles the document reading *and* the reasoning, reached through a simple,
77
+ standard interface that means we could swap in a local server without rewriting a line. We drew on
78
+ **Cohere's** open models for language tasks, and used **Black Forest Labs'** image model in a neat
79
+ sideways way β€” to *generate* deliberately nasty test documents (warped photos, faxes) so we could
80
+ prove the reader holds up under pressure. Dependable open libraries did the plumbing: one for
81
+ pulling text out of PDFs, another for traditional character recognition as a fallback, and small,
82
+ honest building blocks for storage and search. Every model we used sits comfortably under the
83
+ hackathon's size limit.
84
+
85
+ ## The benefits
86
+
87
+ When the intelligence is small enough to run on your own hardware, three good things follow, and
88
+ none of them require a number to appreciate:
89
+
90
+ - **It stays yours.** Sensitive documents and financials never have to leave your own machines.
91
+ Privacy stops being a policy you hope for and becomes a property of where the software runs.
92
+ - **It costs less to operate and never locks you in.** There's no per-robot meter ticking, and
93
+ because everything is open and swappable, you can adopt a better model the week it ships instead
94
+ of waiting for a vendor's roadmap.
95
+ - **It changes at your pace.** A new document layout or a new kind of question is a quick
96
+ adjustment β€” often just more examples β€” not a support case with an outside company.
97
+ - **People get answers directly.** The folks closest to the work can ask their own questions and
98
+ trust the replies, because every answer is grounded in the real data.
99
+
100
+ The bigger lesson of Build Small is the one we didn't expect to feel so strongly: the frontier
101
+ isn't the only place real work gets done. A handful of small, open models β€” chosen carefully and
102
+ pointed at a concrete problem β€” can quietly run a back office, on a machine that fits under a desk.
103
+
104
+ ## Thanks
105
+
106
+ Our gratitude to the organizers, **Hugging Face** and **Gradio**, for running Build Small and for
107
+ making the case that smaller, local and open is a direction worth taking seriously β€” and to the
108
+ participating partners whose open models we leaned on, especially **OpenBMB**, **Cohere** and
109
+ **Black Forest Labs**.
110
+
111
+ ## Links & references
112
+ - **Live app (try it):** https://huggingface.co/spaces/build-small-hackathon/ERP-DocIQ
113
+ - **Project files & code on the Space:** https://huggingface.co/spaces/build-small-hackathon/ERP-DocIQ/tree/main
114
+ - **Demo video:** https://youtu.be/mWs7eRVH_GM
115
+ - **Source code (GitHub):** https://github.com/agency-world/Project-Aperture
116
+ - **The hackathon β€” Build Small field guide:** https://huggingface.co/spaces/build-small-hackathon/field-guide