Google opens Magika for faster file type recognition
Neutral Open Source By What The Future Newsroom · February 18, 2024 · 3 min read

Google opens Magika for faster file type recognition

Google is open-sourcing Magika, an AI system built to recognize binary and text-based file types quickly and accurately. The tool uses a 1MB deep learning model, identifies files in milliseconds, and is available as a Python library and standalone command-line tool.

Google is making Magika available as an open-source tool for file type recognition, aiming to give software a faster and more accurate way to understand what kind of file it is handling. The system is designed for both binary and text-based file types, and Google says it can identify files in milliseconds.

“Magika is a practical open-source file recognition tool with little clear societal risk or dependency impact.”Why it scores Neutral

Why file type recognition is hard

Recognizing a file type may sound simple, but the source material makes clear that it is a difficult problem. File formats can have very different structures, and that diversity creates room for errors when tools try to classify them reliably.

Traditional tools such as libmagic approach the task through hand-crafted heuristics and user-defined rules. That method can work, but it also depends on rules being written, maintained, and applied correctly. Google’s argument for Magika is that this rule-heavy approach can be time-consuming and error-prone.

That matters because file type recognition often sits at the start of a larger workflow. Before a file can be sent to the right scanner, policy check, or detection system, software needs to know what it is. A mistaken identification can send a file down the wrong path or reduce the reliability of systems that depend on accurate classification.

How Magika changes the approach

Magika uses an AI-based model instead of relying only on manually designed rules. According to Google, it was built with a large training dataset and a custom deep learning model that is only 1MB in size.

The small model size is important because the tool is meant to be practical, not just accurate in theory. Google says Magika can identify files in milliseconds, which points to a system designed for high-volume use as well as everyday inspection.

In Google’s framing, the main value is reliability at scale. Magika is presented as a way to improve file detection accuracy across large collections of files, while still remaining fast enough for real workflows.

Benchmark results and internal use

Google says Magika outperformed existing tools by 20 percent in a benchmark of one million files. The source also notes that the results were even better for text files.

Those details are central to the case for Magika. The project is not only described as a new open-source release, but as a tool that has already been measured against existing options across a large benchmark.

Google also says it uses Magika internally to route Gmail, Drive, and Safe Browsing files to the correct security and content policy scanners. That internal use gives a clear example of where file type recognition fits into larger systems: it helps direct files toward the correct downstream checks.

The same logic applies to other software that needs to decide what kind of file it is dealing with before taking action. The source does not describe every possible use case, but it does state that the open-source release is intended to help other software improve file detection accuracy and support researchers working on large-scale detection.

Open source access and VirusTotal plans

Magika is available on Github under the Apache2 license. Users can try a web demo, install it as a Python library, or run it as a standalone command-line tool.

The source also gives a direct installation path through the pypi package manager using the pip install magika command. That makes the tool accessible to users who want to test it locally or integrate it into Python-based workflows.

Google’s open-source approach is also tied to broader detection work. The source says an upcoming integration with VirusTotal is expected to improve that platform’s efficiency and accuracy in detecting malicious code.

That planned integration is a notable signal for Magika’s role. File type recognition is not the same thing as malicious code detection, but accurate classification can support systems that need to decide how a file should be analyzed. By improving the first step, Magika could make later scanning and policy decisions more efficient and reliable.

What to watch next

For now, Magika’s key claims are speed, accuracy, and openness. It is a 1MB AI-based model, built for binary and text-based file type recognition, with performance measured against existing tools in a benchmark of one million files.

The open-source release means the tool can be tried outside Google’s own systems. Its availability as both a Python library and standalone command-line tool also gives users more than one way to adopt it.

The bigger question is how widely Magika will be used by other software and research workflows. Based on the source, Google’s goal is straightforward: improve file type recognition accuracy at scale and provide a reliable tool that others can build into their own detection pipelines.

← Back to the wire

Read next