A new integrated backend that replaces DisCoPy, which until now was providing the low-level functionality of
lambeq. The new backend offers better performance, increased stability, faster training speeds, and a simplified high-level interface to the user. The new backend consists of the following sub-modules:
lambeq.backend.grammar: Contains the building blocks for creating string diagrams.
lambeq.backend.tensor: Contains the necessary classes to create tensor diagrams.
lambeq.backend.pennylane: Interface with PennyLane.
lambeq.backend.tk: Inteface with Tket.
lambeq.backend.numerical_backend: Common interface for numerical backends (such as Numpy, Jax, PyTorch, TensorFlow)
lambeq.backend.drawing: Contains drawing functionality for diagrams and circuits.
BobcatParser: Added a special case for adjectival conjunction in tree translation.
Extra whitespace is now ignored in the
UnknownWordsRewriteRule: Fixed rewriting of non-word boxes.
This update features contributions from participants in unitaryHACK 2023:
A new rewrite rule for handling unknown words. (credit: WingCode)
Many thanks to all who participated.
This update also contains the following changes:
DiagramRewriteris a new class that rewrites diagrams by looking at the diagram as a whole rather than by using rewrite rules on individual boxes. This includes an example
UnifyCodomainRewriterwhich adds an extra box to the end of diagrams to change the output to a specified type. (credit: A.C.E07)
Added an early stopping mechanism to
Trainerusing the parameter
- Support for DisCoPy >= 1.1.4 (credit: toumix).
Diagram.decodeto account for the change in contructor signature
Diagram(inside, dom, cod).
updated attribute names that were previously hidden, e.g.
replaced diagrammatic conjugate with transpose.
swapped left and right currying.
dropped support for legacy DisCoPy.
CCGTree: added reference to the original tree from parsing by introducing a
Internalised DisCoPy quantum ansätze in lambeq.
IQPAnsatznow ends with a layer of Hadamard gates in the multi-qubit case and the post-selection basis is set to be the computational basis (Pauli Z).
Fixed a bottleneck during the initialisation of the
PennyLaneModelcaused by the inefficient substitution of Sympy symbols in the circuits.
Escape special characters in box labels for symbol creation.
Documentation: fixed broken links to DisCoPy documentation.
Documentation: enabled sphinxcontrib.jquery extension for Read the Docs theme.
RealAnsatzin extend-lambeq tutorial notebook.
Fixed model loading in PennyLane notebooks.
Removed support for Python 3.8.
Added example and tutorial notebooks to tests.
Dependencies: pinned the maximum version of Jax and Jaxlib to 0.4.6 to avoid a JIT-compilation error when using the
Support for hybrid quantum-classical models using the
PennyLaneModel. PennyLane is a powerful QML library that allows the development of hybrid ML models by hooking numerically determined gradients of parametrised quantum circuits (PQCs) to the autograd modules of ML libraries like PyTorch or TensorFlow.
Python 3.11 support.
An extensive NLP-101 tutorial, covering basic definitions, text preprocessing, tokenisation, handling of unknown words, machine learning best practices, text classification, and other concepts.
Improve tensor initialisation in the
PytorchModel. This enables the training of larger models as all parameters are initialised such that the expected L2 norm of all output vectors is approximately 1. We use a symmetric uniform distribution where the range depends on the output dimension (flow) of each box.
Improve the fail-safety of the
BobcatParsermodel download method by adding hash checks and atomic transactions.
Use type union expression
Unionin type hints.
raise fromsyntax for better exception handling.
Update the requirements for the documentation.
Fixed bug in
SPSAOptimizertriggered by the usage of masked arrays.
Fixed test for
NumpyModelthat was failing due to a change in the behaviour of Jax.
Fixed brittle quote-wrapped strings in error messages.
Fixed 400 response code during Bobcat model download.
Fixed bug where
CircuitAnsatzwould add empty discards and postselections to the circuit.
Removed install script due to deprecation.
Improved the performance of
NumpyModelwhen using Jax JIT-compilation.
Dependencies: pinned the required version of DisCoPy to 0.5.X.
Fixed incorrectly scaled validation loss in progress bar during model training.
Fixed symbol type mismatch in the quantum models when a circuit was previously converted to tket.
Added new methods to
Checkpointfor creating, saving and loading checkpoints for training.
Documentation: added a section for how to select the right model and trainer for training.
Documentation: added links to glossary terms throughout the documentation.
Documentation: added UML class diagrams for the sub-packages in lambeq.
Dependencies: bumped the minimum versions of
IQPAnsatznow post-selects in the Hadamard basis.
PytorchModelnow initialises using
CCGTree.to_json()can now be applied to
Several slow imports have been deferred, making lambeq much faster to import for the first time.
CCGRule.infer_rule(), direction checks have been made explicit.
UnarySwapis now specified to be a
BobcatParserhas been refactored for easier use with external evaluation tools.
Documentation: headings have been organised in the tutorials into subsections.
punc + Xinstance: if the result is
X\Xthe assigned rule is
CCGRule.CONJUNCTION, otherwise the rule is
CCGRule.REMOVE_PUNCTUATION_LEFT(similarly for punctuation on the right).
Added a strict pregroups mode to the CLI. With this mode enabled, all swaps are removed from the output string diagrams by changing the ordering of the atomic types, converting them into a valid pregroup form as given in [Lam1999].
Adjusted the behaviour of output normalisation in quantum models. Now,
NumpyModelalways returns probabilities instead of amplitudes.
Removed the prediction from the output of the
SPSAOptimizer, which now returns just the loss.
Added a “swapping” unary rule box to handle unary rules that change the direction of composition, improving the coverage of the
--versionflag to the CLI.
make_checkpoint()method to all training models.
WebParserso that the online service to use is specified by name rather than by URL.
BobcatParserto only allow one tree per category in a cell, doubling parsing speed without affecting the structure of the parse trees (in most cases).
Fixed the parameter names in
codhad inadvertently been swapped.
Made the linting of the codebase stricter, enforced by the GitHub action. The flake8 configuration can be viewed in the
Fix false positives in assigning conjunction rule using the
CCGBankParser. The rule
, + X[conj] -> X[conj]is a case of removing left punctuation, but was being assigned conjunction erroneously.
Add support for using
jaxas backend of
NumpyModel. The interface is not affected by this change, but performance of the model is significantly improved.
Fix a bug that raised a
dtypeerror when using the
Fix a bug that caused the normalisation of scalar outputs of circuits without open wires using a
Command-line interface: Add CCG mode. When enabled, the output will be a string representation of the CCG diagram corresponding to the
CCGTreeobject produced by the parser, instead of a DisCoPy diagram or circuit.
Documentation: Add a troubleshooting page.
Add support for Python 3.10.
Unify class hierarchies for parsers and readers:
CCGParseris now a subclass of
Readerand placed in the common package
text2diagram. The old packages
ccg2discocatare no longer available. Compatibility problems with previous versions should be minimal, since from Release 0.2.0 and onwards all
lambeqclasses can be imported from the global namespace.
CurryRewriteRule, which uses map-state duality in order to remove adjoint types from the boxes of a diagram. When used in conjunction with
normal_form(), this removes cups from the diagram, eliminating post-selection.
The Bobcat parser now updates automatically when new versions are made available online.
Update grammar file of Bobcat parser to avoid problems with conflicting unary rules.
Allow customising available root categories for the parser when using the command-line interface.
A new state-of-the-art CCG parser based on [SC2021], fully integrated with
lambeq, which replaces depccg as the default parser of the toolkit. The new Bobcat parser has better performance, simplifies installation, and provides compatibility with Windows (which was not supported due to a depccg conflict). depccg is still supported as an alternative external dependency.
trainingpackage, providing a selection of trainers, models, and optimizers that greatly simplify supervised training for most of
lambeq’s use cases, classical and quantum. The new package adds several new features to
lambeq, such as the ability to save to and restore models from checkpoints.
trainingpackage uses DisCoPy’s tensor network capability to contract tensor diagrams efficiently. In particular, DisCoPy 0.4.1’s new unitary and density matrix simulators result in substantially faster training speeds compared to the previous version.
A command-line interface, which provides most of
lambeq’s functionality from the command line. For example,
lambeqcan now be used as a standard command-line pregroup parser.
A web parser class that can send parsing queries to an online API, so that local installation of a parser is not strictly necessary anymore. The web parser is particularly helpful for testing purposes, interactive usage or when a local parser is unavailable, but should not be used for serious experiments.
pregroupspackage that provides methods for easy creation of pregroup diagrams, removal of cups, and printing of diagrams in text form (i.e. in a terminal).
TreeReaderclass that exploits the biclosed structure of CCG grammatical derivations.
Tokenisation features have been added in all parsers and readers.
Additional generator methods and minor improvements for the
Improved and more detailed package structure.
Most classes and functions can now be imported from
lambeqdirectly, instead of having to import from the sub-packages.
tensormodules have been combined into an
lambeq.ansatzpackage. (However, as mentioned above, the classes and functions they define can now be imported directly from
lambeqand should continue to do so in future releases.)
Improved documentation and additional tutorials.
Add URLs to the setup file.
Fix logo link in README.
Fix missing version when building docs in GitHub action.
Fix typo in the
descriptionkeyword of the setup file.
Update install script to use PyPI package.
Add badges and documentation link to the README file.
lambeqlogo and documentation link to the GitHub repository.
Allow documentation to get the package version automatically.
Add keywords and classifiers to the setup file.
lambeq.circuitmodule to top-level
Fix references to license file.
The initial release of
lambeq, containing a lot of core material. Main features:
Converting sentences to string diagrams.
CCG parsing, including reading from CCGBank.
Support for the
DisCoCat, bag-of-words, and word-sequence compositional models.
Support for adding new compositional schemes.
Rewriting of diagrams.
Ansätze for circuits and tensors, including various forms of matrix product states.
Support for JAX and PyTorch integration.
Example notebooks and documentation.