Skip to main content

This repository contains an easy and intuitive approach to zero-shot and few-shot NER using internal spaCy embeddings.

Project description

Concise Concepts

When wanting to apply NER to concise concepts, it is really easy to come up with examples, but it takes some time to train an entire pipeline. Concise Concepts uses word similarity based on few-shots to get you going with easy!

Install

pip install classy-classification

Quickstart

import spacy
import concise_concepts

data = {
    "fruit": ["apple", "pear", "orange"],
    "vegetable": ["broccoli", "spinach", "tomato"],
    "meat": ["chicken", "beef", "pork", "fish", "lamb"]
}

text = """
    Heat the oil in a large pan and add the Onion, celery and carrots. 
    Then, cook over a medium–low heat for 10 minutes, or until softened. 
    Add the courgette, garlic, red peppers and oregano and cook for 2–3 minutes.
    Later, add some oranges and chickens. """

nlp = spacy.load(\"en_core_web_lg\")
nlp.add_pipe("concise_concepts", config={"data": data})
doc = nlp(text)

print([(ent.text, ent.label_) for ent in doc.ents])
# Output:
#
# [(\"Onion\", \"VEGETABLE\"), (\"Celery\", \"VEGETABLE\"), (\"carrots\", \"VEGETABLE\"), 
#  (\"garlic\", \"VEGETABLE\"), (\"red peppers\", \"VEGETABLE\"), (\"oranges\", \"FRUIT\"), 
#  (\"chickens\", \"MEAT\")]

## use specific number of words to expand over

data = { "fruit": ["apple", "pear", "orange"], "vegetable": ["broccoli", "spinach", "tomato"], "meat": ["chicken", "beef", "pork", "fish", "lamb"] }

topn = [50, 50, 150]

assert len(topn) == len(data)

nlp.add_pipe("concise_concepts", config={"data": data, "topn": topn})



Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

concise-concepts-0.2.0.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

concise_concepts-0.2.0-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file concise-concepts-0.2.0.tar.gz.

File metadata

  • Download URL: concise-concepts-0.2.0.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.8.2 Windows/10

File hashes

Hashes for concise-concepts-0.2.0.tar.gz
Algorithm Hash digest
SHA256 c4e736c8de8f20ff33b3c33024d52ea3d8af348ea9e90ae964de90950a3ccf2c
MD5 cd23a551a57c2bc6eca26849e39db0a2
BLAKE2b-256 af556d7842e1ca073f8e60e5096ed7cd8379e146e2ec434cc5a2d45a86aa1ec6

See more details on using hashes here.

File details

Details for the file concise_concepts-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for concise_concepts-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 711104047950ba76b94655a9371de2ce21a50a34bef2e63816e085a8d5a0bf56
MD5 585f847e416afebf257aeabf55f296f9
BLAKE2b-256 23e47dd2cdc79142f34989d3a70382df8022f069bef287fbc5e727baf05cce1c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page