← Latest papers
💬 NLP

Benchmarking Local LLMs for Natural-Language-to-SQL Querying in Biopharmaceutical Manufacturing: An Empirical Benchmark on Consumer-Grade Hardware

This study demonstrates that locally deployed, code-tuned general-purpose LLMs (specifically Qwen 2.5 Coder 7B and Llama 3.1 8B) outperform domain-specific biomedical models in generating compliant SQL queries for biopharmaceutical manufacturing on consumer-grade hardware, though human oversight remains essential for regulated applications.

Original authors: Sagar Bhetwal, Rajan Bastakoti, Nirajan Acharya, Gaurav Kumar Gupta

Published 2026-06-02
📖 5 min read🧠 Deep dive

Original authors: Sagar Bhetwal, Rajan Bastakoti, Nirajan Acharya, Gaurav Kumar Gupta

Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer

Imagine a pharmaceutical factory as a massive, high-security library. Inside, there are millions of books (data) about how medicines are made, cleaned, and tested. Because of strict safety rules, no one is allowed to take these books out of the building or show them to outsiders.

For years, if a factory worker wanted to know, "How many batches of medicine were cleaned last Tuesday?" they had to fill out a paper request and wait days for a computer expert to find the answer.

This paper asks a simple question: Can we put a smart, local "robot librarian" inside the factory that understands plain English and can instantly find the answer in the books, without ever leaving the building?

Here is the story of their experiment, explained simply.

The Setup: The "Local Robot Librarian"

The researchers built a small, self-contained system on a standard laptop (the kind you might buy at a store, not a supercomputer). They installed four different "brain" models (AI models) on it. These brains were designed to listen to a question in English and write a computer command (SQL) to ask the database for the answer.

They tested these four brains on a fake (synthetic) library of 63,000 records about medicine making. The goal was to see which brain could translate human questions into correct computer commands best, while staying strictly inside the factory walls.

The Four Contestants

The researchers picked four different types of AI brains to race:

  1. Qwen 2.5 Coder: A brain specifically trained to be a programmer. It's like a librarian who has spent their whole life learning the library's cataloging system.
  2. Llama 3.1: A very smart, general-purpose brain. It's like a well-read scholar who knows a little bit about everything and has a huge memory.
  3. Mistral: Another general-purpose brain, but slightly smaller and older. Think of it as a quick-witted student who is good at simple tasks but gets confused by complex ones.
  4. Meditron: A brain specifically trained on medical textbooks and doctor's notes. The researchers hoped this would be the "expert doctor" who knows the language of medicine better than anyone.

The Race: How They Did

The researchers asked each brain 60 different questions, ranging from easy ("Show me the list of batches") to hard ("Show me the batches where the cleaning took longer than usual and the temperature was high").

Here is what happened:

  • The "Doctor" (Meditron) Failed Completely:
    Surprisingly, the brain trained specifically on medical data failed almost entirely. It couldn't even write the computer command.

    • Why? It turned out this brain had a very small "working memory" (context window). The list of library rules (the database schema) was too long to fit in its memory. It was like trying to read a novel while wearing a blindfold that only lets you see one word at a time. Even when the researchers shortened the rules so it could fit, the brain still couldn't write the right commands. It seems that training it on medical text actually made it forget how to speak "computer code."
  • The "Programmer" and the "Scholar" (Qwen and Llama) Won:
    The two best performers were the general-purpose scholar (Llama) and the programmer (Qwen).

    • Llama was slightly more reliable at following the rules. It wrote correct computer commands 93% of the time.
    • Qwen was slightly better at the actual wording of the commands, matching the style of the reference answers more closely.
    • The Catch: Even though they were the winners, they weren't perfect. They still made mistakes about 7–12% of the time.
  • The "Student" (Mistral) Got Confused:
    Mistral did okay on simple questions but failed miserably when the questions got complex (involving multiple tables). Its performance dropped from 40% on easy tasks to just 15% on hard ones. It couldn't handle the complexity of the factory's data structure.

The Big Lessons

1. "Specialist" Doesn't Always Mean "Better"
The researchers expected the medical-trained brain (Meditron) to win because the data was about medicine. Instead, the general-purpose brains won. It turns out that for this specific job (writing computer code), knowing medical facts didn't help; knowing how to write code did. In fact, the medical training seemed to have "diluted" the brain's ability to write code.

2. Memory Size Matters More Than You Think
The biggest reason the medical brain failed was that it ran out of memory. The list of database rules was too big for its small brain. This suggests that for complex factory data, you need a model with a large "working memory," even if it's not a medical expert.

3. You Still Need a Human in the Loop
Even the best brains (Llama and Qwen) made mistakes. They got the right answer about 90% of the time, but in a factory where mistakes can hurt patients, 90% isn't good enough to let the robot work alone.

  • The Verdict: These local AI tools are great for drafting the questions. A human must always check the draft before the computer runs it. Think of the AI as a very fast intern who writes the report, but the manager (the human) must sign off on it.

4. It Works on Regular Laptops
The most exciting part is that they did all this on a standard consumer laptop, not a massive supercomputer. This proves that factories don't need to spend millions on cloud servers to use AI. They can keep their data safe inside their own walls using a regular computer.

Summary

The paper shows that we can build a safe, local AI system for pharmaceutical factories that runs on regular laptops. However, the "medical expert" AI failed because it had a small memory and lost its coding skills. The best options were general-purpose AI models, but they still need a human to double-check their work before they are used for real decisions. It's a promising start, but the robot isn't ready to drive the car alone yet.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →