Zero Labs
Industry News / AI

The Hidden Treasure in Your Factory: (How to rescue “Dark Data” without investing thousands with…

Source · Towards AI By Sergio Bajo Navarro

From the publisher’s feed, collected in the ZeroLabs newsroom.

The Hidden Treasure in Your Factory: (How to rescue “Dark Data” without investing thousands with local AI)Image created by GPT 5.6 luna.Manufacturing plants live in a constant duality. On one hand, they operate with latest state-of-the-art equipment seamlessly integrated into IoT ecosystems; on the other, they rely on very robust legacy machinery that has been running for years. However, this machinery remains isolated from the rest of the company’s systems.When improvement, automation, or monitoring plans are designed, these veteran machines are often left out of the budget. Why? Usually, because upgrading their proprietary software through the original manufacturer is expensive and can cost thousands of dollars. However, despite their low technological visibility, their impact on production remains incredibly high.These machines constantly generate reports and data. Understanding the trends and drifts of this data is highly useful for quality control, production, and maintenance tasks.The “Dark Data” ProblemTechnology consultancies refer to this as “Dark Data”. It is estimated that between 60% and 73% of enterprise data is never analyzed or is so unstructured that it provides no value. A 2020 IDC survey of 1,500 business leaders stated that 68% of available enterprise data goes unutilized (1).Reliable sources such as Seagate, Forrester, or Forbes have spoken openly on the subject, and numerous companies offer solutions that are technologically advanced and reliable, but also expensive to implement.All this data remains on local servers or gets trapped in PDF reports that nobody has the time to structure and study.These reports contain critical information for maintenance, production and quality teams:Average batch values: Critical for tracking product quality over time.Working parameters: Trends indicating component wear and tear.Processing times, alarms, and stops: Fundamental for calculating real productivity.The Challenge of Connectivity and StructuringVeteran equipment runs on reliable software inside its closed environment. However, the cost of updating the software and connectivity with the rest of the plant’s tools, together with the hours of downtime that it implies, means that it remains isolated.If you’re lucky, your proprietary software will allow you to export (or read) data to a CSV file before printing the PDF report, allowing a Python script to process the data at almost no cost.Unfortunately, the standard output is a PDF report that gets reviewed by production and quality teams, before being archived in a folder. These PDFs contain the fundamental data about product quality, working variables, alarms, and process times.Depending on the batch duration, the number of alarms, or operator modifications, the structure of these PDFs varies wildly. Extracting reliable data from them using traditional software (like standard OCR) is a nightmare. A slightly shifted table, an unexpected page break, different text length, or an unforeseen value will change the format and generate extraction problems.The result is known: thousands of reports stored on local servers and computers. Companies do not usually have the resources to save and analize all this data manually.The Solution: Local Artificial IntelligenceGenerative AI has changed the rules of the industrial game and provides the “low-cost” solution. A Python script backed by an open-source Large Language Model (LLM) can run 100% locally and privately on a standard computer, recovering all data and exporting it to an updated Excel sheet daily.The AI can understands the technical context. It can differentiate between values measured in the same units, understand abbreviations, and avoid confusing concepts.Fig. 1: Examples of fictional unstructured reports. Some of the challenges posed to the extraction system are highlighted.How It Works Under the Hood (The Python Implementation)To prove this isn’t just theory, I generated 20 fake, unstructured PDF reports featuring different layouts, abbreviations, semantic traps (like confusing “compression pressure” with “pre-compression pressure”), and mixed units. All with the intention of confusing the AI and generating the worst-case scenario (fig. 1).I built a Python script that uses Llama 3.1 (8B) running entirely locally via Ollama, meaning no factory data ever leaves the plant. All PDF reports should be exported to a folder or computer outside the equipment to prevent failures that affect production. Here are the four technical pillars that make this extraction possible:Connecting to the Local AI. Instead of paying for cloud APIs, I decide to use the standard OpenAI Python library to connect to our local Ollama server, avoiding costs and exposing our data to the cloud. Ollama can run without GPU, if you use lightweight models, running perfectly on a standard CPU. All tests were run in a standard personal computer (my own laptop).from openai import OpenAI# Pointing to the local Ollama instanceclient = OpenAI( api_key="local", base_url="http://localhost:11434/v1" )2. Extracting text while preserving spatial relationship. Traditional PDF extractors scramble columns of text. Tests performed with pypdf2 work very well on reports that contain only text, but they generate extraction problems if the reports contain tables. Using pdfplumber with the layout=True parameter provides the solution. It preserves the physical spacing of the document, ensuring the AI can understand the structure of the report.import pdfplumberdef extract_text_pdf(route_to_your_pdf): text = "" with pdfplumber.open(route_to_your_pdf) as pdf: for page in pdf.pages: # layout=True is key: it respects spacing between columns text_page = page.extract_text(layout=True) if text_page: text += text_page + "\n" return text3. Forcing Strict JSON Output from the LLM. We need to avoid any kind of hallucination or made-up data. We don’t want a chat with an AI. We need the raw structured data as is found in the source. By setting the temperature=0.0 (eliminating hallucination) we reduce fabricated data data, and forcing a json_object response format, helps ensure the result follows the required structure.import jsondef process_text_with_ai(text): prompt = f""" Read the following pharmaceutical tablet compression report and extract: - Batch - Start Date / Time - End Date / Time -Etc Return ONLY a valid JSON object with these exact keys. If data is missing, output "Not found". Text: {text[:4000]} """ response = client.chat.completions.create( model="llama3.1", messages=[{"role": "user", "content": prompt}], response_format={ "type": "json_object" }, temperature=0.0 # Low temperature for precision ) return json.loads(respuesta.choices[0].message.content)4. Very Clear prompt to avoid errors. The model provides the information we ask for, just it is found in the reports. For example, it might return the same value but in a different format (250000 vs 250.000) or sometimes include a units, which can cause problems when writing the data to a file. Defining every detail in the prompt after testing is the only way to ensure a perfect output.prompt = f""" Read the following pharmaceutical tablet compression report and extract: ….. - Average weight (numeric value in mg, no units) - Compression pressure (numeric value in kN, no units) - Conforming units (format: 1958600) - Alarms (literal text) Return ONLY a valid JSON object with these exact keys. If data is missing, output "Not found". Text: {texto[:4000]}The Results: Revealing the Dark DataThe script processed the 20 unstructured PDFs with a 99.6% recovery rate. The 0.4% failure occurred when I intentionally omitted an end date, forcing the AI to estimate it. The recovery rate of the data inside the reports was 100% (fig. 2).Fig. 2: ‘Raw’ data from the 20 fictional reports exported to Excel (Headers in Spanish from local test). 100% of the data contained in the reports was retrieved. The value in green does not appear in the report and was incorrectly inferred by the AI. The alarm list is complete, although the Excel spread sheet’s output format does not make this apparent.By automating this reading process and generating structured formats (like Excel or SQL) (fig.3), factories instantly unlock three pillars of Industry 4.0 with virtually zero (or very little) hardware investment:Real OEE Visibility: Extracting exact batch durations, real machine speeds and stops, and conforming units directly from the reports eliminates the bias of manual data entry. OEE can be analyzed at the end of the bath or day on machines that usually don’t have real-time OEE. Making it a metric instead of an estimation.Long-Term Quality Control: Monitoring the trend of critical values across hundreds of batches reveals long-term trend deviations and prevents process drift.Data-Driven Preventive Maintenance: The real treasure lies in the trend of working parameters. A slight increase in motor workload or pressure reveals component wear, allowing maintenance teams to intervene before a catastrophic stop in production.Fig. 3: Structured data in an Excel spreadsheet for the 20 process reports. (Headers in Spanish from local test). Calculation of batch averages, parameters, and OEE based on process time and the number of conforming units. The positive and negative trends in the charts are due to deliberately generated data used to test the system.Digitizing and extracting plant data does not always require replacing heavy machinery or high software and hardware update budgets. Sometimes, true innovation consists of using cutting-edge technology to finally listen to what our oldest machines have been trying to tell us in PDF format for years.What Should Be the Next Step?I asked myself what should be the next phase to improve this idea.Firstly, automation: creating a script to automatically update the PDF reading of a file.Secondly, I was thinking about using AI to generate a brief report of the extracted data, saving time on the everyday task of studying the data. I was on a break talking about the topic of Dark Data, when somebody said, “If nobody has time to recover the data, nobody will have time to study it.” As I heard that, it was clear that I had a new goal: the complete automation of the extraction, including an AI in charge of generating a brief report about the data.Automation:Most factory equipment runs on Windows. To create the automation process on Windows, we need to create a .bat file to automatically run our .py file.Because it is necessary to run the Ollama server first on Windows, you have to include the instructions in the .bat file. Waiting a few seconds for it to fully load into RAM is necessary, and closing Ollama later avoids a waste of computer resources.@echo offecho Starting Ollama Server...start /b ollama serveecho Waiting to load AI...timeout /t 5 /nobreak > nulpython "C:\path\to\your_file.py" :: Run your Python file hereecho Closing Ollama...taskkill /F /IM ollama.exe /T > nulecho task endLater, you have to open the Task Scheduler from the Start menu. There, you can click “Create Basic Task”, name it as you wish, and choose “Daily” at your preferred time. In the “Action” step, select “Start a program” and point to your .bat file. Done.To avoid processing the same files every day, the processed reports should be tracked in some way. I use a .txt file to store their names. Inside our .py file, we should include a function to check if the report has already been processed.for file in stored_pdfs: if file not in processed_files: # Process the fileReporting the Data After ExtractionBefore generating a report that summarizes the data, we need to pass it to our AI for analysis. But the data we write to Excel and keep in our program’s “memory” is raw data. In my original idea, the means, sums, and other calculations were done by the Excel file. However, the Excel file does not perform any calculations if it is not open.It is possible to run these files without a graphical interface, but depending on the program you use on your computer (Microsoft Office, LibreOffice, OpenOffice) to open the .xlsx file, the instructions are very different. This makes it difficult to use the same script or method on different computers, complicating the deployment. I decided to do the math with Python as well, using the Numpy library.I created a statistics.py file to handle the calculations. This file takes the raw data extracted by our Llama 3.1 stored in our .xlsx file's raw data sheet. It calculates the values that we will need (averages, means, OEE, others). Once it is done, it is sent back to our .xlsx file.# sending data to the .xlsx file exampletry: wb = openpyxl.load_workbook(excel_file) ws = wb["Statistical_Summary"] # Map values to specific cells # Row 2: Total batches (B2) ws["B2"] = total_batches ws["C2"] = len(latest_10) # Row 3: Theoretical weight # Row 4: Average weight (mg) ws["B4"] = round(historical["weight"], 2) ws["C4"] = round(recent["weight"], 2)No matter which program you choose to check your data, it will be avalaible there. Excel, or similar tool, can create charts and organize the data in a way that’s easy to understand. The file also sends a summary to our AI model, which uses it to generate the report.# Return a text summary for DeepSeek to processsummary_for_ai = f”””Comparison (historical: {total_batches} batches vs. the latest 10 batches):- Average weight (mg): Historical={historical[‘weight’]:.2f} | Latest 10={recent[‘weight’]:.2f}- Time loss (%): Historical={historical[‘time_loss’]:.2f} | Latest 10={recent[‘time_loss’]:.2f}- Overall OEE: Historical={historical[‘oee’]:.2f}% | Latest 10={recent[‘oee’]:.2f}%“””return summary_for_ai To generate the report, I decided to use a more “capable” model in reasoning: deepseek-r1:8b. We could use the same model for data extraction and report generation, but, honestly, I wanted to test switching between models on my computer for future projects.We need generation, but the temperature must be low I use temperature=0.3. I added the new model and prompt to my .py script as a new function:try: response = client.chat.completions.create( model="deepseek-r1:8b", messages=[{"role": "user", "content": prompt}], temperature=0.3 )except Exception as e: print(f"Error generating report: {e}")The report will have only four points with trends and OEE compared with the historical data. One minute of reading time leaves no excuse for not knowing your data. The report is printed in the terminal as part of the execution, but it is stored as a .txt file to be read later. I decided not to create a new .txt report every day and store hundreds of reports again, because the data is already stored and can be managed inside the Excel file. When there is a new report, it overwrites the last one.Fig. 4: Final report generated by Deepseek-r1 as show in the .txt report.Final ThoughtsAI technology is evolving very quickly. Today, it is possible to use agents to analyze different types of reports and data, prepare the data as you need, create a presentation, and email you a summary. In this case, I want to show that simple, cheap, and tested solutions can help — or be enough — in many cases, without a big investment of time and money. It may not be a perfect solution, but I hope you find it useful.Disclosure: I use AI in my everyday work. In this case, Gemini 3 and GPT 5 models helped me correct typos, create the first image, and debug my code. However, I write, develop and test my ideas by myself. I also use other software tools, like Google or LibreOffice. Finally I would like to thank to everyone who contributes to improving these technologies without expecting anything in return.Bibliography1, https://www.seagate.com/ca/en/stories/articles/seagates-rethink-data-report-reveals-that-68-percent-of-data-available-to-businesses-goes-unleveraged-pr-master/The Hidden Treasure in Your Factory: (How to rescue “Dark Data” without investing thousands with… was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.