Skip to content

Latest commit

 

History

History
77 lines (45 loc) · 2.01 KB

README.md

File metadata and controls

77 lines (45 loc) · 2.01 KB

NLU (aka Natural Language Understanding)

We build a very simple, lightweight intent classifier. Aimed to be comfortably run in a Raspberry Pi 3b 🍓

The original pipeline can be found in this Colab Notebook

📐 Classifier (intent prediction)

🧬 Data Encoding

💡 We use a LabelEncoder which maps classes to integer indices

💡 We use Spacy to embed sentences into continuous vector space

📤 CRF (entity extraction)

We use sklearn-crfsuite to extract entities.

💡 To know more check its documentation!

How To

Install

Installing Spacy can be challenging in an Raspberry Pi. The advice is either to cross-compile or to use pre-built wheels.

Blis and Spacy wheels can be found here

Alternatively you can cross-compile / build your own:

Click to expand!

Building the blis, spacy or numpy wheels in the RPI can be a painfully slow process so to avoid the suffering a possible solution is to cross-compile using docker buildx.

The steps are as follows:

  1. Install buildx

You can use this script

  1. Run docker build (in a work-station, not in the RPI!):
docker buildx build --push \
  --platform linux/arm/v7 \
  -t jmrf/simple-nlu-rpi:cp37 \
  -f Dockerfile .
  1. Run the container (in the RPI)

    docker run -it --entrypoint /bin/bash jmrf/numpy-rpi:py37-np1.21.6

    In another terminal:

    docker container ls  # copy the container ID
    
    # Copy the wheels back to the target system
    docker cp <your-container-ID>:/numpy/dist/numpy-1.21.6-cp37-cp37m-linux_armv7l.whl .
    pip install numpy-1.21.6-cp37-cp37m-linux_armv7l.whl