https://github.com/cqcl/lambeq
A high-level Python library for Quantum Natural Language Processing
https://github.com/cqcl/lambeq
python qnlp
Last synced: 10 months ago
JSON representation
A high-level Python library for Quantum Natural Language Processing
- Host: GitHub
- URL: https://github.com/cqcl/lambeq
- Owner: CQCL
- License: apache-2.0
- Created: 2021-10-10T16:38:24.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2025-03-24T14:37:27.000Z (10 months ago)
- Last Synced: 2025-03-31T15:08:28.999Z (10 months ago)
- Topics: python, qnlp
- Language: Python
- Homepage: https://docs.quantinuum.com/lambeq/
- Size: 32.5 MB
- Stars: 476
- Watchers: 30
- Forks: 118
- Open Issues: 27
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# λambeq

[](LICENSE)
[](//pypi.org/project/lambeq)
[](//pypi.org/project/lambeq)
[](//arxiv.org/abs/2110.04236)
## About
lambeq is a toolkit for quantum natural language processing (QNLP).
- Documentation: https://docs.quantinuum.com/lambeq/.
- User support: .
- Contributions: Please read [our guide](https://docs.quantinuum.com/lambeq/CONTRIBUTING.html).
- If you want to subscribe to lambeq's mailing list, let us know by sending an email to .
## Getting started
### Prerequisites
- Python 3.10+
### Installation
lambeq can be installed with the command:
```bash
pip install lambeq
```
The default installation of lambeq includes Bobcat parser, a state-of-the-art statistical parser (see [related paper](https://arxiv.org/abs/2109.10044)) fully integrated with the toolkit.
To install lambeq with optional dependencies for extra features, run:
```bash
pip install lambeq[extras]
```
To install lambeq with optional dependencies for experimental features, run:
```bash
pip install lambeq[experimental]
```
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
```
## Usage
The [docs/examples](//github.com/CQCL/lambeq-docs/tree/main/docs/examples)
directory in lambeq's [documentation repository](https://github.com/CQCL/lambeq-docs) contains notebooks demonstrating usage of the various tools in lambeq.
Example - parsing a sentence into a diagram (see
[docs/examples/parser.ipynb](//github.com/CQCL/lambeq-docs/blob/main/docs/examples/parser.ipynb)):
```python
from lambeq import BobcatParser
parser = BobcatParser()
diagram = parser.sentence2diagram('This is a test sentence')
diagram.draw()
```
## Testing
Run all tests with the command:
```bash
pytest
```
Note: if you have installed lambeq in a virtual environment, remember to
install pytest in the same environment using pip.
## License
Distributed under the Apache 2.0 license. See [`LICENSE`](LICENSE) for
more details.
## Citation
If you wish to attribute our work, please cite
[the accompanying paper](//arxiv.org/abs/2110.04236):
```
@article{kartsaklis2021lambeq,
title={lambeq: {A}n {E}fficient {H}igh-{L}evel {P}ython {L}ibrary for {Q}uantum {NLP}},
author={Dimitri Kartsaklis and Ian Fan and Richie Yeung and Anna Pearson and Robin Lorenz and Alexis Toumi and Giovanni de Felice and Konstantinos Meichanetzidis and Stephen Clark and Bob Coecke},
year={2021},
journal={arXiv preprint arXiv:2110.04236},
}
```