Recent Releases of https://github.com/cqcl/lambeq
https://github.com/cqcl/lambeq - 0.5.0
Added:
- A new experimental
lambeq.experimental.discocircmodule that contains an efficientlambeq.experimental.discocirc.DisCoCircReaderand all the required functionality for converting long texts and entire multi-paged documents into quantum circuits, based on theDisCoCircframework. - A new tree representation of a pregroup diagram, termed
pregroup tree, is implemented through thelambeq.text2diagram.pregroup_tree.PregroupTreeNodeclass. 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 thepregroup treerepresentation of diagrams. This does not replaceBobcatParseras the default parser. - A new
lambeq.backend.grammar.Framedata structure that allows the recursive grouping oflambeqboxes and diagrams and can be seen as aquantum supermapacting on the enclosed arguments. Frames are used inDisCoCircdiagrams. - A new
lambeq.training.PytorchQuantumModelclass 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). - A new native
lambeq.backend.symbol.Symbolclass that eliminates any dependencies with SymPy and improves efficiency. - A new rewrite rule class,
lambeq.rewrite.CollapseDomainRewriteRule, that converts boxes into domain-less boxes by uncurrying (credit: Kin Ian Lo). - New
lambeq.backend.Diagram.remove_snakesandlambeq.backend.Diagram.rigid_normal_formmethods that make the specific rewrites also available outside of the originallambeq.backend.Diagram.normal_formmethod (credit: Kin Ian Lo). - Caching options for fast access to already computed tensor contraction paths for tensor network models, specifically
PytorchModelandPytorchQuantumModel. The constructor of these models now takes atn_path_optimizerargument, which can be aTnPathOptimizerobject, replicating the old un-cached behaviour, or aCachedTnPathOptimizerwhich 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),
Sim9AnsatzandSim9CxAnsatz. - 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
tketas an intermediate step for their conversions. CircuitAnsatznow acts as a dagger functor (credit: Kin Ian Lo).- Refactored
QuantumModelto be less numpy-specific and easier to extend with other backends. - Made the split tensor ansätze, i.e.
SpiderAnsatzandMPSAnsatz, work on boxes with domains. This utilises the newly-implementedCollapseDomainRewriteRule(credit: Kin Ian Lo). - Changed the
devicekeyword argument for model-based parsers, e.g.BobcatParser, so that it follows PyTorch convention and supports multiple types. - Added the new
lambeq.text2diagram.OncillaParseras a parser option to the CLI via the-p oncillaargument. - Removed the deprecated
lambeq.text2diagram.DepCCGParseras a parser option from the CLI. - Refactored tokeniser loading from
SpacyTokeniserinto a new utility functionlambeq.core.utils.get_spacy_tokeniser. - Significantly extended and restructured the documentation pages, fixed various issues, and added more material and tutorials.
- Made
tketan 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.lambdifymethod error when used with a daggered tensor box (credit: Kin Ian Lo).
- Python
Published by neiljdo about 1 year ago
https://github.com/cqcl/lambeq - 0.4.3
Changed:
- Documentation has now been moved to a dedicated repository 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.
- Python
Published by neiljdo almost 2 years ago
https://github.com/cqcl/lambeq - 0.4.2
Added:
- Added timing information to training logs and model checkpoints.
Changed:
- Changed theme of online documentation.
- Updated required version of
pytketto 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.
- Python
Published by nikhilkhatri almost 2 years ago
https://github.com/cqcl/lambeq - 0.4.1
Added:
- Support for Python 3.12.
- A new
Sim4Ansatzbased on the paper by Sim et al. (arXiv:1905.10876). - A new argument in
Trainer.fitfor specifying anearly_stopping_criterionother than validation loss. - A new argument
collapse_noun_phrasesin methods ofCCGParserandCCGTreeclasses (for example, seeCCGParser.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.drawingin view of planned new features. - Updated random number generation in
TketModelby using the recommendednumpy.random.default_rndmethod.
Fixed:
- Handling of possible empty
Bras andKets during conversion from DisCoPy. - Fixed a bug in JIT compilation of mixed circuit evaluations.
- Python
Published by nikhilkhatri about 2 years ago
https://github.com/cqcl/lambeq - 0.4.0
Added:
A new integrated backend that replaces
DisCoPy, which until now was providing the low-level functionality oflambeq. 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 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 thelambeq.CCGTree.lambeq.CCGRuleapply method: Addedlambeq.CCGRule.applymethod to classlambeq.CCGRule.
Changed:
- Diagram-level rewriters: Rewrite functions
remove_cupsandremove_swapsare now refactored as diagram-level rewriters,lambeq.RemoveCupsRewriterandlambeq.RemoveSwapsRewritercorrespondingly. - Extra whitespace is now ignored in the
lambeq.Tokeniser.
Fixed:
lambeq.UnknownWordsRewriteRule: Fixed rewriting of non-word boxes.
Removed:
- Removed
CCGTree.to_biclosed_diagramand references todiscopy.biclosed. Now CCG trees are directly converted into string diagrams, without the extra step of storing the derivation in a biclosed form. lambeq.CCGRule: Removedreplace_cat_resultand addedlambeq.CCGRule.resolve.
- Python
Published by Thommy257 over 2 years ago
https://github.com/cqcl/lambeq - 0.3.3
This update features contributions from participants in unitaryHACK 2023: - 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:
- 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.
- Python
Published by ianyfan almost 3 years ago
https://github.com/cqcl/lambeq - 0.3.2
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.
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:
- 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.
- Fixed disentangling
RealAnsatzin extend-lambeq tutorial notebook. - Fixed model loading in PennyLane notebooks.
- Fixed typo
SPSAOptimizer(credit: Gopal-Dahale)
Removed:
- Removed support for Python 3.8.
- Python
Published by Thommy257 almost 3 years ago
https://github.com/cqcl/lambeq - 0.3.1
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
CircuitAnsatzandTensorAnsatz.
- Python
Published by nikhilkhatri about 3 years ago
https://github.com/cqcl/lambeq - 0.3.0
Added:
- Support for hybrid quantum-classical models using the
PennyLaneModel.PennyLaneis 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
LossFunctionto be used in conjunction with theQuantumTrainer. Currently, we support theCrossEntropyLoss,BinaryCrossEntropyLoss, and theMSELossloss 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
BobcatParsermodel download method by adding hash checks and atomic transactions. - Use type union expression
|instead ofUnionin type hints. - Use
raise fromsyntax for better exception handling. - Update the requirements for the documentation.
Fixed:
- 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:
- Removed install script due to deprecation.
- Python
Published by Thommy257 about 3 years ago
https://github.com/cqcl/lambeq - 0.2.8
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.
- Python
Published by Thommy257 over 3 years ago
https://github.com/cqcl/lambeq - 0.2.7
Added:
- Added support for Japanese to DepCCGParser. (credit: KentaroAOKI https://github.com/CQCL/lambeq/pull/24)
- Overhauled the CircuitAnsatz interface, and added three new ansätze.
- Added helper methods to CCGTree to get the children of a tree.
Added a new .tree2diagram method to TreeReader, extracted from TreeReader.sentence2diagram.
- Added a new TreeReaderMode named HEIGHT.
- Added new methods to Checkpoint for 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.
Changed:
- Dependencies: bumped the minimum versions of discopy and torch.
- IQPAnsatz now post-selects in the Hadamard basis.
- PytorchModel now initialises using xavier_uniform.
- CCGTree.to_json can now be applied to None, returning None.
- Several slow imports have been deferred, making lambeq much faster to import for the first time.
- In CCGRule.infer_rule, direction checks have been made explicit.
- UnarySwap is now specified to be a unaryBoxConstructor.
- BobcatParser has been refactored for easier use with external evaluation tools.
- Documentation: headings have been organised in the tutorials into subsections.
Fixed:
- Fixed how CCGRule.infer_rule assigns a punc + X instance: if the result is X\X the assigned rule is CONJUNCTION, otherwise the rule is REMOVE_PUNCTUATION_LEFT (similarly for punctuation on the right).
Removed:
- Removed unnecessary override of .from_diagrams in NumpyModel.
- Removed unnecessary kwargs parameters from several constructors.
- Removed unused special_cases parameter and _ob method from CircuitAnsatz.
- Python
Published by ianyfan over 3 years ago
https://github.com/cqcl/lambeq - 0.2.6
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.
Fixed:
- Adjusted the behaviour of output normalisation in quantum models. Now, NumpyModel always returns probabilities instead of amplitudes.
- Removed the prediction from the output of the SPSAOptimizer, which now returns just the loss.
- Python
Published by ianyfan almost 4 years ago
https://github.com/cqcl/lambeq - 0.2.5
Added:
- Added a "swapping" unary rule box to handle unary rules that change the direction of composition, improving the coverage of the BobcatParser.
- Added a --version flag to the CLI.
- Added a make_checkpoint method to all training models.
Changed:
- Changed the WebParser so that the online service to use is specified by name rather than by URL.
- Changed the BobcatParser to only allow one tree per category in a cell, doubling parsing speed without affecting the structure of the parse trees (in most cases).
- Made the linting of the codebase stricter, enforced by the GitHub action. The flake8 configuration can be viewed in the setup.cfg file.
Fixed:
- Fixed the parameter names in CCGRule, where dom and cod had inadvertently been swapped.
- Python
Published by ianyfan almost 4 years ago
https://github.com/cqcl/lambeq - 0.2.4
Added:
- Support for using jax as backend of tensornetwork when setting use_jit=True in the NumpyModel. The interface is not affected by this change, but performance of the model is significantly improved.
Fixed:
- Fix a bug that caused the BobcatParser and the WebParser to trigger an SSL certificate error using Windows.
- 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.
- Python
Published by Thommy257 almost 4 years ago
https://github.com/cqcl/lambeq - 0.2.3
Added:
- CCGRule: Add symbol method that returns the ASCII symbol of a given CCG rule.
- CCGTree: Extend deriv method with CCG output. It is now capable of returning standard CCG diagrams.
- Command-line interface: CCG mode. When enabled, the output will be a string representation of the CCG diagram corresponding to the CCGTree object produced by the parser, instead of DisCoPy diagram or circuit.
- Documentation: Add a troubleshooting page.
Change:
- Change the behaviour of spiders_reader such that the spiders decompose logarithmically. This change also affects other rewrite rules that use spiders, such as coordination and relative pronouns.
- Rename AtomicType.PREPOSITION to AtomicType.PREPOSITIONAL_PHRASE.
Fixed:
- Fix a bug that raised a dtype error when using the TketModel on Windows.
- Fix a bug that caused the normalisation of scalar outputs of circuits without open wires using a QuantumModel.
- Python
Published by Thommy257 about 4 years ago
https://github.com/cqcl/lambeq - 0.2.2
Added:
- Add support for Python 3.10.
- Unify class hierarchies for parsers and readers: CCGParser is now a subclass of Reader and placed in the common package text2diagram. The old packages reader and ccg2discocat are no longer available. Compatibility problems with previous versions should be minimal, since from Release 0.2.0 and onwards all lambeq classes can be imported from the global namespace.
- Add CurryRewriteRule, which uses map-state duality in order to remove adjoint types from the boxes of a diagram. When used in conjunction with discopy.rigid.Diagram.normal_form(), this removes cups from the diagram, eliminating post-selection.
- The Bobcat parser now updates automatically when new versions are made available online.
- Allow customising available root categories for the parser when using the command-line interface.
Fixed:
- Update grammar file of Bobcat parser to avoid problems with conflicting unary rules.
- Python
Published by y-richie-y about 4 years ago
https://github.com/cqcl/lambeq - 0.2.1
Added:
- A new Checkpoint class that implements pickling and file operations from Trainer and Model.
Changed:
- Improvements to the training module, allowing multiple diagrams to be accepted as input to the SPSAOptimizer.
- Updated documentation, including sub-package structures and class diagrams.
- Python
Published by ianyfan about 4 years ago
https://github.com/cqcl/lambeq - 0.2.0
Added:
- A new state-of-the-art CCG parser, 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.
- A training package, 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.
- Furthermore, the training package uses DisCoPy's tensor network capability to contract tensor diagrams efficiently. In particular, DisCoPy 0.4.1's new unitary and density matrix simulators in 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, lambeq can 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.
- A new lambeq.pregroups package that provides methods for easy creation of pregroup diagrams, removal of cups, and printing of diagrams in text form (i.e. in a terminal).
- A new TreeReader class that exploits the biclosed structure of CCG grammatical derivations.
- Three new rewrite rules for relative pronouns and coordination.
- Tokenisation features have been added in all parsers and readers.
- Additional generator methods and minor improvements for the CCGBankParser class.
Changed:
- Improved and more detailed package structure.
- Most classes and functions can now be imported from lambeq directly, instead of having to import from the sub-packages.
- The circuit and tensor modules have been combined into an lambeq.ansatz package. (However, as mentioned above, the classes and functions they define can now be imported directly from lambeq and should continue to do so in future releases.)
- Improved documentation and additional tutorials.
- Python
Published by y-richie-y about 4 years ago
https://github.com/cqcl/lambeq - 0.1.2
Minor changes: - Add URLs to setup file
Fixes: - Fix logo link in README - Fix missing version when building docs in GitHub action - Fix typo to description keyword in setup file
- Python
Published by ianyfan over 4 years ago
https://github.com/cqcl/lambeq - 0.1.1
Minor changes: - Update install script to use PyPI package - Add badges and link to documentation to README file - Add lambeq logo and link to GitHub to documentation - Allow documentation to automatically get package version - Add keywords and classifiers to setup file
Fixes:
- Add lambeq.circuit submodule to top-level lambeq module
- Fix references to license file
- Python
Published by ianyfan over 4 years ago
https://github.com/cqcl/lambeq - 0.1.0
Initial release of lambeq. This contains a lot of core material:
- converting sentences to string diagrams
- CCG parsing, including reading from CCGBank
- support for depccg parsing
- rewriting diagrams
- ansatze for circuits and tensors, including MPS ansatze
- support for JAX and PyTorch integration
- example notebooks and documentation
- Python
Published by ianyfan over 4 years ago