Teaching Machines to Read Dates in File Names

Consistent file naming is a quiet productivity win. When teams can predict how a file will be named before they even open a folder, searching and sharing become faster and less error-prone. Dropbox's "naming conventions" feature is designed to enforce this consistency, automatically renaming files in specific folders according to user-set rules, such as including a keyword or a date.

A key part of this automated process is recognizing when an existing file name already contains a date so that the renaming logic can preserve or reformat it. This is trickier than it sounds. Dates appear in a dizzying variety of styles: MM/DD/YYYY, DD/MM/YYYY, or YYYY-MM-DD. They might be abbreviated (Jan for January), context-specific (FY2023 for fiscal year), or have no separators at all (survey20230601).

The team initially attempted a rule-based approach, but quickly ran into its limitations. Rules require prior knowledge of every possible user convention, and at Dropbox's scale, enumerating the full range of plausible formats is impractical. The rule-based system could not bend to the inconsistencies of how different people and systems name files. This led the team to build a machine learning model to identify date components directly from the file name text. Development began in early 2022, and a new ML-powered version of naming conventions rolled out to Dropbox users in August 2022.

Modeling Date Components

The first design decision was whether to treat a date as a single, holistic entity or to identify its component parts. Treating it as one entity simplifies the model—it only needs to spot one type of thing. But this holistic view limits flexibility. For the Dropbox feature, the downstream tasks often need to manipulate individual parts, like swapping out the month or extracting just the year. This granularity requirement pushed the team toward a segmented, component-level classification.

The problem was formulated as supervised multi-class classification, using a pipeline of modules: annotation, tokenization, encoding, and classification.

To create the training data, the team annotated a sample of file names from Dropbox employees, using the open-source tool Doccano to mark the positions of year, month, and day elements. Annotation, however, was an iterative process because manual tagging is expensive and faces coverage gaps. A file name like report_MM_DD_YYYY.txt might be missed entirely by human annotators, leaving the model blind to that format.

To resolve this, they built a synthetic data generation tool. Once a format gap was identified, a few examples were annotated manually, and the tool was used to generate a large batch of synthetic file names in that specific format. These synthetic files were then mixed with the human-annotated data to enrich coverage and reduce the risk of overfitting.

The team kept the total dataset to a few thousand samples, balancing annotation costs against returns. This frugality was enabled by transfer learning: by starting with a pre-trained model, fine-tuning on a smaller, curated dataset was sufficient to achieve strong performance.

Tokenization and IOB Labels

File names are not just dates—they are words, numbers, and punctuation thrown together. To make sense of the context around the date, the text needs tokenization. While word- and character-level splits have their trade-offs, the team chose a subword tokenizer. This approach offered the right balance, preserving digital-level granularity for the numeric date parts while capturing meaningful word or subword context for other parts of the name. They selected Google's SentencePiece tokenizer, which supports BPE and Unigram methods and treats each digit as a distinct token.

With tokens in hand, they applied Inside-Outside-Beginning (IOB) tagging to mark entity boundaries. Each token receives a tag: B-YEAR if it starts a year, I-YEAR if it's inside that year, and so on for months and days; non-date tokens are tagged O.

["hello", "O"], [" ", "O"], ["2", "B-YEAR"], ["0", "I-YEAR"], ["2", "I-YEAR"], ["2", "I-YEAR"], ["-", "O"], ["0", "B-MONTH"], ["4", "I-MONTH"], ["-", "O"], ["0", "B-DAY"], ["1", "I-DAY"], ["!", "O"]

This tagging structure is exactly what the ML classifier is trained to predict for new, unseen file names.

Classification Optimizations

To predict the IOB tags, the team evaluated text classification approaches. Traditional methods like TF-IDF or bag-of-words discard word order, which is fatal for understanding which symbols go with which component. Instead, they turned to transformer models. They settled on the pre-trained DistilRoberta as the backbone classifier—its size and performance profile fit the task well.

Even with that model choice, performance at inference was a challenge. A real-time latency above one second delivered a poor user experience. The team compressed the model with two common techniques: model pruning, which removes unnecessary parameters or layers, and model quantization, which reduces parameter precision (for instance, from float32 to float16).

Both optimizations brought latency down to an acceptable range, but pruning made the most significant impact. The full DistilRoberta architecture has six encoder layers and 88 million parameters—roughly 300 MB of data. Removing the last two encoder layers did not degrade model accuracy, yet it cut latency by more than 30 percent, making the feature responsive enough for production use.

Putting the model to work

In testing, the ML model delivered a 40% increase in renamed files over the baseline rule-based model. After the August 2022 rollout to users, both the feature’s weekly active user count and the volume of renamed files rose. During the first few weeks of availability, naming conventions were applied to over one million files.

User research surfaced a practical hurdle: some users were hesitant to manually set up naming convention rules for a folder. To remove that friction, Dropbox added automatic suggestions for naming conventions based on the conventions already present in files within the folder. This let users carry their existing naming patterns forward to new files instead of defining rules from scratch.

What comes next

Date components are not the only useful metadata hiding in file names—names, locations, and organizational entities appear frequently too. The current model extracts only date components, but the team envisions applying more sophisticated approaches, such as large language models, to identify additional entity types. That would enable a more granular and accurate renaming experience in the future.