Aid workers loading boxes into a convoy vehicle

XML Coding with AI, Episode 1: A New Hope

Once a curator has organised, arranged and described a collection of material, the next step is to make that work visible to others. At the University of Manchester Library, this usually means producing an XML file – a structured format that captures all the descriptive metadata needed to surface the material on the Jisc Archives Hub. It is a detailed and often repetitive task which seemed ripe for automation, especially with the arrival of new context-sensitive tools provided by generative AI. This blog series charts my journey so far with ChatGPT: the surprising strengths, the limitations, and everything in between. In this first blog post, I outline the problem and explain why AI was chosen as a potential solution.

Why XML isn’t easily automated

Screenshot of an XML file opened in the Oxygen XML editor. The structure displays hierarchical metadata for archival items, including elements such as , , , , and . The file contains nested levels for subseries and items, showing encoded descriptions of committee minutes, correspondence, and enclosures, with ISAD(G) tags and repository codes applied. This illustrates the complexity of encoded archival description (EAD) used for cataloguing materials at the University of Manchester Library.
A sample XML structure viewed using the Oxygen XML editor

Creating XML is a challenging process to automate for a couple of reasons. Firstly, the architecture is dependent on context – for example, archives may require language tags for some, all or none of the items, depending on the languages present in the material. Metadata is also arranged hierarchically, including data at item, file, subseries and series levels to varying extents, again depending on the material. (For a reasonably complex XML catalogue, take a look at the Stamford papers. Here some items are nested five layers down, others only three.) In addition, some large collections have been described in unstructured formats such as word to a ‘box list’ standard (a simple list of items in a collection, often used during initial cataloguing) and therefore require reformatting to fit the encoded archival description (EAD) standard for the XML file. Tools do exist to make creating XML easier, but manual editing is still needed to fine-tune the data to the required standard. For archives of hundreds or even thousands of items, this is a time-consuming process.

Exploring AI with the AIIA team

Screenshot of an Excel spreadsheet displaying a box list from the Elizabeth Wilson Collection. The spreadsheet includes structured metadata such as box numbers, item names, extent, physical condition, and detailed scope and description fields. Rows are grouped by archival boxes, with some fields using shorthand or unstructured notes (e.g. “[n.d.]”, “Some pages stuck together”). Highlighted rows indicate box-level divisions (e.g. "EWC/1 Files" and "EWC/2 Notebooks"). The data structure, while partially organised, is not fully machine-readable, illustrating the challenges of converting such lists into EAD-XML format for digital cataloguing.
Excerpt from the box list I brought to the workshop

On the 29th May 2024, our rare books curator Steven Hartshorne and I met with colleagues from the AIIA team (Ian Gifford, Nilani Ganeshwaran, Christopher Wilson, Pete Morris and Tom Higgins) to look at ways we could improve our cataloguing processes with a specific eye towards using AI tools. Steven was interested in using the technology for cataloguing printed books, a different type of challenge to cataloguing archives. For books, descriptions tend to be richer and based on standard fields such as publisher or date, information which may not be known or even apply to archival material (personal papers, miscellany and ephemera, for example). I brought with me some sample XML files already on JISC as well as a box list excel file for a small collection from the Humanitarian archive that I was planning to convert manually into XML.

Over the course of a three-hour workshop, we discussed different options such as a web app that takes pasted information from a list or a python script that can create XML from a structured file such as a .csv. Although both were potentially time-saving, they had limitations compared with generative AI. The use of pre-defined rules for traditional programmes means that variations in input metadata would require either re-tooling before processing or manual fixing of outputs after the file was produced. Generative AI, on the other hand, could potentially adapt its processes to the material, inferring patterns and interpreting a collection’s structure (such as an item sitting within a file or series) from even loosely structured data. In this way, it would align more with the way a human would approach the data, adapting its approach to the quirks and intricacies of the specific collection, but at a significantly faster pace.

Testing ChatGPT with real data

Screenshot of a ChatGPT interface showing the output of a Python script used to identify container rows in an Excel spreadsheet. The message at the top confirms that a hierarchical JSON file has been created, with a download link provided. A human response to the output explains that "container rows are highlighted in yellow." The Python code displayed reads an Excel file (Sheet1) and identifies highlighted rows based on missing or non-missing values in specific columns. This example demonstrates how AI was guided to recognise structure within semi-structured archival metadata.
Prompts by Tom Higgins to produce an accurate JSON file

We then asked ChatGPT to interpret the data from the box list excel file and produce a working XML file based on the examples provided. As the box list was not structured in a way a computer could easily read, we first instructed ChatGPT to convert it into a standard data format called JSON (JavaScript Object Notation). It misinterpreted the hierarchy at first, not understanding that the ‘containers’ (e.g. series) were highlighted in yellow. This revealed another advantage of using AI chatbots: troubleshooting was very easy, and if we understood the source of the problem we could correct it in plain speech (no knowledge of python required!). Once we were satisfied that the JSON contained all the right information organised in the right structure, we pasted an example of a record in EAD-XML format and asked the AI to create XML that followed the same rules. The output was a useable and accurate XML file, that would normally take several hours, created in around 10 minutes. You can view the finished record, the first to be co-created with AI, here: Elizabeth Wilson Collection.

The potential time saving using AI was really exciting, and I was looking forward to trying the tool for myself with larger collections. After the meeting I realised that some of the data in the box list that I had provided to ChatGPT needed to be edited to match established EAD standards. The file produced by ChatGPT was already in reasonable shape, so this could be done manually, but the process felt very slow, especially so with the knowledge that this could be accomplished in seconds with AI! In the meantime, I started experimenting with the free service, attempting to use optical character recognition on publicly available PDF handlists for example, but the free model was unable to process the large amounts of data necessary. I also gathered handlists and Word/PDF catalogues from other curators that could be used as test cases. In October, we gained access to the full service, allowing for the experimental phase to begin. In the next post, The Hallucinations Strike Back, I will outline the challenges I’ve been facing over the past six months using AI for XML.


Posted

in

by

Disclaimer / Data Protection / Copyright notice / Web accessibility / Freedom of information / Charitable status / Royal Charter Number: RC000797