TL;DR
FACTORIE is a probabilistic programming library that reimagines factor graphs through the lens of imperative programming. By using a general-purpose language (Scala) instead of restricted logic-based declarations, it allows researchers to build complex, dynamic relational models that are 3–15x faster and significantly more accurate than previous state-of-the-art systems.
The Challenge with Relational Data
Graphical models like Conditional Random Fields (CRFs) are excellent for structured prediction, but defining them for "relational" data—where dependencies are complex, repeated, or change during inference—is notoriously difficult.
Existing toolkits often rely on declarative languages like First-Order Logic (e.g., Markov Logic Networks) or SQL. While elegant, these "little languages" struggle with real-world programming needs: they are often inefficient at expressing procedural concepts like graph reachability, set comparisons, or complex string manipulations. Furthermore, they often require "unrolling" the entire graph into memory, which becomes computationally prohibitive as model complexity grows.
Methods: Imperatively Defined Factor Graphs
The authors introduce Imperatively Defined Factor Graphs (IDFs), implemented in the FACTORIE library using the Scala programming language. The core idea is to use imperative code to define four key aspects of a model:
- Structure Definition (
unroll): Instead of a static graph, factors are created on-the-fly. When a variable changes, a snippet of code "unrolls" only the necessary neighboring factors. - Variable Coordination: Changes to one variable can automatically trigger updates in others (e.g., changing a cluster label automatically updates the cluster's canonical string).
- Variable-Statistics Mapping: The system separates the "neighbors" of a factor from the "sufficient statistics" used to score it, allowing for efficient, on-the-fly feature calculation.
- Proposal Distribution: Users can write procedural code to suggest "jumps" between possible worlds during Markov chain Monte Carlo (MCMC) inference.
To make this efficient, FACTORIE uses a DiffList—a compact object that tracks incremental changes. This allows the system to score a "proposal" (a potential change to the model) without ever needing to represent or score the entire global graph. For learning, they utilize Sample-Rank, an algorithm that learns by ranking different MCMC jumps.
Datasets
The paper evaluates FACTORIE on the Cora dataset, a standard benchmark for research paper citation analysis. The task involves:
- Segmentation: Labeling parts of a citation string (Author, Title, Venue).
- Coreference: Determining which citation strings refer to the same underlying paper entity.
Key Insights
- The "Logic" isn't the Point: The authors argue that the power of relational models comes from repeated structure and tied parameters, not necessarily from formal logic. Using a Turing-complete language like Scala provides the flexibility that logic-based systems lack.
- Incrementalism is King: By using
DiffListand imperative unrolling, FACTORIE avoids the "memory wall." It can reason about data larger than memory because it only ever looks at the local "delta" of a change. - Object-Oriented Probabilities: Variables and factor templates are treated as first-class objects. This allows for inheritance and polymorphism, making it easy to create new, complex variable types (like set-valued variables).
- On-the-fly Features: Because features are defined as functions, the model can compute complex metrics (like String Edit Distance) during inference rather than pre-calculating every possible combination.
Key Results
The authors compared FACTORIE against Markov Logic Networks (using the Alchemy toolkit) on the joint segmentation and coreference task.
- Accuracy: FACTORIE (labeled as IDF) achieved a 20–25% reduction in error compared to the previous state-of-the-art. As shown in the table, Joint IDF reaches a Coreference Cluster Recall of 94.62, vastly outperforming the Joint MLN baseline of 75.2.
- Speed: The system was 3–15 times faster than MLNs.
- Efficiency: While MLNs took 50–90 minutes for learning and inference, FACTORIE's isolated tasks finished in under 3 minutes, and the complex joint task took only 18 minutes.
Limitations and Future Work
- Verbosity: The authors acknowledge that specifying templates in FACTORIE can be more verbose than a single line of first-order logic, though they argue this is a fair trade-off for flexibility.
- Learning Curve: Users need to be comfortable with Scala and the imperative style of model building, which differs from the purely mathematical or logical declarations found in other toolkits.
- Future Directions: The paper suggests that the framework is general enough to support generative models (like Latent Dirichlet Allocation) in very few lines of code, hinting at broader applications beyond discriminative relational models.
Summary updated