Tags: CQCL/lambeq
Tags
Added: - A new experimental `lambeq.experimental.discocirc` module that contains an efficient `lambeq.experimental.discocirc.DisCoCircReader` and all the required functionality for converting long texts and entire multi-paged documents into quantum circuits, based on the `DisCoCirc` framework. - A new tree representation of a pregroup diagram, termed `pregroup tree`, is implemented through the `lambeq.text2diagram.pregroup_tree.PregroupTreeNode` class. This lays the groundwork for drastically improving the parsing and internal processing of diagrams. - A new experimental end-to-end parser class, `lambeq.text2diagram.OncillaParser`, that simplifies the process of generating diagrams from text, minimizing or even eliminating exposure of the user to CCG representations and functionality. This parser utilises the `pregroup tree` representation of diagrams. This does not replace `BobcatParser` as the default parser. - A new `lambeq.backend.grammar.Frame` data structure that allows the recursive grouping of `lambeq` boxes and diagrams and can be seen as a `quantum supermap` acting on the enclosed arguments. Frames are used in `DisCoCirc` diagrams. - A new `lambeq.training.PytorchQuantumModel` class that allows Pytorch autograd to be used on quantum circuits, while so far it was possible to use it only on tensor networks (credit: [Kin Ian Lo](https://github.com/kinianlo)). - A new native `lambeq.backend.symbol.Symbol` class that eliminates any dependencies with [SymPy](https://www.sympy.org/) and improves efficiency. - A new rewrite rule class, `lambeq.rewrite.CollapseDomainRewriteRule`, that converts boxes into domain-less boxes by uncurrying (credit: [Kin Ian Lo](<https://github.com/kinianlo>)). - New `lambeq.backend.Diagram.remove_snakes` and `lambeq.backend.Diagram.rigid_normal_form` methods that make the specific rewrites also available outside of the original `lambeq.backend.Diagram.normal_form` method (credit: [Kin Ian Lo](https://github.com/kinianlo)). - Caching options for fast access to already computed tensor contraction paths for tensor network models, specifically `PytorchModel` and `PytorchQuantumModel`. The constructor of these models now takes a `tn_path_optimizer` argument, which can be a `TnPathOptimizer` object, replicating the old un-cached behaviour, or a `CachedTnPathOptimizer` which allows caching of the computed tensor contraction paths for quick lookup. - Support for evaluating mixed-scalar PennyLane circuits, i.e. circuits where all qubits are either discarded or post-selected. - Two new ansätze from the Sim *et al.* paper ([arXiv:1905.10876](https://arxiv.org/abs/1905.10876)), `Sim9Ansatz` and `Sim9CxAnsatz`. - Support for ancilla qubits in `lambeq`'s ansätze. Changed: - Significantly improved the efficiency of the `PennyLaneModel`. - Refactored all models so that they do not depend on `tket` as an intermediate step for their conversions. - `CircuitAnsatz` now acts as a dagger functor (credit: [Kin Ian Lo](https://github.com/kinianlo)). - Refactored `QuantumModel` to be less numpy-specific and easier to extend with other backends. - Made the split tensor ansätze, i.e. `SpiderAnsatz` and `MPSAnsatz`, work on boxes with domains. This utilises the newly-implemented `CollapseDomainRewriteRule` (credit: [Kin Ian Lo](https://github.com/kinianlo)). - Changed the `device` keyword argument for model-based parsers, e.g. `BobcatParser`, so that it follows PyTorch convention and supports multiple types. - Added the new `lambeq.text2diagram.OncillaParser` as a parser option to the CLI via the `-p oncilla` argument. - Removed the deprecated `lambeq.text2diagram.DepCCGParser` as a parser option from the CLI. - Refactored tokeniser loading from `SpacyTokeniser` into a new utility function `lambeq.core.utils.get_spacy_tokeniser`. - Significantly extended and restructured the documentation pages, fixed various issues, and added more material and tutorials. - Made `tket` an optional dependency. Fixed: - Fixed an enum incompatibility with Python > 3.10. - Fixed the behaviour of tensoring a type with the identity diagram. - Fixed a `lambeq.backend.Diagram.lambdify` method error when used with a daggered tensor box (credit: [Kin Ian Lo](https://github.com/kinianlo)).
Changed: - Documentation has now been moved to a [dedicated repository](https://github.com/CQCL/lambeq-docs) and got a new URL (https://cqcl.github.io/lambeq-docs/). - Changed the landing page and some visuals in the online documentation. - Updated README to reflect the new docs structure. Fixed: - Fixed minor issues on some documentation pages and the README file.
Added: - Added timing information to training logs and model checkpoints. Changed: - Changed theme of online documentation. - Updated required version of `pytket` to 1.31.0. Fixed: - Fixed bug in generation of single-legged quantum spiders. - Fixed bug when evaluating quantum circuits using Tket. Removed: - Removed support for Python 3.9.
Added: - Support for Python 3.12. - A new `Sim4Ansatz` based on the paper by Sim et al. (arXiv:1905.10876). - A new argument in `Trainer.fit` for specifying an `early_stopping_criterion` other than validation loss. - A new argument `collapse_noun_phrases` in methods of `CCGParser` and `CCGTree` classes (for example, see `CCGParser.sentence2diagram`) that allows the user to maintain noun phrases in the derivation or collapse them into nouns as desired. - Raised meaningful exception when users try to convert to/from DisCoPy 1.1.0. Changed: - An internal refactoring of module `backend.drawing` in view of planned new features. - Updated random number generation in `TketModel` by using the recommended `numpy.random.default_rnd` method. Fixed: - Handling of possible empty ``Bra`` s and ``Ket`` s during conversion from DisCoPy. - Fixed a bug in JIT compilation of mixed circuit evaluations.
Added: - 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.quantum``: Adds quantum-specific functionality to the backend and provides a circuit simulator based on the [TensorNetwork](https://github.com/google/TensorNetwork) library. - ``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. - ``lambeq.BobcatParser``: Added a special case for adjectival conjunction in tree translation. - ``lambeq.TreeReader``: Diagrams now are created straight from the ``lambeq.CCGTree``. - ``lambeq.CCGRule`` apply method: Added ``lambeq.CCGRule.apply`` method to class ``lambeq.CCGRule``. Changed: - Diagram-level rewriters: Rewrite functions ``remove_cups`` and ``remove_swaps`` are now refactored as diagram-level rewriters, ``lambeq.RemoveCupsRewriter`` and ``lambeq.RemoveSwapsRewriter`` correspondingly. - Extra whitespace is now ignored in the ``lambeq.Tokeniser``. Fixed: - ``lambeq.UnknownWordsRewriteRule``: Fixed rewriting of non-word boxes. Removed: - Removed ``CCGTree.to_biclosed_diagram`` and references to ``discopy.biclosed``. Now CCG trees are directly converted into string diagrams, without the extra step of storing the derivation in a biclosed form. - ``lambeq.CCGRule``: Removed ``replace_cat_result`` and added ``lambeq.CCGRule.resolve``.
This update features contributions from participants in unitaryHACK 2… …023: - Two new optimisers: - The Nelder-Mead optimiser. (credit: Gopal Dahale) - The Rotosolve optimiser. (credit: Ahmed Darwish) - A new rewrite rule for handling unknown words. (credit: WingCode) Many thanks to all who participated. This update also contains the following changes: Added: - `lambeq.DiagramRewriter` is 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 `UnifyCodomainRewriter` which 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 `Trainer` using the parameter `early_stopping_interval`. Fixed: - In `PennyLaneModel`, SymPy symbols are now substituted during the forward pass so that gradients are back-propagated to the original parameters. - A pickling error that prevented CCG trees produced by `BobcatParser` from being unpickled has been fixed.
Added: - Support for `DisCoPy` >= 1.1.4 (credit: toumix). - replaced `discopy.rigid` with `discopy.grammar.pregroup` everywhere. - replaced `discopy.biclosed` with `discopy.grammar.categorial` everywhere. - Use `Diagram.decode` to account for the change in contructor signature `Diagram(inside, dom, cod)`. - updated attribute names that were previously hidden, e.g. `._data` becomes `.data`. - replaced diagrammatic conjugate with transpose. - swapped left and right currying. - dropped support for legacy DisCoPy. - Added `CCGType` class for utilisation in the `biclosed_type` attribute of `CCGTree`, allowing conversion to and from a discopy categorial object using `CCGType.discopy` and `CCGType.from_discopy` methods. - `CCGTree`: added reference to the original tree from parsing by introducing a `metadata` field. Changed: - Internalised DisCoPy quantum ansätze in lambeq. - `IQPAnsatz` now 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: - Fixed a bottleneck during the initialisation of the `PennyLaneModel` caused 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. - Fixed disentangling `RealAnsatz` in extend-lambeq tutorial notebook. - Fixed model loading in PennyLane notebooks. - Fixed typo `SPSAOptimizer` (credit: Gopal-Dahale) Removed: - Removed support for Python 3.8.
Changed: - 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 `NumpyModel`. Fixed: - Documentation: fixed broken DisCoPy links. - Fixed PyTorch datatype errors in example and tutorial notebooks. - Updated custom ansätze in tutorial notebook to match new structure of `CircuitAnsatz` and `TensorAnsatz`.
Added: - 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. - Add lambeq-native loss functions `LossFunction` to be used in conjunction with the`QuantumTrainer`. Currently, we support the `CrossEntropyLoss`, `BinaryCrossEntropyLoss`, and the `MSELoss` loss functions. - 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. Changed: - 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 `BobcatParser` model download method by adding hash checks and atomic transactions. - Use type union expression `|` instead of `Union` in type hints. - Use `raise from` syntax for better exception handling. - Update the requirements for the documentation. Fixed: - Fixed bug in `SPSAOptimizer` triggered by the usage of masked arrays. - Fixed test for `NumpyModel` that 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 `CircuitAnsatz` would add empty discards and postselections to the circuit. Removed: - Removed install script due to deprecation.
Changed: - Improved the performance of `NumpyModel` when using Jax JIT-compilation. - Dependencies: pinned the required version of DisCoPy to 0.5.X. Fixed: - 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.
PreviousNext