Git Product home page Git Product logo

psl's Introduction

PSL

Build Status

Main

Probabilistic soft logic (PSL) is a machine learning framework for developing probabilistic models. PSL models are easy to use and fast. You can define models using a straightforward logical syntax and solve them with fast convex optimization. PSL has produced state-of-the-art results in many areas spanning natural language processing, social-network analysis, knowledge graphs, recommender system, and computational biology. More information about PSL is available at the PSL homepage.

Getting Started with PSL

If you want to use PSL to build models, you probably do not need this source code. Instead, visit the Getting Started guide to learn how to create PSL projects that will automatically install a stable version of these libraries.

Installing PSL from Source

If you do want to install PSL from source, you can use Maven 3.x. In the top-level directory of the PSL source (which should be the same directory that holds this README), run:

mvn install

Installing PSL with Gurobi

PSL can additionally be used with the Gurobi solver for inference. Gurobi is a commercial solver, but free academic licenses are available. To use Gurobi with PSL, you must have Gurobi installed and licensed, see Gurobi Quickstart Guide. Further, you must install the Gurobi jar file into your local Maven repository. See Guide to installing 3rd party JARs for more information.

To do this, first download the Gurobi jar file from the Gurobi website. You will need to create an account and agree to the license terms. You must also obtain a Gurobi license that is registered and saved to your machine. Be sure to export the GUROBI_HOME environment variable to point to your install directory, <installdir>, and GRB_LICENSE_FILE environment variable to point to the location of the license file. Moreover, you must have the Gurobi install bin directory, <installdir>/bin, added to your PATH environment variable and <installdir>/lib added to your LD_LIBRARY_PATH environment variable. Then, run the following command, replacing <installdir>/lib/gurobi.jar with the path to the downloaded jar file and <version> with the version of Gurobi you downloaded:

mvn install:install-file -Dfile=<installdir>/lib/gurobi.jar -DgroupId=com.gurobi -DartifactId=gurobi -Dversion=<version> -Dpackaging=jar

If you are using a version of Gurobi other than 10.0.3, you will also need to update the Gurobi dependency version in the PSL pom.xml file. Then, you can install PSL with Gurobi support by running:

mvn install -P Gurobi

PSL inference can then be run with Gurobi using the GurobiInference class.

Citing PSL

We hope you find PSL useful! If you have, please consider citing PSL in any related publications as

@article{bach:jmlr17,
  Author = {Bach, Stephen H. and Broecheler, Matthias and Huang, Bert and Getoor, Lise},
  Journal = {Journal of Machine Learning Research (JMLR)},
  Title = {Hinge-Loss {M}arkov Random Fields and Probabilistic Soft Logic},
  Year = {2017}
}

Additional Resources

psl's People

Contributors

alexmemory avatar almumill avatar berty38 avatar cfpryor avatar cortys avatar dickensc avatar ericnorris avatar eriq-augustine avatar gvozdetsky avatar jacksullivan avatar jrfoulds avatar mbroecheler avatar puuj avatar shobeir avatar shrestabs avatar sriramiscool avatar stephenbach avatar thachandrew avatar vihanggodbole avatar whiteau avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

psl's Issues

Instantiating factories from config file fails when executing from Maven

In PSL version 1.0.1:

If a factory is specified in psl.properties, e.g.,

example.conicreasoner.conicprogramsolver = edu.umd.cs.psl.optimizer.conic.ipm.HomogeneousIPMFactory

and a program is executed from Maven with the command

>> mvn exec:java -Dexec.mainClass=<fully qualified class name>

then the class loader cannot find the specified class, even if it is on the classpath.

Suspect that Maven uses its own class loader, so the jars containing the factories are not on the classpath of the class loader used by the ConfigManager.

Have you ever thought about giving support on Ruby language?

I think it would be a good idea, maybe to write a gem about this just for fun. Ruby right now it's a very popular language in startups, and many startups has to do some analisys of social networks. I was working with this tool for social network analisys and I think it's very useful.

What do you think? I volunteer to make it.

[CLOSED] Better Programmatic API

Issue by eriq-augustine
Thursday Nov 10, 2016 at 06:14 GMT
Originally opened as eriq-augustine#17


PSL is great as a stand alone program (whether run in Groovy or CLI).
But, I want to be able to load a PSL model/data and run online tasks.
This is not about updating in real-time, but just about using PSL as a decision maker to drive some larger program.

ExternalFunction implementations use the wrong method on StringAttribute

Several of the ExternalFunction implementations (I noticed LevenshteinSimilarity, SubStringSimilarity, and CosineSimilarity) use toString() to convert GroundTerm instances to strings. Based on my reading of the code, this is incorrect, as this should concretely dispatch to StringAttribute whose toString() method returns a truncated string as follows:

public String toString() {
        if (value.length() > 28)
            return "'" + value.substring(0, Math.min(value.length(), 25)) + "...'";
        else
            return "'" + value + "'";
    }

Rather, these calls should be to the getValue() method, which simply returns the value. If my interpretation of the dispatch here is correct please let me know and I'll go through and submit a pull request with fixes throughout ExternalFunction implementers.

support arbitrary constant (PSLParser)

In PSL.g4

constant
    :   SINGLE_QUOTE IDENTIFIER SINGLE_QUOTE
    |   DOUBLE_QUOTE IDENTIFIER DOUBLE_QUOTE
    ;

Since a constant is quoted within single double or double quote, it would be better if user can use any character instead of just letter and digit (e.g: using delimiter to make constant easier to read and debug)

In addition to this, may be lots of people will get confuse if they have this error: org.antlr.v4.runtime.NoViableAltException because of constant parsing.

Documentation of external functions

This is a issue with current documentation of using external function.

The documentation says to use the following to define an external function in PSL.

model.add function: MyStringSimilarity, implementation: new MyStringSimilarity();

However, the above is likely to throw a cast exception. This should be corrected with

model.add function: “MyStringSimilarity”, implementation: new MyStringSimilarity();

How big the model can be

Hi,

I wanted to know if you have any estimates on size and time of models? I understand the complexity of model can affect everything but I was curious that how fast it is in the applications that you have used PSL?
Does it parallelize well if I run it on a big machine?

Thanks

Seems that the value of primalRes and epsilonPrimal goes wrong in this version of code...

I've been running social-network-analysis in PSL-example using this version of source code. Previously, it normally ends in 40secs. However, this time the PSL program stuck in optimization phase until 25000 iterations.

I printed stopping criteria and saw that primalRes > epsilonPrimal always holds. So I tried to let epsilonPrimal = 2 * epsilonPrimal and the program ended with 479 iterations.

groovy project ./run.sh get an error

I rewrite the groovy project for my own, but when I run the run.sh I get an error:
$ mvn clean
[INFO] Scanning for projects...
[INFO]
[INFO] -------------< org.linqs.psl.examples:simpleacquaintances >-------------
[INFO] Building simpleacquaintances 1.0.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ simpleacquaintances ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.197 s
[INFO] Finished at: 2018-08-01T20:08:59+08:00
[INFO] ------------------------------------------------------------------------

/cygdrive/d/kgi/groovy
$ ./run.sh
[INFO] Scanning for projects...
[INFO]
[INFO] -------------< org.linqs.psl.examples:simpleacquaintances >-------------
[INFO] Building simpleacquaintances 1.0.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[WARNING] The POM for org.linqs:psl-groovy:jar:CANARY-2.1.6 is missing, no dependency information available
[WARNING] The POM for org.linqs:psl-cli:jar:CANARY is missing, no dependency information available
[WARNING] The POM for org.linqs:psl-dataloading:jar:CANARY is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.167 s
[INFO] Finished at: 2018-08-01T20:26:13+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project simpleacquaintances: Could not resolve dependencies for project org.linqs.psl.examples:simpleacquaintances:jar:1.0.0-SNAPSHOT: Failure to find org.linqs:psl-groovy:jar:CANARY-2.1.6 in http://maven.aliyun.com/nexus/content/groups/public was cached in the local repository, resolution will not be reattempted until the update interval of nexus-aliyun has elapsed or updates are forced -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
ERROR: Failed to compile

  • I guess I can't download the psl relative jar in the mirror, but in my local repository I have downloaded the three jars.

No signature of method: static org.linqs.psl.model.predicate.StandardPredicate.get()

I use the three jar psl-groovy-CANARY.jar psl-dataloading-1.0.0.jar psl-cli-CANARY.jar for my application, but I get the error as follows:

Exception in thread "main" groovy.lang.MissingMethodException: No signature of method: static org.linqs.psl.model.predicate.StandardPredicate.get() is applicable for argument types: (java.lang.String, [Lorg.linqs.psl.model.term.ConstantType;) values: [Name, [UniqueIntID, UniqueStringID]] Possible solutions: grep(), getAt(java.lang.String), wait(), any(), grep(java.lang.Object), getName() at groovy.lang.MetaClassImpl.invokeStaticMissingMethod(MetaClassImpl.java:1503) at groovy.lang.MetaClassImpl.invokeStaticMethod(MetaClassImpl.java:1489) at org.codehaus.groovy.runtime.callsite.StaticMetaClassSite.call(StaticMetaClassSite.java:53) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:133) at org.linqs.psl.groovy.PSLModel.addPredicate(PSLModel.groovy:180) at org.linqs.psl.groovy.PSLModel.this$3$addPredicate(PSLModel.groovy) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:210) at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:59) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:154) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:174) at org.linqs.psl.groovy.PSLModel.add(PSLModel.groovy:143) at org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:232) at org.linqs.psl.examples.kgi.Run.definePredicates(Run.groovy:96) at org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:232) at org.linqs.psl.examples.kgi.Run.run(Run.groovy:448) at org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:232) at org.linqs.psl.examples.kgi.Run.main(Run.groovy:467)

  • I guess my predicate have problem, but I can't make sure, here is my code:

public Run() {
config = ConfigManager.getManager().getBundle("kgi")
config.addProperty("admmreasoner.maxiterations", 125000)
String suffix = System.getProperty("user.name") + "@" + getHostname()
String baseDBPath = config.getString("dbpath", System.getProperty("java.io.tmpdir"))
String dbPath = Paths.get(baseDBPath, this.getClass().getName() + "_" + suffix).toString()
dataStore = new RDBMSDataStore(new H2DatabaseDriver(Type.Disk, dbPath, true), config)
model = new PSLModel(this, dataStore)
}
private void definePredicates() {
model.add predicate: "Name", types: [ConstantType.UniqueIntID, ConstantType.UniqueStringID]
}

Aggressive Caching of Atoms

It looks like both AtomCache and PersistedAtomManager (which appear unavoidable on the code path, as PersistedAtomManager is called by MPEInferencer and AtomCache is a class that any implementation of Database must return) cache and never discard a large number of Atoms. In particular, buildPersistedAtomCache effectively loads the entire database into memory by calling db.getAtom on every possible set of values for each predicate (since getAtom caches all these values in the AtomCache).

I guess my issue/thought here is twofold. The first is, why bother with PersistedAtomManager when getAtom implementations are already backed by a cache? The second is, AtomCache should be a proper cache in the sense that it should discard old values and allow them to be garbage collected. As it is it seems that it isn't possible to perform inference on datasets that are too large to fit entirely in memory, which seems to defeat the purpose of having a system that is backed by a database.

I'm certainly willing to help out in terms of addressing these two issues if there is support from the team, but I'd like to know if there is an underlying rationale for things being the way they are before I dive in with a knife.

[CLOSED] Tests

Issue by eriq-augustine
Thursday Nov 03, 2016 at 23:38 GMT
Originally opened as eriq-augustine#5


More tests!
This is just a general issue to stress the importance of tests.
It will not get closed until PSL 2.0 has "adequate" tests.

[CLOSED] Different toString() formats for logical and arithmetic rules

Issue by eriq-augustine
Saturday Nov 05, 2016 at 20:11 GMT
Originally opened as eriq-augustine#13


Lets make this consistent across all rules.

Examples:
(Input Rule String) -> (toString())
Logical:
"1: Single(A) & Double(A, B) >> Single(B) ^2" -> "{1.0} ( SINGLE(A) & DOUBLE(A, B) ) >> SINGLE(B) {squared}"

Arithmetic:
"1: Single(A) = 1 ^2" -> "1.0: 1.0 * SINGLE(A) = 1.0 ^2"

Notice the weights and squaring are represented differently.

Support for Additional ArgumentTypes

I'd like to add support for some additional ArgumentTypes to psl predicates, probably DateTime and maybe long to start. Let me know if you'd be amenable to adding that in to the main fork.

[CLOSED] Wiki Page: Arithemetic Rule Semantics

Issue by eriq-augustine
Friday Nov 04, 2016 at 03:59 GMT
Originally opened as eriq-augustine#10


Make a page for 2.0 arithmetic rule semantics.
Include this data:

2.0 Arithmetic Rule Semantics

  • (Rule is two parts: expression and selects)
  • Eash sum variable can be used once per expression.
    • ie. each sum variable must have a unique id.
  • A select may only appear on a rule with a sum variable.
  • The only valid things that can appear in the select are:
    • Constants
    • Variables apearing in the associated arithmetic expression
    • The single sum variable that was defined as the argument
  • Cardinality can only be taken on a sum variable.
    • Cardinality cannot be in a select.
  • Builtin Coefficient Functions

[CLOSED] Implement non-symmetric operator in parser

Issue by stephenbach
Saturday Nov 19, 2016 at 01:41 GMT
Originally opened as eriq-augustine#28


Need to change PSL.g4 antlr grammar. Something like

termOperator
	:	termEqual
	|	notEqual
        |       nonsymmetric
	;

termEqual
	:	EQUAL EQUAL
	;

notEqual
	:	NEGATION EQUAL
	;

nonsymmetric
        :       SYMBOL1 SYMBOL2

then add logic to visitAtom in ModelLoader.java.

Then put the correct symbol in Atom.toString()

Unable to build from source

Running mvn install (3.5.2) gets:

 Failed to execute goal on project psl-core: Could not resolve dependencies for project edu.umd.cs:psl-core:jar:1.2.1: Failed to collect dependencies at edu.emory.mathcs:parallelcolt:jar:0.9.4: Failed to read artifact descriptor for edu.emory.mathcs:parallelcolt:jar:0.9.4: Could not transfer artifact edu.emory.mathcs:parallelcolt:pom:0.9.4 from/to psl-releases (https://scm.umiacs.umd.edu/maven/lccd/content/repositories/psl-releases/): Failed to transfer file: https://scm.umiacs.umd.edu/maven/lccd/content/repositories/psl-releases/edu/emory/mathcs/parallelcolt/0.9.4/parallelcolt-0.9.4.pom. Return code is: 503 , ReasonPhrase:Service Unavailable. -> [Help 1]

Problem with umd.edu server?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.