Skip to content

Commit 19da7cd

Browse files
Thomas HoffmannianyfanDimitri Kartsaklisnikhilkhatrineiljdo
committed
Release version 0.4.0
Co-authored-by: Ian Fan <ian.fan@quantinuum.com> Co-authored-by: Dimitri Kartsaklis <dimitri.kartsaklis@quantinuum.com> Co-authored-by: Nikhil Khatri <nikhil.khatri@quantinuum.com> Co-authored-by: Neil Ortega <neil.ortega@quantinuum.com>
1 parent 5da6a54 commit 19da7cd

File tree

196 files changed

+18277
-7312
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

196 files changed

+18277
-7312
lines changed

.github/workflows/build_test.yml

+2-33
Original file line numberDiff line numberDiff line change
@@ -79,37 +79,6 @@ jobs:
7979
--durations=50
8080
--ignore=${{ env.TEST_DIR }}/text2diagram/test_depccg_parser.py
8181
--ignore=${{ env.DOCS_DIR }}/extract_code_cells.py
82-
- name: Determine if depccg tests should be run
83-
# only test depccg if it is explicitly changed, since it is very slow
84-
# tests are also disabled on Python 3.11
85-
id: depccg-enabled
86-
continue-on-error: true # this is expected to fail but the job should still succeed
87-
run: >
88-
${{ matrix.python-version != '3.11' }}
89-
&& git fetch --depth=1 origin ${{ github.base_ref || github.event.before }}:before
90-
&& git diff --name-only before | grep depccg
91-
- name: Install depccg and locate depccg pre-trained model cache
92-
id: loc-depccg-cache
93-
if: steps.depccg-enabled.outcome == 'success'
94-
run: |
95-
pip install cython # must be installed before depccg
96-
pip install depccg==2.0.3.2
97-
echo "dir=$(python -c 'from depccg.instance_models import MODEL_DIRECTORY, MODELS; print(MODEL_DIRECTORY / MODELS["en"][1])')" >> $GITHUB_OUTPUT
98-
pip install lambeq # override dependency conflicts
99-
- name: Restore depccg pre-trained model from cache
100-
id: depccg-cache
101-
if: steps.depccg-enabled.outcome == 'success'
102-
uses: actions/cache@v2
103-
with:
104-
path: ${{ steps.loc-depccg-cache.outputs.dir }}
105-
key: depccg
106-
- name: Download depccg pre-trained model if needed
107-
if: steps.depccg-enabled.outcome == 'success' && steps.depccg-cache.outputs.cache-hit != 'true'
108-
run: python -c 'import tarfile, urllib;from depccg.instance_models import MODEL_DIRECTORY;tarfile.open(urllib.request.urlretrieve("https://qnlp.cambridgequantum.com/models/tri_headfirst.tar.gz")[0]).extractall(MODEL_DIRECTORY)'
109-
- name: Test DepCCGParser
110-
if: steps.depccg-enabled.outcome == 'success'
111-
continue-on-error: true
112-
run: coverage run --append --source=${{ env.SRC_DIR }} -m pytest -k test_depccg_parser.py
11382
- name: Preparation for notebook testing
11483
run: pip install nbmake
11584
- name: Test example notebooks
@@ -141,9 +110,9 @@ jobs:
141110
with:
142111
python-version: ${{ matrix.python-version }}
143112
- name: Install dependencies with type hints
144-
run: python -m pip install numpy pytket spacy torch types-PyYAML
113+
run: python -m pip install numpy pytket spacy torch types-PyYAML types-Pillow ipython
145114
- name: Install type checker
146-
run: python -m pip install mypy==1.3.0 # unpin when newer version works
115+
run: python -m pip install mypy
147116
- name: Type check with mypy
148117
run: mypy ${{ env.SRC_DIR }}
149118
- name: View strict type errors

.github/workflows/docs.yml

+5
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ on:
1010

1111
env:
1212
WORKFLOWS_DIR: .github/workflows
13+
DOCS_DIR: docs
1314

1415
jobs:
1516
docs:
@@ -29,6 +30,10 @@ jobs:
2930
run: |
3031
sudo apt-get install graphviz pandoc
3132
pip install -r docs/requirements.txt
33+
- name: Draw diagrams from PlantUML files
34+
uses: Timmy/plantuml-action@v1
35+
with:
36+
args: '-v -DPLANTUML_LIMIT_SIZE=8192 -tpng ${{ env.DOCS_DIR }}/puml/*.puml -o img'
3237
- name: Build documentation
3338
run: ${{ env.WORKFLOWS_DIR }}/build-docs
3439
- name: Deploy documentation

.gitignore

+8
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,11 @@ htmlcov/
1313
# ignore the built documentation
1414
docs/_*
1515
!docs/_static/
16+
docs/puml/img
17+
18+
# ignore runs and related artifacts
19+
**/runs/
20+
**/*.lt
21+
22+
# ignore notebooks not part of the official docs
23+
**/ntbks/

README.md

+9-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ lambeq is a toolkit for quantum natural language processing (QNLP).
1515
- Documentation: https://cqcl.github.io/lambeq/
1616
- User support: <lambeq-support@cambridgequantum.com>
1717
- Contributions: Please read [our guide](https://cqcl.github.io/lambeq/CONTRIBUTING.html).
18-
- If you want to subscribe to lambeq's mailing list, let us know by sending an email to <lambeq-support@cambridgequantum.com>.
18+
- If you want to subscribe to lambeq's mailing list, let us know by sending an email to <lambeq-support@cambridgequantum.com>.
1919

2020
---
2121
**Note:** Please do not try to read the documentation directly from the preview provided in the [repository](https://github.com/CQCL/lambeq/tree/main/docs), since some of the pages will not be rendered properly.
@@ -42,9 +42,14 @@ To install lambeq with optional dependencies for extra features, run:
4242
pip install lambeq[extras]
4343
```
4444

45-
To enable depccg support, you will need to install depccg separately. More information can be found
46-
on the [depccg homepage](//github.com/masashi-y/depccg).
47-
Currently, only version 2.0.3.2 of depccg is supported. After installing depccg, you can download its model by using the script provided in the `contrib` folder of this repository:
45+
To enable DepCCG support, you will need to install the external parser separately.
46+
47+
---
48+
**Note:** The DepCCG-related functionality is no longer actively supported in `lambeq`, and may not work as expected. We strongly recommend using the default Bobcat parser which comes as part of `lambeq`.
49+
50+
---
51+
52+
If you still want to use DepCCG, for example because you plan to apply ``lambeq`` on Japanese, you can install DepCCG separately following the instructions on the [DepCCG homepage](//github.com/masashi-y/depccg). After installing DepCCG, you can download its model by using the script provided in the `contrib` folder of this repository:
4853

4954
```bash
5055
python contrib/download_depccg_model.py

docs/CONTRIBUTING.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,5 @@ Please be polite and respectful in any form of communication you have with other
6262

6363
- :ref:`General information about sub-packages <sec-package-api>`
6464
- :ref:`UML diagrams for sub-packages <uml-diagrams>`
65+
- `"low-level lambeq" tutorial <advanced.rst>`_
6566
- `"Extending lambeq" tutorial <tutorials/extend-lambeq.ipynb>`_
66-
- `"DisCoPy usage" tutorial <advanced.rst>`_

docs/_static/images/comm-diagram.png

34.7 KB
Loading

docs/_static/images/linear.png

121 KB
Loading

docs/_static/images/snake-2.png

4.06 KB
Loading

docs/_static/images/snake.png

3.29 KB
Loading

docs/advanced.rst

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
.. _sec-advanced:
22

3-
Advanced: DisCoPy usage
4-
=======================
3+
Advanced: low-level lambeq
4+
==========================
55

6-
To understand ``lambeq`` in further depth, it is necessary to familiarise yourself with :ref:`sec-discopy`, the underlying library used for manipulating :term:`monoidal categories <monoidal category>`. After these tutorials, you will have the necessary knowledge to contribute to ``lambeq`` and DisCoPy.
6+
To understand ``lambeq`` in further depth, it is necessary to familiarise yourself with the low-level :py:mod:`lambeq.backend` module and its :ref:`available classes and methods <api_backend>`.
7+
8+
After these tutorials, you will have the necessary knowledge to contribute to ``lambeq``.
79

810
.. toctree::
911

docs/bibliography.rst

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ Bibliography
1515
1616
.. [GL2012] F. Gao, H. Lixing. `Implementing the Nelder-Mead Simplex Algorithm with Adaptive Parameters <https://link.springer.com/article/10.1007/s10589-010-9329-3>`_, `Computational Optimization and Applications`,` 51. 259-277.10.1007/s10589-010-9329-3, 2012
1717
18+
.. [Hea2019] V. Havlíček, A. Córcoles, K. Temme, A. Harrow, A. Kandala, J. Chow, J. Gambetta. `Supervised Learning with Quantum-Enhanced Feature Spaces <https://www.nature.com/articles/s41586-019-0980-2>`_. `Nature`, 567, 2019
19+
1820
.. [HS2007] J. Hockenmaier, M. Steedman. `CCGbank: A Corpus of CCG Derivations and Dependency Structures Extracted from the Penn Treebank <https://aclanthology.org/J07-3004.pdf>`_, `Computational Linguistics, Volume 33, Number 3`, September 2007
1921
2022
.. [HV2013] C. Heunen, J. Vicary. `Introduction to Categorical Quantum Mechanics <http://www.cs.ox.ac.uk/people/jamie.vicary/IntroductionToCategoricalQuantumMechanics.pdf>`_, `Course Notes`, Oxford University, 2013

docs/cli.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ Note that the order of the types in the new diagram has been changed in a way th
169169
The ``pregroups`` mode trades off diagrammatic simplicity and conformance to a formal pregroup grammar for a larger vocabulary, since each word is associated with more types than before and new words (combined tokens) are added to the vocabulary. Depending on the size of your dataset, this might lead to data sparsity problems during training.
170170

171171
.. Note::
172-
To convert a string diagram into a strict pregroup diagram programmatically, one can use the :py:meth:`~lambeq.remove_swaps` method.
172+
To convert a string diagram into a strict pregroup diagram programmatically, one can use the :py:class:`.RemoveSwapsRewriter` class.
173173

174174
Using a reader
175175
--------------
@@ -227,7 +227,7 @@ For the classical case, applying a :py:class:`.SpiderAnsatz` with 2 dimensions a
227227
Other options
228228
-------------
229229

230-
To store the :term:`DisCoPy` (for string diagrams) or the :py:class:`.CCGTree` objects (for the CCG trees) in ``json`` or ``pickle`` format, type:
230+
To store the :py:class:`lambeq.backend.grammar.Diagram` (for string diagrams) or the :py:class:`.CCGTree` objects (for the CCG trees) in ``json`` or ``pickle`` format, type:
231231

232232
.. code-block:: console
233233

docs/conf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626

2727
project = 'lambeq'
28-
copyright = '2021-2023 Cambridge Quantum Computing Ltd.'
28+
copyright = '2021-2024 Cambridge Quantum Computing Ltd.'
2929
author = 'Cambridge Quantum QNLP Dev Team'
3030

3131
# -- General configuration ---------------------------------------------------

docs/discopy.rst

-13
This file was deleted.

0 commit comments

Comments
 (0)