LM Dataformat (lm-dataformat) is a Python utility designed for efficient storage and reading of files specifically tailored for large language model (LLM) training. It provides functionalities to archive data with associated metadata and stream documents for processing. The current version is 0.0.20, but the project appears to be abandoned, with no active development or maintenance since its last release in 2021 and last GitHub commit over six years ago.
pip install lm-dataformatVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to create a data archive using `lm-dataformat` by adding multiple JSON-formatted documents with associated metadata, committing the archive, and then reading the stored data back. It uses a temporary directory for demonstration and includes cleanup.
Consider migrating to actively maintained alternatives for LLM data handling, especially for new projects or those requiring long-term stability and security updates.
Pin exact dependency versions if using this library in a production environment, and thoroughly test for compatibility. Be prepared to fork and maintain the library yourself or migrate if critical issues arise.
Implement custom validation and error handling around `add_data` and `stream_data` calls. Ensure data is well-formed before archiving, and add logging to monitor the integrity of the data processing pipeline.
Always call `Archive.commit()` after adding all data to finalize the archive. Ensure the path passed to `Reader` is the directory where `Archive.commit()` was executed successfully.
This can indicate data corruption or an interruption during archive creation. Ensure sufficient disk space, proper permissions, and that the `commit()` method is called without interruption. Inspect the `output_dir` for partially written `.zst` files. If the problem persists, it may be an unaddressed bug in the abandoned library.
Ensure that any data you wish to store as a document is first converted into a string format, typically by using `json.dumps()` for Python dictionaries/lists, or `.decode('utf-8')` for byte strings.