A Lightweight Conditional Random Field
Project description
Chaine
A linear-chain conditional random field implementation.
Chaine is a modern Python library without any third-party dependencies and a backend written in C implementing conditional random fields for natural language processing tasks like named entity recognition or part-of-speech tagging.
- Lightweight: explain
- Fast: explain
- Easy to use: explain
You can install the latest stable version from PyPI:
$ pip install chaine
If you are interested in the theoretical concepts behind conditional random fields, refer to the introducing paper by Lafferty et al.
How it works
>>> import chaine
>>> tokens = [["John", "Lennon", "was", "rhythm", "guitarist" "of", "The", "Beatles"]]
>>> labels = [["B-PER", "I-PER", "O", "O", "O", "O", "B-ORG", "I-ORG"]]
>>> model = chaine.train(tokens, labels, max_iterations=5)
Loading data
Start training
Iteration 1, train loss: 14.334076
Iteration 2, train loss: 14.334064
Iteration 3, train loss: 14.334053
Iteration 4, train loss: 14.334041
Iteration 5, train loss: 14.334029
>>> model.predict(tokens)
[['B-PER', 'I-PER', 'O', 'O', 'O', 'B-ORG', 'I-ORG']]
Check out the introducing Jupyter notebook.
Credits
This library makes use of and is partially based on:
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
chaine-0.2.1.tar.gz
(116.4 kB
view hashes)
Built Distributions
Close
Hashes for chaine-0.2.1-cp39-cp39-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b6bca31b7ccea6ff7f757950ba283c48ae029858549f27fb85239006dcbe1762 |
|
MD5 | 18a9372e576daa57aebd4d2954c4f985 |
|
BLAKE2b-256 | 2aa17b59e02c95343876459c50a857ee31bcb977f118934e9d2dfcfb86587bb3 |
Close
Hashes for chaine-0.2.1-cp38-cp38-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 57da50a991ab784bff09975982fa0a43de0f555d7aa86c7eeff515cd000c7516 |
|
MD5 | 8ed2e6583690b9980bc48386e4ea9d05 |
|
BLAKE2b-256 | 4b84be8910fefc905e3972d8edd997a31eb4b1e64decde2b87c2e0ab21c19e22 |