JNI Kernel Extension for SVMlight


Overview of this Software

This software is an extension of the SVMlight software (V6.01) available at http://svmlight.joachims.org/. It provides an interface to kernel functions that are implemented in Java by means of the Java Native Interface (JNI) Invocation API.

Technically, the custom C/C++ kernel module of SVMlight now becomes a proxy that is tightly coupled to the Java class edu.unika.aifb.jnikernel.KernelManager. This class delegates all kernel evaluation calls to a user-specified Java class that implements the edu.unika.aifb.kernels.api.Kernel interface. Thus, SVMlight can directly (i.e. without further modifications) work with any Java class that implements this interface.

A small disclaimer: To stick to the modular setup of SVMlight, all operations for converting C/C++ datatypes to Java and back are happening within the kernel interface and, as such, again and again during each kernel evaluation. Especially when dealing with large vectors, the repeated conversion to Java will result in a substantial computational overhead. For smaller vectors or for kernels defined on the custom String field of the SVMlight instances the conversion overhead is, however, neglectable.

News

Download and Installation

  1. You can download precompiled versions of SVMlight that incorporate the extension. Precompiled versions are available as follows:
  2. Download the corresponding Java package: jnikernel.jar (corresponding Java documentation: jnikernel-javadoc.tar.gz, can also be viewed online here).
  3. You need to have the Sun Java Runtime Environment installed. Both versions have been linked to work with the Sun JDK/JRE 1.5 shared libraries (should also work with Java 1.6). Basically, this means that you have to make sure that the Sun JVM shared libraries are available to SVMlight (c.f. Sun JNI Guide, ch 7.2.1).
  4. Go and test your installation (see below). If it does not work, you might need to compile the whole thing on your system.

Compiling SVMlight with the JNI Kernel Extension

  1. Get the SVMlight sources (V6.01) from http://download.joachims.org/svm_light/current/svm_light.tar.gz.
  2. Download the kernel modules in kernel.c and and kernel.h and place them inside the base folder of the SVMlight sources.
  3. Place the include "svm_common.h" statement in scm_classify.c inside an extern "C" {...} statement.
  4. Place the include "svm_common.h" and include "svm_learn.h" statements in scm_learn_main.c inside an extern "C" {...} statement.
  5. You need to compile the new kernel module using C++, the core SVMlight modules using plain C and link everything into executables using a C++ linker. Further, you must instruct the compiler/linker to use the respective JNI include files and libraries. For Sun Java 1.2 and above (c.f. Sun JNI Guide, ch 7.2.1), this means: To save you breath and time, you may download an adapted SVMlight makefile (just change the respective JDK/JRE directories) here: Makefile.

Usage

Implementing Own Kernels

You can implement whatever kernel, just make sure that it implements the edu.unika.aifb.kernels.api.Kernel interface (check the corresponding JavaDoc for details: jnikernel-javadoc.tar.gz or online here). If parameters need to be passed to the kernel implementation, this can be done by implementing a constructor that takes a single java.util.Properties argument. The extension is implemented in such a way that during initialization, the KernelManager will check whether the implementing kernel class has a matching constructor. If so, it will pass the contents of the parameter file such that other, implementation-specific parameters can be read. If not, the default constructor will be used.

License and Acknowledgements

This extension can be freely used and modified but work based on this implementation should acknowledge this source by pointing to this website. When using the extension, please make sure that you comply with the (separate) license of the basic SVMlight software.

Contact

For any questions, please contact Stephan Bloehdorn. You might also like to have a look at the Semantic Kernel Extension for SVMlight available here.