spaCy/website/docs/usage/101/_serialization.md
Ines Montani e597110d31
💫 Update website (#3285)
<!--- Provide a general summary of your changes in the title. -->

## Description

The new website is implemented using [Gatsby](https://www.gatsbyjs.org) with [Remark](https://github.com/remarkjs/remark) and [MDX](https://mdxjs.com/). This allows authoring content in **straightforward Markdown** without the usual limitations. Standard elements can be overwritten with powerful [React](http://reactjs.org/) components and wherever Markdown syntax isn't enough, JSX components can be used. Hopefully, this update will also make it much easier to contribute to the docs. Once this PR is merged, I'll implement auto-deployment via [Netlify](https://netlify.com) on a specific branch (to avoid building the website on every PR). There's a bunch of other cool stuff that the new setup will allow us to do – including writing front-end tests, service workers, offline support, implementing a search and so on.

This PR also includes various new docs pages and content.
Resolves #3270. Resolves #3222. Resolves #2947. Resolves #2837.


### Types of change
enhancement

## Checklist
<!--- Before you submit the PR, go over this checklist and make sure you can
tick off all the boxes. [] -> [x] -->
- [x] I have submitted the spaCy Contributor Agreement.
- [x] I ran the tests, and all new and existing tests passed.
- [x] My changes don't require a change to the documentation, or if they do, I've added all required information.
2019-02-17 19:31:19 +01:00

1.6 KiB
Raw Blame History

If you've been modifying the pipeline, vocabulary, vectors and entities, or made updates to the model, you'll eventually want to save your progress for example, everything that's in your nlp object. This means you'll have to translate its contents and structure into a format that can be saved, like a file or a byte string. This process is called serialization. spaCy comes with built-in serialization methods and supports the Pickle protocol.

What's pickle?

Pickle is Python's built-in object persistence system. It lets you transfer arbitrary Python objects between processes. This is usually used to load an object to and from disk, but it's also used for distributed computing, e.g. with PySpark or Dask. When you unpickle an object, you're agreeing to execute whatever code it contains. It's like calling eval() on a string so don't unpickle objects from untrusted sources.

All container classes, i.e. Language (nlp), Doc, Vocab and StringStore have the following methods available:

Method Returns Example
to_bytes bytes data = nlp.to_bytes()
from_bytes object nlp.from_bytes(data)
to_disk - nlp.to_disk("/path")
from_disk object nlp.from_disk("/path")