Skip to content

Conversation

@bhargav
Copy link
Contributor

@bhargav bhargav commented Mar 4, 2017

Work Items

  • Implements feature caching for static features that do not change between runs.
  • Update documentation
  • Add unit tests
  • Verify/Reason if we need a function to explicitly clear the cache?

Idea: Cache static features that do not change across learning iterations. Improves training speed at the cost of using more memory for caching the features. Tested this on the Chunker app and there is a significant improvements to training time.

  • Can be extended further with other caching implementation like MapDB (which supports on-disk caching)

@danyaljj
Copy link
Member

danyaljj commented Mar 5, 2017

One big concern I have is the confusion that it might create a little confusion with cache = true (vs isStatic ). Especially in the documentation here. We might consider changing the terminology and clarify the difference (+use cases).

val a = new BooleanProperty[T](name, cachedF) with NodeProperty[T] { override def node: Node[T] = papply.node }
val a = new BooleanProperty[T](name, cachedF) with NodeProperty[T] {
override def node: Node[T] = papply.node
override val isCachingEnabled: Boolean = isStatic
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe change isCachingEnabled to sth closed to static? isStatic (or isStaticEnabled) itself sounds more clear

@danyaljj
Copy link
Member

danyaljj commented Mar 5, 2017

On the implementation, I'd suggestion different approach: we can reuse the existing caching. The only thing we have to do is to make sure we don't clean in between each training iterations. That is handled here by this function.. So the only change needed is, not calling the clear function for properties for which isStatic is specified.

@bhargav bhargav force-pushed the property-in_memory-caching branch from c17096e to 699f238 Compare March 11, 2017 23:21
@bhargav bhargav force-pushed the property-in_memory-caching branch from ce9450a to 08dec8b Compare April 9, 2017 04:19
@bhargav bhargav changed the title [WIP] Enable in-memory feature caching for properties Enable in-memory feature caching for properties Apr 9, 2017
@bhargav bhargav requested a review from kordjamshidi April 9, 2017 04:40
@bhargav
Copy link
Contributor Author

bhargav commented Apr 9, 2017

This is ready to be reviewed.

Copy link
Member

@kordjamshidi kordjamshidi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one renaming suggestions, otherwise this is good to me to merge.

If you want to cache the value of a feature during a single iteration, use the `cache` parameter.

The `cache` parameter allows the value to be cached within a training/testing iteration. This is useful if you one of your features depends on evaluation of a Classifier on other instances as well. This recursive evaluation of the Classifier might be expensive and caching would speed-up performance. Look at a sample usage of this parameter in the [POSTagging Example](../../saul-examples/src/main/scala/edu/illinois/cs/cogcomp/saulexamples/nlp/POSTagger/POSDataModel.scala#L66).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you one of your => if one of your

val posWindow = property(token, cache = true) {
(t: ConllRawToken) => t.getNeighbors.map(n => posWindow(n))
}
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe iterationCache or perIterationCache? (instead of cache)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants