Commit a9fe09e5 authored by Leo Gao's avatar Leo Gao
Browse files

Update interface

parent ea7c5a2c
......@@ -6,7 +6,9 @@ import collections
class LM(abc.ABC):
@abc.abstractmethod
def loglikelihood(self, requests):
"""Compute log-likelihood of generating a continuation from a context
"""Compute log-likelihood of generating a continuation from a context.
Downstream tasks should attempt to use loglikelihood instead of other
LM calls whenever possible.
:param requests: list
A list of pairs (context, continuation)
......@@ -35,7 +37,7 @@ class LM(abc.ABC):
Context string
until: str
The string sequence to generate until. This string sequence may
span across msultiple tokens, or may be part of one token.
span across multiple tokens, or may be part of one token.
:return: list
A list of strings continuation
continuation: str
......@@ -112,7 +114,13 @@ class Dataset(abc.ABC):
pass
@abc.abstractmethod
def construct_requests(self, doc, nshot=0, prompt=False):
def construct_requests(self, ctx):
""" Uses RequestFactory to construct Requests and returns an iterable of
Requests which will be sent to the LM.
:param ctx: str
The context string, generated by fewshot_context.
"""
pass
@abc.abstractmethod
......@@ -134,6 +142,11 @@ class Dataset(abc.ABC):
aggregates them into one float. This should be the same for all
submetrics of the same name; if it differs, an error should be
raised.
:param doc:
The document as returned from training_docs, validation_docs, or test_docs.
:param results:
The results of the requests created in construct_requests.
"""
pass
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment