Skip to content

Commit

Permalink
Release version 0.4.0
Browse files Browse the repository at this point in the history
Co-authored-by: Ian Fan <[email protected]>
Co-authored-by: Dimitri Kartsaklis <[email protected]>
Co-authored-by: Nikhil Khatri <[email protected]>
Co-authored-by: Neil Ortega <[email protected]>
  • Loading branch information
5 people committed Jan 11, 2024
1 parent 5da6a54 commit 19da7cd
Show file tree
Hide file tree
Showing 196 changed files with 18,277 additions and 7,312 deletions.
35 changes: 2 additions & 33 deletions .github/workflows/build_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,37 +79,6 @@ jobs:
--durations=50
--ignore=${{ env.TEST_DIR }}/text2diagram/test_depccg_parser.py
--ignore=${{ env.DOCS_DIR }}/extract_code_cells.py
- name: Determine if depccg tests should be run
# only test depccg if it is explicitly changed, since it is very slow
# tests are also disabled on Python 3.11
id: depccg-enabled
continue-on-error: true # this is expected to fail but the job should still succeed
run: >
${{ matrix.python-version != '3.11' }}
&& git fetch --depth=1 origin ${{ github.base_ref || github.event.before }}:before
&& git diff --name-only before | grep depccg
- name: Install depccg and locate depccg pre-trained model cache
id: loc-depccg-cache
if: steps.depccg-enabled.outcome == 'success'
run: |
pip install cython # must be installed before depccg
pip install depccg==2.0.3.2
echo "dir=$(python -c 'from depccg.instance_models import MODEL_DIRECTORY, MODELS; print(MODEL_DIRECTORY / MODELS["en"][1])')" >> $GITHUB_OUTPUT
pip install lambeq # override dependency conflicts
- name: Restore depccg pre-trained model from cache
id: depccg-cache
if: steps.depccg-enabled.outcome == 'success'
uses: actions/cache@v2
with:
path: ${{ steps.loc-depccg-cache.outputs.dir }}
key: depccg
- name: Download depccg pre-trained model if needed
if: steps.depccg-enabled.outcome == 'success' && steps.depccg-cache.outputs.cache-hit != 'true'
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)'
- name: Test DepCCGParser
if: steps.depccg-enabled.outcome == 'success'
continue-on-error: true
run: coverage run --append --source=${{ env.SRC_DIR }} -m pytest -k test_depccg_parser.py
- name: Preparation for notebook testing
run: pip install nbmake
- name: Test example notebooks
Expand Down Expand Up @@ -141,9 +110,9 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies with type hints
run: python -m pip install numpy pytket spacy torch types-PyYAML
run: python -m pip install numpy pytket spacy torch types-PyYAML types-Pillow ipython
- name: Install type checker
run: python -m pip install mypy==1.3.0 # unpin when newer version works
run: python -m pip install mypy
- name: Type check with mypy
run: mypy ${{ env.SRC_DIR }}
- name: View strict type errors
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:

env:
WORKFLOWS_DIR: .github/workflows
DOCS_DIR: docs

jobs:
docs:
Expand All @@ -29,6 +30,10 @@ jobs:
run: |
sudo apt-get install graphviz pandoc
pip install -r docs/requirements.txt
- name: Draw diagrams from PlantUML files
uses: Timmy/plantuml-action@v1
with:
args: '-v -DPLANTUML_LIMIT_SIZE=8192 -tpng ${{ env.DOCS_DIR }}/puml/*.puml -o img'
- name: Build documentation
run: ${{ env.WORKFLOWS_DIR }}/build-docs
- name: Deploy documentation
Expand Down
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,11 @@ htmlcov/
# ignore the built documentation
docs/_*
!docs/_static/
docs/puml/img

# ignore runs and related artifacts
**/runs/
**/*.lt

# ignore notebooks not part of the official docs
**/ntbks/
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ lambeq is a toolkit for quantum natural language processing (QNLP).
- Documentation: https://cqcl.github.io/lambeq/
- User support: <[email protected]>
- Contributions: Please read [our guide](https://cqcl.github.io/lambeq/CONTRIBUTING.html).
- If you want to subscribe to lambeq's mailing list, let us know by sending an email to <[email protected]>.
- If you want to subscribe to lambeq's mailing list, let us know by sending an email to <[email protected]>.

---
**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.
Expand All @@ -42,9 +42,14 @@ To install lambeq with optional dependencies for extra features, run:
pip install lambeq[extras]
```

To enable depccg support, you will need to install depccg separately. More information can be found
on the [depccg homepage](//github.com/masashi-y/depccg).
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:
To enable DepCCG support, you will need to install the external parser separately.

---
**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`.

---

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:

```bash
python contrib/download_depccg_model.py
Expand Down
2 changes: 1 addition & 1 deletion docs/CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,5 @@ Please be polite and respectful in any form of communication you have with other

- :ref:`General information about sub-packages <sec-package-api>`
- :ref:`UML diagrams for sub-packages <uml-diagrams>`
- `"low-level lambeq" tutorial <advanced.rst>`_
- `"Extending lambeq" tutorial <tutorials/extend-lambeq.ipynb>`_
- `"DisCoPy usage" tutorial <advanced.rst>`_
Binary file added docs/_static/images/comm-diagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/images/linear.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/images/snake-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/images/snake.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 5 additions & 3 deletions docs/advanced.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
.. _sec-advanced:

Advanced: DisCoPy usage
=======================
Advanced: low-level lambeq
==========================

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.
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>`.

After these tutorials, you will have the necessary knowledge to contribute to ``lambeq``.

.. toctree::

Expand Down
2 changes: 2 additions & 0 deletions docs/bibliography.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ Bibliography
.. [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
.. [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
.. [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
.. [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
Expand Down
4 changes: 2 additions & 2 deletions docs/cli.rst
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ Note that the order of the types in the new diagram has been changed in a way th
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.

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

Using a reader
--------------
Expand Down Expand Up @@ -227,7 +227,7 @@ For the classical case, applying a :py:class:`.SpiderAnsatz` with 2 dimensions a
Other options
-------------

To store the :term:`DisCoPy` (for string diagrams) or the :py:class:`.CCGTree` objects (for the CCG trees) in ``json`` or ``pickle`` format, type:
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:

.. code-block:: console
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@


project = 'lambeq'
copyright = '2021-2023 Cambridge Quantum Computing Ltd.'
copyright = '2021-2024 Cambridge Quantum Computing Ltd.'
author = 'Cambridge Quantum QNLP Dev Team'

# -- General configuration ---------------------------------------------------
Expand Down
13 changes: 0 additions & 13 deletions docs/discopy.rst

This file was deleted.

Loading

0 comments on commit 19da7cd

Please sign in to comment.