This repository contains an easy and intuitive approach to few-shot NER using most similar expansion over spaCy embeddings.
Project description
Concise Concepts
When wanting to apply NER to concise concepts, it is really easy to come up with examples, but pretty difficult to train an entire pipeline. Concise Concepts uses few-shot NER based on word embedding similarity 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": ["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": ["beef", "pork", "fish", "lamb"]
}
topn = [50, 50, 150]
assert len(topn) == len
nlp.add_pipe("concise_concepts", config={"data": data, "topn": topn})
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file concise-concepts-0.2.2.tar.gz
.
File metadata
- Download URL: concise-concepts-0.2.2.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.12 CPython/3.8.2 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f9f42266de801479ed81012bd4ccc1a5f521c1b98d3d18cfa1ac971e1b757270 |
|
MD5 | 744ef84d53317f0efc02304dcc05e249 |
|
BLAKE2b-256 | 2eee7425151d20a668d9653b3b8bce7b18f8c2d9d94366537842b8348cd6b601 |
File details
Details for the file concise_concepts-0.2.2-py3-none-any.whl
.
File metadata
- Download URL: concise_concepts-0.2.2-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.12 CPython/3.8.2 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c94f74cc5e3c70825562370e10a29ab3334b9e80cd1436070207a4f6e3b4cd01 |
|
MD5 | 975cec8b1aea4e019f4475018878ed17 |
|
BLAKE2b-256 | f4d23ac335a6dc86ce833e47a75e19271a03f7bb8208634394c021d68f198486 |