Git Product home page Git Product logo

lambeq's Introduction

lambeq

lambeq logo

Build status License PyPI version PyPI downloads arXiv

About

lambeq is a toolkit for quantum natural language processing (QNLP).

Documentation: https://cqcl.github.io/lambeq/

Getting started

Prerequisites

  • Python 3.7+

Installation

Direct pip install

The base lambeq can be installed with the command:

pip install lambeq

This does not include optional dependencies such as depccg and PyTorch, which have to be installed separately. In particular, depccg is required for lambeq.ccg2discocat.DepCCGParser.

To install lambeq with depccg, run instead:

pip install cython numpy
pip install lambeq[depccg]
depccg_en download

See below for further options.

Automatic installation (recommended)

This runs an interactive installer to help pick the installation destination and configuration.

  1. Run:
    bash <(curl 'https://cqcl.github.io/lambeq/install.sh')

Git installation

This required Git to be installed.

  1. Download this repository:

    git clone https://github.com/CQCL/lambeq
  2. Enter the repository:

    cd lambeq
  3. Make sure pip is up-to-date:

    pip install --upgrade pip wheel
  4. (Optional) If installing the optional dependency depccg, the following packages must be installed before installing depccg:

    pip install cython numpy

    Further information can be found on the depccg homepage.

  5. Install lambeq from the local repository using pip:

    pip install --use-feature=in-tree-build .

    To include depccg, run instead:

    pip install --use-feature=in-tree-build .[depccg]

    To include all optional dependencies, run instead:

    pip install --use-feature=in-tree-build .[all]
  6. If using a pretrained depccg parser, download a pretrained model:

    depccg_en download

Usage

The docs/examples directory contains notebooks demonstrating usage of the various tools in lambeq.

Example - parsing a sentence into a diagram (see docs/examples/ccg2discocat.ipynb):

from lambeq.ccg2discocat import DepCCGParser

depccg_parser = DepCCGParser()
diagram = depccg_parser.sentence2diagram('This is a test sentence')
diagram.draw()

Note: all pre-trained depccg models apart from the basic one are broken, and depccg has not yet been updated to fix this. Therefore, it is recommended to just use the basic parser, as shown here.

Testing

Run all tests with the command:

pytest

Note: if you have installed in a virtual environment, remember to install pytest in the same environment using pip.

Building Documentation

To build the documentation, first install the required dependencies:

pip install -r docs/requirements.txt

then run the commands:

cd docs
make clean
make html

the docs will be under docs/_build.

To rebuild the rst files themselves, run:

sphinx-apidoc --force -o docs lambeq

License

Distributed under the Apache 2.0 license. See LICENSE for more details.

Citation

If you wish to attribute our work, please cite the accompanying paper:

@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},
}

lambeq's People

Contributors

ianyfan avatar dimkart avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.