Skip to content

GehadSalemFekry/QuantumNLP-Quantinuum-Quriosity

 
 

Repository files navigation

Quantum Natural Language Processing with lambeq --> by Quantinuum

Womanium Quantum Hackathon 2022

Data:

Summary:

The goal of the project is to create a quantum model that takes two sentences and responds with the similarity between them (1 for similar, 0 for not similar), and similarity is defined to be as being of the same topic. The data provided was only using statements either related to food or it, but the model could then be extended when having a larger dataset with different topics.

We first tried to get a general overview of the data and what are its different characteristics; we used the wordcloud package to visualize the data based on the frequency of the different words presented to get a general idea of what is included and what to expect.

After that, we parsed the sentences into diagrams; we chose the BobcatParser from lambeq as it is a parser so has some grammar rules built in, unlike other readers that only read data into diagrams without any grammar linked to the diagrams.

Then, we transformed the diagrams into circuits using IQPAnsatz while also removing cups in the diagrams to reduce the number of computations so, increasing the performance of the model.

In this stage, we were in need of a model that could perform the sentence comparison, so we built our own by inheriting from NumpyModel and editing its forward function by adding a similarity metric (an inner product for both sentences. Additionally, we defined the loss and accuracy metrics needed for training the model.

Then, we trained the model over a portion of the dataset (80%) so to validate and test with the other 20%. And at the end visualized the results we got from the training.

Future improvements:

  • Create circuit reader function that is able to read each element but then we include it in the opposite order.
  • Implement a better similarity metric.
  • Train the model using AerBackend
  • Having a bigger dataset

About

Womanium Quantum Hackathon 2022 - Team Quriosity

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Jupyter Notebook 100.0%