severinsimmler / chaine Goto Github PK
View Code? Open in Web Editor NEWLinear-chain conditional random fields (CRF) for natural language processing
Home Page: https://severinsimmler.github.io/chaine
Linear-chain conditional random fields (CRF) for natural language processing
Home Page: https://severinsimmler.github.io/chaine
The restrictions for input data are to loose, something like the following is allowed:
>>> import chaine
>>> tokens = [["John", "Lennon", "was", "born", "in", "Liverpool"]]
>>> labels = [["B-PER", "I-PER", "O", "O", "O", "B-LOC"]]
>>> model = chaine.train(tokens, labels, max_iterations=5)
>>> model.predict(["John", "Lennon", "was", "born", "in", "Liverpool"])
[['O', 'O', 'O', 'O'], ['O', 'O', 'O', 'O', 'O', 'O'], ['O', 'O', 'O'], ['O', 'O', 'O', 'O'], ['O', 'O'], ['O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O']]
This human error, where the person forgot the outer brackets, leads to bad predictions. The "correct code" would be:
>>> import chaine
>>> tokens = [["John", "Lennon", "was", "born", "in", "Liverpool"]]
>>> labels = [["B-PER", "I-PER", "O", "O", "O", "B-LOC"]]
>>> model = chaine.train(tokens, labels, max_iterations=5)
>>> model.predict([["John", "Lennon", "was", "born", "in", "Liverpool"]])
[['B-PER', 'I-PER', 'O', 'O', 'O', 'B-LOC']]
Similar to Hidden Markov Models
Like #12, only the other way round
macOS Catalina 10.15.7
jan@iMac:~$ pip3.9 install chaine
Collecting chaine
Using cached chaine-0.1.0.tar.gz (7.8 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing wheel metadata ... done
Building wheels for collected packages: chaine
Building wheel for chaine (PEP 517) ... error
ERROR: Command errored out with exit status 1:
command: /usr/local/opt/[email protected]/bin/python3.9 /usr/local/lib/python3.9/site-packages/pip/_vendor/pep517/_in_process.py build_wheel /var/folders/y9/8ddvkkvs3r783w2v7l_hnm2c0000gn/T/tmpnfwxnwmi
cwd: /private/var/folders/y9/8ddvkkvs3r783w2v7l_hnm2c0000gn/T/pip-install-8m0zcihl/chaine
Complete output (50 lines):
A setup.py file already exists. Using it.
warning: chaine/crfsuite_api.pxd:53:4: 'messagefunc' redeclared
running build
running build_py
creating /private/var/folders/y9/8ddvkkvs3r783w2v7l_hnm2c0000gn/T/pip-install-8m0zcihl/chaine/build
creating /private/var/folders/y9/8ddvkkvs3r783w2v7l_hnm2c0000gn/T/pip-install-8m0zcihl/chaine/build/lib.macosx-10.15-x86_64-3.9
creating /private/var/folders/y9/8ddvkkvs3r783w2v7l_hnm2c0000gn/T/pip-install-8m0zcihl/chaine/build/lib.macosx-10.15-x86_64-3.9/chaine
copying chaine/__init__.py -> /private/var/folders/y9/8ddvkkvs3r783w2v7l_hnm2c0000gn/T/pip-install-8m0zcihl/chaine/build/lib.macosx-10.15-x86_64-3.9/chaine
copying chaine/core.py -> /private/var/folders/y9/8ddvkkvs3r783w2v7l_hnm2c0000gn/T/pip-install-8m0zcihl/chaine/build/lib.macosx-10.15-x86_64-3.9/chaine
copying chaine/utils.py -> /private/var/folders/y9/8ddvkkvs3r783w2v7l_hnm2c0000gn/T/pip-install-8m0zcihl/chaine/build/lib.macosx-10.15-x86_64-3.9/chaine
copying chaine/typing.py -> /private/var/folders/y9/8ddvkkvs3r783w2v7l_hnm2c0000gn/T/pip-install-8m0zcihl/chaine/build/lib.macosx-10.15-x86_64-3.9/chaine
copying chaine/data.py -> /private/var/folders/y9/8ddvkkvs3r783w2v7l_hnm2c0000gn/T/pip-install-8m0zcihl/chaine/build/lib.macosx-10.15-x86_64-3.9/chaine
copying chaine/trainer_wrapper.hpp -> /private/var/folders/y9/8ddvkkvs3r783w2v7l_hnm2c0000gn/T/pip-install-8m0zcihl/chaine/build/lib.macosx-10.15-x86_64-3.9/chaine
copying chaine/model.pyx -> /private/var/folders/y9/8ddvkkvs3r783w2v7l_hnm2c0000gn/T/pip-install-8m0zcihl/chaine/build/lib.macosx-10.15-x86_64-3.9/chaine
copying chaine/tagger_wrapper.hpp -> /private/var/folders/y9/8ddvkkvs3r783w2v7l_hnm2c0000gn/T/pip-install-8m0zcihl/chaine/build/lib.macosx-10.15-x86_64-3.9/chaine
copying chaine/model.cpp -> /private/var/folders/y9/8ddvkkvs3r783w2v7l_hnm2c0000gn/T/pip-install-8m0zcihl/chaine/build/lib.macosx-10.15-x86_64-3.9/chaine
copying chaine/crfsuite_api.pxd -> /private/var/folders/y9/8ddvkkvs3r783w2v7l_hnm2c0000gn/T/pip-install-8m0zcihl/chaine/build/lib.macosx-10.15-x86_64-3.9/chaine
copying chaine/trainer_wrapper.cpp -> /private/var/folders/y9/8ddvkkvs3r783w2v7l_hnm2c0000gn/T/pip-install-8m0zcihl/chaine/build/lib.macosx-10.15-x86_64-3.9/chaine
running build_ext
building 'chaine.model' extension
creating /private/var/folders/y9/8ddvkkvs3r783w2v7l_hnm2c0000gn/T/pip-install-8m0zcihl/chaine/build/temp.macosx-10.15-x86_64-3.9
creating /private/var/folders/y9/8ddvkkvs3r783w2v7l_hnm2c0000gn/T/pip-install-8m0zcihl/chaine/build/temp.macosx-10.15-x86_64-3.9/chaine
creating /private/var/folders/y9/8ddvkkvs3r783w2v7l_hnm2c0000gn/T/pip-install-8m0zcihl/chaine/build/temp.macosx-10.15-x86_64-3.9/chaine/crfsuite
creating /private/var/folders/y9/8ddvkkvs3r783w2v7l_hnm2c0000gn/T/pip-install-8m0zcihl/chaine/build/temp.macosx-10.15-x86_64-3.9/chaine/crfsuite/lib
creating /private/var/folders/y9/8ddvkkvs3r783w2v7l_hnm2c0000gn/T/pip-install-8m0zcihl/chaine/build/temp.macosx-10.15-x86_64-3.9/chaine/crfsuite/lib/cqdb
creating /private/var/folders/y9/8ddvkkvs3r783w2v7l_hnm2c0000gn/T/pip-install-8m0zcihl/chaine/build/temp.macosx-10.15-x86_64-3.9/chaine/crfsuite/lib/cqdb/src
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers -Ichaine/crfsuite/include/ -Ichaine/crfsuite/lib/cqdb/include -Ichaine/liblbfgs/include -Ichaine -I/usr/local/include -I/usr/local/opt/[email protected]/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/[email protected]/3.9.0_2/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c -std=c99 chaine/crfsuite/lib/cqdb/src/cqdb.c -o /private/var/folders/y9/8ddvkkvs3r783w2v7l_hnm2c0000gn/T/pip-install-8m0zcihl/chaine/build/temp.macosx-10.15-x86_64-3.9/chaine/crfsuite/lib/cqdb/src/cqdb.o
clang: error: no such file or directory: 'chaine/crfsuite/lib/cqdb/src/cqdb.c'
clang: error: no input files
error: command '/usr/bin/clang' failed with exit code 1
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/pip/_vendor/pep517/_in_process.py", line 280, in <module>
main()
File "/usr/local/lib/python3.9/site-packages/pip/_vendor/pep517/_in_process.py", line 263, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "/usr/local/lib/python3.9/site-packages/pip/_vendor/pep517/_in_process.py", line 204, in build_wheel
return _build_backend().build_wheel(wheel_directory, config_settings,
File "/private/var/folders/y9/8ddvkkvs3r783w2v7l_hnm2c0000gn/T/pip-build-env-s4rurxcv/overlay/lib/python3.9/site-packages/poetry/core/masonry/api.py", line 57, in build_wheel
return unicode(WheelBuilder.make_in(poetry, Path(wheel_directory)))
File "/private/var/folders/y9/8ddvkkvs3r783w2v7l_hnm2c0000gn/T/pip-build-env-s4rurxcv/overlay/lib/python3.9/site-packages/poetry/core/masonry/builders/wheel.py", line 59, in make_in
wb.build()
File "/private/var/folders/y9/8ddvkkvs3r783w2v7l_hnm2c0000gn/T/pip-build-env-s4rurxcv/overlay/lib/python3.9/site-packages/poetry/core/masonry/builders/wheel.py", line 89, in build
self._build(zip_file)
File "/private/var/folders/y9/8ddvkkvs3r783w2v7l_hnm2c0000gn/T/pip-build-env-s4rurxcv/overlay/lib/python3.9/site-packages/poetry/core/masonry/builders/wheel.py", line 121, in _build
self._run_build_command(setup)
File "/private/var/folders/y9/8ddvkkvs3r783w2v7l_hnm2c0000gn/T/pip-build-env-s4rurxcv/overlay/lib/python3.9/site-packages/poetry/core/masonry/builders/wheel.py", line 149, in _run_build_command
subprocess.check_call(
File "/usr/local/Cellar/[email protected]/3.9.0_2/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 373, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/usr/local/Cellar/[email protected]/3.9.0_2/bin/python3.9', '/private/var/folders/y9/8ddvkkvs3r783w2v7l_hnm2c0000gn/T/pip-install-8m0zcihl/chaine/setup.py', 'build', '-b', '/private/var/folders/y9/8ddvkkvs3r783w2v7l_hnm2c0000gn/T/pip-install-8m0zcihl/chaine/build']' returned non-zero exit status 1.
----------------------------------------
ERROR: Failed building wheel for chaine
Failed to build chaine
ERROR: Could not build wheels for chaine which use PEP 517 and cannot be installed directly
When e.g. data is not in the correct format
We used to
chaine-1.1.0-cp38-cp38-manylinux2014_x86_64.whl
but now
chaine-1.1.1-cp38-cp38-manylinux_2_27_x86_64.whl
which seems to be broken on some machines.
It would be helpful to have an option to define the output path of the model.crf
.
For some reason the wheel build process fails for Python 3.10 on Windows: https://github.com/severinsimmler/chaine/runs/5529016996?check_suite_focus=true
Extend README
And update type hints
int
/float
features like this [1, 19, 4, 0, 0, 0]
are currently not supported by chaine
. crfsuite_api.hpp
only allows double
at the moment, see:
EDIT: string
types also work.
EDIT: float
types doesn't work.
And create a high-level Python module using the private module. I think this is best practice.
E.g. LabelSequence
as a pendant to TokenSequence
/Sequence
Think about real-world scenarios how the library might be used
Initial position:
Installing dependencies with poetry using poetry install
(on WSL Ubuntu).
Error:
error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1
Solution:
sudo apt-get install build-essential
Commit the C++ files
ImportError: /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.29' not found (required by /opt/hostedtoolcache/Python/3.8.6/x64/lib/python3.8/site-packages/chaine/crf.cpython-38-x86_64-linux-gnu.so)
Add POS tagger for realistic feature extraction: https://stanfordnlp.github.io/stanza/pos.html
Accept a callable instead of a string
Or something that displays loading data and current iteration + loss
warning: chaine/crfsuite_api.pxd:53:4: 'messagefunc' redeclared
chaine/crfsuite/lib/cqdb/src/cqdb.c: In function ‘cqdb_to_id’:
chaine/crfsuite/lib/cqdb/src/cqdb.c:600:26: warning: variable ‘ksize’ set but not used [-Wunused-but-set-variable]
600 | uint32_t ksize;
| ^~~~~
In file included from /usr/include/string.h:519,
from chaine/crfsuite/lib/cqdb/src/cqdb.c:37:
In function ‘strncpy’,
inlined from ‘cqdb_writer_close’ at chaine/crfsuite/lib/cqdb/src/cqdb.c:287:5:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:106:10: warning: ‘__builtin_strncpy’ output truncated before terminating nul copying 4 bytes from a string of the same length [-Wstringop-truncation]
106 | return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In function ‘strncpy’,
inlined from ‘cqdb_reader’ at chaine/crfsuite/lib/cqdb/src/cqdb.c:503:9:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:106:10: warning: ‘__builtin_strncpy’ specified bound 4 equals destination size [-Wstringop-truncation]
106 | return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from chaine/crfsuite/lib/crf/src/crf1d_context.c:47:
chaine/crfsuite/lib/crf/src/vecmath.h: In function ‘_aligned_malloc’:
chaine/crfsuite/lib/crf/src/vecmath.h:50:15: warning: implicit declaration of function ‘posix_memalign’ [-Wimplicit-function-declaration]
50 | int ret = posix_memalign(&p, alignment, size);
| ^~~~~~~~~~~~~~
chaine/crfsuite/lib/crf/src/crf1d_context.c: In function ‘crf1dc_new’:
chaine/crfsuite/lib/crf/src/crf1d_context.c:74:13: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
74 | if (ret = crf1dc_set_num_items(ctx, T))
| ^~~
chaine/crfsuite/lib/crf/src/crf1d_context.c: In function ‘crf1dc_score’:
chaine/crfsuite/lib/crf/src/crf1d_context.c:468:15: warning: unused variable ‘L’ [-Wunused-variable]
468 | const int L = ctx->num_labels;
| ^
chaine/crfsuite/lib/crf/src/crf1d_context.c:466:38: warning: unused variable ‘cur’ [-Wunused-variable]
466 | const floatval_t *state = NULL, *cur = NULL, *trans = NULL;
| ^~~
chaine/crfsuite/lib/crf/src/crf1d_encode.c: In function ‘crf1de_state_score’:
chaine/crfsuite/lib/crf/src/crf1d_encode.c:141:15: warning: unused variable ‘L’ [-Wunused-variable]
141 | const int L = crf1de->num_labels;
| ^
chaine/crfsuite/lib/crf/src/crf1d_encode.c: In function ‘crf1de_state_score_scaled’:
chaine/crfsuite/lib/crf/src/crf1d_encode.c:179:15: warning: unused variable ‘L’ [-Wunused-variable]
179 | const int L = crf1de->num_labels;
| ^
chaine/crfsuite/lib/crf/src/crf1d_encode.c: In function ‘crf1de_features_on_path’:
chaine/crfsuite/lib/crf/src/crf1d_encode.c:281:15: warning: unused variable ‘L’ [-Wunused-variable]
281 | const int L = crf1de->num_labels;
| ^
chaine/crfsuite/lib/crf/src/crf1d_encode.c:279:22: warning: unused variable ‘ctx’ [-Wunused-variable]
279 | crf1d_context_t *ctx = crf1de->ctx;
| ^~~
chaine/crfsuite/lib/crf/src/crf1d_encode.c: In function ‘crf1de_observation_expectation’:
chaine/crfsuite/lib/crf/src/crf1d_encode.c:340:15: warning: unused variable ‘L’ [-Wunused-variable]
340 | const int L = crf1de->num_labels;
| ^
chaine/crfsuite/lib/crf/src/crf1d_encode.c:338:22: warning: unused variable ‘ctx’ [-Wunused-variable]
338 | crf1d_context_t *ctx = crf1de->ctx;
| ^~~
chaine/crfsuite/lib/crf/src/crf1d_encode.c: In function ‘crf1de_model_expectation’:
chaine/crfsuite/lib/crf/src/crf1d_encode.c:397:41: warning: unused variable ‘trans’ [-Wunused-variable]
397 | const feature_refs_t *attr = NULL, *trans = NULL;
| ^~~~~
chaine/crfsuite/lib/crf/src/crf1d_encode.c: In function ‘crf1de_set_data’:
chaine/crfsuite/lib/crf/src/crf1d_encode.c:449:13: warning: variable ‘begin’ set but not used [-Wunused-but-set-variable]
449 | clock_t begin = 0;
| ^~~~~
chaine/crfsuite/lib/crf/src/crf1d_encode.c: In function ‘crf1de_save_model’:
chaine/crfsuite/lib/crf/src/crf1d_encode.c:583:9: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
583 | if (ret = crf1dmw_open_features(writer))
| ^~~
chaine/crfsuite/lib/crf/src/crf1d_encode.c:624:17: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
624 | if (ret = crf1dmw_put_feature(writer, fmap[k], &feat))
| ^~~
chaine/crfsuite/lib/crf/src/crf1d_encode.c:632:9: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
632 | if (ret = crf1dmw_close_features(writer))
| ^~~
chaine/crfsuite/lib/crf/src/crf1d_encode.c:638:9: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
638 | if (ret = crf1dmw_open_labels(writer, L))
| ^~~
chaine/crfsuite/lib/crf/src/crf1d_encode.c:648:17: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
648 | if (ret = crf1dmw_put_label(writer, l, str))
| ^~~
chaine/crfsuite/lib/crf/src/crf1d_encode.c:655:9: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
655 | if (ret = crf1dmw_close_labels(writer))
| ^~~
chaine/crfsuite/lib/crf/src/crf1d_encode.c:661:9: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
661 | if (ret = crf1dmw_open_attrs(writer, B))
| ^~~
chaine/crfsuite/lib/crf/src/crf1d_encode.c:673:21: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
673 | if (ret = crf1dmw_put_attr(writer, amap[a], str))
| ^~~
chaine/crfsuite/lib/crf/src/crf1d_encode.c:681:9: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
681 | if (ret = crf1dmw_close_attrs(writer))
| ^~~
chaine/crfsuite/lib/crf/src/crf1d_encode.c:687:9: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
687 | if (ret = crf1dmw_open_labelrefs(writer, L + 2))
| ^~~
chaine/crfsuite/lib/crf/src/crf1d_encode.c:694:13: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
694 | if (ret = crf1dmw_put_labelref(writer, l, edge, fmap))
| ^~~
chaine/crfsuite/lib/crf/src/crf1d_encode.c:699:9: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
699 | if (ret = crf1dmw_close_labelrefs(writer))
| ^~~
chaine/crfsuite/lib/crf/src/crf1d_encode.c:705:9: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
705 | if (ret = crf1dmw_open_attrrefs(writer, B))
| ^~~
chaine/crfsuite/lib/crf/src/crf1d_encode.c:714:17: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
714 | if (ret = crf1dmw_put_attrref(writer, amap[a], attr, fmap))
| ^~~
chaine/crfsuite/lib/crf/src/crf1d_encode.c:720:9: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
720 | if (ret = crf1dmw_close_attrrefs(writer))
| ^~~
chaine/crfsuite/lib/crf/src/crf1d_encode.c:533:22: warning: unused variable ‘threshold’ [-Wunused-variable]
533 | const floatval_t threshold = 0.01;
| ^~~~~~~~~
chaine/crfsuite/lib/crf/src/crf1d_encode.c:529:13: warning: variable ‘begin’ set but not used [-Wunused-but-set-variable]
529 | clock_t begin;
| ^~~~~
In file included from chaine/crfsuite/lib/crf/src/crf1d_encode.c:47:
chaine/crfsuite/lib/crf/src/crf1d_encode.c: In function ‘crf1de_exchange_options’:
chaine/crfsuite/lib/crf/src/params.h:51:13: warning: variable ‘__ret’ set but not used [-Wunused-but-set-variable]
51 | int __ret = 0; \
| ^~~~~
chaine/crfsuite/lib/crf/src/crf1d_encode.c:750:5: note: in expansion of macro ‘BEGIN_PARAM_MAP’
750 | BEGIN_PARAM_MAP(params, mode)
| ^~~~~~~~~~~~~~~
chaine/crfsuite/lib/crf/src/crf1d_encode.c: In function ‘encoder_viterbi’:
chaine/crfsuite/lib/crf/src/crf1d_encode.c:953:9: warning: unused variable ‘i’ [-Wunused-variable]
953 | int i;
| ^
chaine/crfsuite/lib/crf/src/crf1d_encode.c: In function ‘encoder_save_model’:
chaine/crfsuite/lib/crf/src/crf1d_encode.c:920:12: warning: ‘ret’ may be used uninitialized in this function [-Wmaybe-uninitialized]
920 | return crf1de_save_model(crf1de, filename, w, self->ds->data->attrs, self->ds->data->labels, lg);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
chaine/crfsuite/lib/crf/src/crf1d_model.c: In function ‘crf1dmw_put_labelref’:
chaine/crfsuite/lib/crf/src/crf1d_model.c:521:21: warning: unused variable ‘offset’ [-Wunused-variable]
521 | uint32_t n = 0, offset = 0;
| ^~~~~~
chaine/crfsuite/lib/crf/src/crf1d_model.c: In function ‘crf1dmw_put_attrref’:
chaine/crfsuite/lib/crf/src/crf1d_model.c:638:21: warning: unused variable ‘offset’ [-Wunused-variable]
638 | uint32_t n = 0, offset = 0;
| ^~~~~~
chaine/crfsuite/lib/crf/src/crf1d_model.c: In function ‘crf1dmw_put_feature’:
chaine/crfsuite/lib/crf/src/crf1d_model.c:744:13: warning: comparison of integer expressions of different signedness: ‘int’ and ‘uint32_t’ {aka ‘unsigned int’} [-Wsign-compare]
744 | if (fid != hfeat->num)
| ^~
In function ‘read_uint8’,
inlined from ‘read_uint8_array’ at chaine/crfsuite/lib/crf/src/crf1d_model.c:173:20,
inlined from ‘crf1dm_new_impl’ at chaine/crfsuite/lib/crf/src/crf1d_model.c:786:10:
chaine/crfsuite/lib/crf/src/crf1d_model.c:133:12: warning: writing 16 bytes into a region of size 4 [-Wstringop-overflow=]
133 | *value = *buffer;
| ~~~~~~~^~~~~~~~~
chaine/crfsuite/lib/crf/src/crf1d_model.c: In function ‘crf1dm_new_impl’:
chaine/crfsuite/lib/crf/src/crf1d_model.c:66:13: note: at offset 0 to object ‘magic’ with size 4 declared here
66 | uint8_t magic[4]; /* File magic. */
| ^~~~~
chaine/crfsuite/lib/crf/src/crf1d_tag.c: In function ‘crf1dt_state_score’:
chaine/crfsuite/lib/crf/src/crf1d_tag.c:74:15: warning: unused variable ‘L’ [-Wunused-variable]
74 | const int L = crf1dt->num_labels;
| ^
chaine/crfsuite/lib/crf/src/crfsuite.c: In function ‘crfsuite_evaluation_output’:
chaine/crfsuite/lib/crf/src/crfsuite.c:482:44: warning: unused variable ‘lev’ [-Wunused-variable]
482 | const crfsuite_label_evaluation_t *lev = &eval->tbl[i];
| ^~~
chaine/crfsuite/lib/crf/src/crfsuite.c:475:15: warning: variable ‘lg’ set but not used [-Wunused-but-set-variable]
475 | logging_t lg;
| ^~
At top level:
chaine/crfsuite/lib/crf/src/crfsuite.c:325:14: warning: ‘safe_strncpy’ defined but not used [-Wunused-function]
325 | static char *safe_strncpy(char *dst, const char *src, size_t n)
| ^~~~~~~~~~~~
chaine/crfsuite/lib/crf/src/crfsuite_train.c: In function ‘crfsuite_train_train’:
chaine/crfsuite/lib/crf/src/crfsuite_train.c:140:11: warning: unused variable ‘algorithm’ [-Wunused-variable]
140 | char *algorithm = NULL;
| ^~~~~~~~~
In file included from chaine/crfsuite/lib/crf/src/train_arow.c:47:
chaine/crfsuite/lib/crf/src/vecmath.h: In function ‘_aligned_malloc’:
chaine/crfsuite/lib/crf/src/vecmath.h:50:15: warning: implicit declaration of function ‘posix_memalign’ [-Wimplicit-function-declaration]
50 | int ret = posix_memalign(&p, alignment, size);
| ^~~~~~~~~~~~~~
In file included from chaine/crfsuite/lib/crf/src/train_arow.c:46:
chaine/crfsuite/lib/crf/src/train_arow.c: In function ‘exchange_options’:
chaine/crfsuite/lib/crf/src/params.h:51:13: warning: variable ‘__ret’ set but not used [-Wunused-but-set-variable]
51 | int __ret = 0; \
| ^~~~~
chaine/crfsuite/lib/crf/src/train_arow.c:219:5: note: in expansion of macro ‘BEGIN_PARAM_MAP’
219 | BEGIN_PARAM_MAP(params, mode)
| ^~~~~~~~~~~~~~~
chaine/crfsuite/lib/crf/src/train_arow.c: In function ‘crfsuite_train_arow’:
chaine/crfsuite/lib/crf/src/train_arow.c:292:17: warning: unused variable ‘iteration_begin’ [-Wunused-variable]
292 | clock_t iteration_begin = clock();
| ^~~~~~~~~~~~~~~
chaine/crfsuite/lib/crf/src/train_arow.c:291:20: warning: unused variable ‘norm’ [-Wunused-variable]
291 | floatval_t norm = 0., sum_loss = 0.;
| ^~~~
chaine/crfsuite/lib/crf/src/train_arow.c:259:13: warning: unused variable ‘begin’ [-Wunused-variable]
259 | clock_t begin = clock();
| ^~~~~
chaine/crfsuite/lib/crf/src/train_arow.c:252:16: warning: variable ‘beta’ set but not used [-Wunused-but-set-variable]
252 | floatval_t beta;
| ^~~~
At top level:
chaine/crfsuite/lib/crf/src/train_arow.c:212:19: warning: ‘tau2’ defined but not used [-Wunused-function]
212 | static floatval_t tau2(floatval_t cost, floatval_t norm, floatval_t c)
| ^~~~
chaine/crfsuite/lib/crf/src/train_arow.c:207:19: warning: ‘tau1’ defined but not used [-Wunused-function]
207 | static floatval_t tau1(floatval_t cost, floatval_t norm, floatval_t c)
| ^~~~
chaine/crfsuite/lib/crf/src/train_arow.c:202:19: warning: ‘tau0’ defined but not used [-Wunused-function]
202 | static floatval_t tau0(floatval_t cost, floatval_t norm, floatval_t c)
| ^~~~
chaine/crfsuite/lib/crf/src/train_arow.c:197:19: warning: ‘cost_sensitive’ defined but not used [-Wunused-function]
197 | static floatval_t cost_sensitive(floatval_t err, floatval_t d)
| ^~~~~~~~~~~~~~
chaine/crfsuite/lib/crf/src/train_arow.c:192:19: warning: ‘cost_insensitive’ defined but not used [-Wunused-function]
192 | static floatval_t cost_insensitive(floatval_t err, floatval_t d)
| ^~~~~~~~~~~~~~~~
chaine/crfsuite/lib/crf/src/train_arow.c:166:13: warning: ‘delta_add’ defined but not used [-Wunused-function]
166 | static void delta_add(delta_t *dc, floatval_t *w, floatval_t *ws, const floatval_t tau, const floatval_t u)
| ^~~~~~~~~
chaine/crfsuite/lib/crf/src/train_arow.c:153:19: warning: ‘delta_norm2’ defined but not used [-Wunused-function]
153 | static floatval_t delta_norm2(delta_t *dc)
| ^~~~~~~~~~~
In file included from chaine/crfsuite/lib/crf/src/train_averaged_perceptron.c:47:
chaine/crfsuite/lib/crf/src/vecmath.h: In function ‘_aligned_malloc’:
chaine/crfsuite/lib/crf/src/vecmath.h:50:15: warning: implicit declaration of function ‘posix_memalign’ [-Wimplicit-function-declaration]
50 | int ret = posix_memalign(&p, alignment, size);
| ^~~~~~~~~~~~~~
In file included from chaine/crfsuite/lib/crf/src/train_averaged_perceptron.c:46:
chaine/crfsuite/lib/crf/src/train_averaged_perceptron.c: In function ‘exchange_options’:
chaine/crfsuite/lib/crf/src/params.h:51:13: warning: variable ‘__ret’ set but not used [-Wunused-but-set-variable]
51 | int __ret = 0; \
| ^~~~~
chaine/crfsuite/lib/crf/src/train_averaged_perceptron.c:91:5: note: in expansion of macro ‘BEGIN_PARAM_MAP’
91 | BEGIN_PARAM_MAP(params, mode)
| ^~~~~~~~~~~~~~~
chaine/crfsuite/lib/crf/src/train_averaged_perceptron.c: In function ‘crfsuite_train_averaged_perceptron’:
chaine/crfsuite/lib/crf/src/train_averaged_perceptron.c:156:17: warning: unused variable ‘iteration_begin’ [-Wunused-variabl]
156 | clock_t iteration_begin = clock();
| ^~~~~~~~~~~~~~~
chaine/crfsuite/lib/crf/src/train_averaged_perceptron.c:155:20: warning: unused variable ‘norm’ [-Wunused-variable]
155 | floatval_t norm = 0., loss = 0.;
| ^~~~
chaine/crfsuite/lib/crf/src/train_averaged_perceptron.c:126:13: warning: unused variable ‘begin’ [-Wunused-variable]
126 | clock_t begin = clock();
| ^~~~~
In file included from chaine/crfsuite/lib/crf/src/train_l2sgd.c:108:
chaine/crfsuite/lib/crf/src/vecmath.h: In function ‘_aligned_malloc’:
chaine/crfsuite/lib/crf/src/vecmath.h:50:15: warning: implicit declaration of function ‘posix_memalign’ [-Wimplicit-function-declaration]
50 | int ret = posix_memalign(&p, alignment, size);
| ^~~~~~~~~~~~~~
chaine/crfsuite/lib/crf/src/train_l2sgd.c: In function ‘l2sgd’:
chaine/crfsuite/lib/crf/src/train_l2sgd.c:151:23: warning: unused variable ‘clk_begin’ [-Wunused-variable]
151 | clock_t clk_prev, clk_begin = clock();
| ^~~~~~~~~
chaine/crfsuite/lib/crf/src/train_l2sgd.c:151:13: warning: variable ‘clk_prev’ set but not used [-Wunused-but-set-variable]
151 | clock_t clk_prev, clk_begin = clock();
| ^~~~~~~~
chaine/crfsuite/lib/crf/src/train_l2sgd.c: In function ‘l2sgd_calibration’:
chaine/crfsuite/lib/crf/src/train_l2sgd.c:296:13: warning: unused variable ‘clk_begin’ [-Wunused-variable]
296 | clock_t clk_begin = clock();
| ^~~~~~~~~
In file included from chaine/crfsuite/lib/crf/src/train_l2sgd.c:106:
chaine/crfsuite/lib/crf/src/train_l2sgd.c: In function ‘exchange_options’:
chaine/crfsuite/lib/crf/src/params.h:51:13: warning: variable ‘__ret’ set but not used [-Wunused-but-set-variable]
51 | int __ret = 0; \
| ^~~~~
chaine/crfsuite/lib/crf/src/train_l2sgd.c:393:5: note: in expansion of macro ‘BEGIN_PARAM_MAP’
393 | BEGIN_PARAM_MAP(params, mode)
| ^~~~~~~~~~~~~~~
chaine/crfsuite/lib/crf/src/train_l2sgd.c: In function ‘crfsuite_train_l2sgd’:
chaine/crfsuite/lib/crf/src/train_l2sgd.c:447:15: warning: unused variable ‘T’ [-Wunused-variable]
447 | const int T = gm->cap_items;
| ^
chaine/crfsuite/lib/crf/src/train_l2sgd.c:443:13: warning: variable ‘clk_begin’ set but not used [-Wunused-but-set-variable]
443 | clock_t clk_begin;
| ^~~~~~~~~
chaine/crfsuite/lib/crf/src/train_l2sgd.c:241:13: warning: ‘eta’ may be used uninitialized in this function [-Wmaybe-uninitialized]
241 | logging(lg, "Epoch %d, learning rate: %f, training loss: %f", epoch, eta, sum_loss);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
chaine/crfsuite/lib/crf/src/train_l2sgd.c:146:16: note: ‘eta’ was declared here
146 | floatval_t eta, gain, decay = 1.;
| ^~~
In file included from chaine/crfsuite/lib/crf/src/train_lbfgs.c:50:
chaine/crfsuite/lib/crf/src/vecmath.h: In function ‘_aligned_malloc’:
chaine/crfsuite/lib/crf/src/vecmath.h:50:15: warning: implicit declaration of function ‘posix_memalign’ [-Wimplicit-function-declaration]
50 | int ret = posix_memalign(&p, alignment, size);
| ^~~~~~~~~~~~~~
chaine/crfsuite/lib/crf/src/train_lbfgs.c: In function ‘lbfgs_progress’:
chaine/crfsuite/lib/crf/src/train_lbfgs.c:127:13: warning: variable ‘duration’ set but not used [-Wunused-but-set-variable]
127 | clock_t duration, clk = clock();
| ^~~~~~~~
In file included from chaine/crfsuite/lib/crf/src/train_lbfgs.c:49:
chaine/crfsuite/lib/crf/src/train_lbfgs.c: In function ‘exchange_options’:
chaine/crfsuite/lib/crf/src/params.h:51:13: warning: variable ‘__ret’ set but not used [-Wunused-but-set-variable]
51 | int __ret = 0; \
| ^~~~~
chaine/crfsuite/lib/crf/src/train_lbfgs.c:160:5: note: in expansion of macro ‘BEGIN_PARAM_MAP’
160 | BEGIN_PARAM_MAP(params, mode)
| ^~~~~~~~~~~~~~~
chaine/crfsuite/lib/crf/src/train_lbfgs.c: In function ‘crfsuite_train_lbfgs’:
chaine/crfsuite/lib/crf/src/train_lbfgs.c:217:15: warning: unused variable ‘A’ [-Wunused-variable]
217 | const int A = trainset->data->attrs->num(trainset->data->attrs);
| ^
chaine/crfsuite/lib/crf/src/train_lbfgs.c:216:15: warning: unused variable ‘L’ [-Wunused-variable]
216 | const int L = trainset->data->labels->num(trainset->data->labels);
| ^
chaine/crfsuite/lib/crf/src/train_lbfgs.c:215:15: warning: unused variable ‘N’ [-Wunused-variable]
215 | const int N = trainset->num_instances;
| ^
chaine/crfsuite/lib/crf/src/train_lbfgs.c:214:13: warning: unused variable ‘begin’ [-Wunused-variable]
214 | clock_t begin = clock();
| ^~~~~
In file included from chaine/crfsuite/lib/crf/src/train_passive_aggressive.c:47:
chaine/crfsuite/lib/crf/src/vecmath.h: In function ‘_aligned_malloc’:
chaine/crfsuite/lib/crf/src/vecmath.h:50:15: warning: implicit declaration of function ‘posix_memalign’ [-Wimplicit-function-declaration]
50 | int ret = posix_memalign(&p, alignment, size);
| ^~~~~~~~~~~~~~
In file included from chaine/crfsuite/lib/crf/src/train_passive_aggressive.c:46:
chaine/crfsuite/lib/crf/src/train_passive_aggressive.c: In function ‘exchange_options’:
chaine/crfsuite/lib/crf/src/params.h:51:13: warning: variable ‘__ret’ set but not used [-Wunused-but-set-variable]
51 | int __ret = 0; \
| ^~~~~
chaine/crfsuite/lib/crf/src/train_passive_aggressive.c:221:5: note: in expansion of macro ‘BEGIN_PARAM_MAP’
221 | BEGIN_PARAM_MAP(params, mode)
| ^~~~~~~~~~~~~~~
chaine/crfsuite/lib/crf/src/train_passive_aggressive.c: In function ‘crfsuite_train_passive_aggressive’:
chaine/crfsuite/lib/crf/src/train_passive_aggressive.c:328:17: warning: unused variable ‘iteration_begin’ [-Wunused-variable]
328 | clock_t iteration_begin = clock();
| ^~~~~~~~~~~~~~~
chaine/crfsuite/lib/crf/src/train_passive_aggressive.c:327:20: warning: unused variable ‘norm’ [-Wunused-variable]
327 | floatval_t norm = 0., sum_loss = 0.;
| ^~~~
chaine/crfsuite/lib/crf/src/train_passive_aggressive.c:270:13: warning: unused variable ‘begin’ [-Wunused-variable]
270 | clock_t begin = clock();
| ^~~~~
Add a chaine.load()
function.
A more detailed README or documentation would be helpful. Opinions @severinsimmler?
And profile to identify bottlenecks (both speed and memory)
Add a module to optimize hyperparameters in a convenient way.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.