Exemple #1
0
def test_experiment(assess_reader):
    def fit_maxent(X, y):
        mod = LogisticRegression(solver='liblinear', multi_class='auto')
        mod.fit(X, y)
        return mod
    nli.experiment(
        train_reader=nli.SNLITrainReader(snli_home, samp_percentage=0.01),
        phi=lambda x, y: {"$UNK": 1},
        train_func=fit_maxent,
        assess_reader=assess_reader,
        random_state=42)
Exemple #2
0
def test_experiment():
    def fit_maxent(X, y):
        mod = LogisticRegression()
        mod.fit(X, y)
        return mod

    nli.experiment(train_reader=nli.SNLITrainReader(samp_percentage=0.01),
                   phi=lambda x, y: {"$UNK": 1},
                   train_func=fit_maxent,
                   assess_reader=None,
                   random_state=42)
Exemple #3
0
def main():
    exp = nli.experiment(train_reader=nli.SNLITrainReader(SNLI_HOME,
                                                          samp_percentage=1.0),
                         assess_reader=nli.SNLIDevReader(SNLI_HOME,
                                                         samp_percentage=1.0),
                         phi=sentence_encoding_rnn_phi,
                         train_func=fit_bilstm_attention,
                         random_state=None,
                         vectorize=False)
    print(exp)
# In[19]:

dataset = nli.build_dataset(train_reader, word_overlap_phi)

# In[20]:

dataset.keys()

# However, it's more efficient to use `nli.experiment` to bring all these pieces together. This wrapper will work for all the models we consider.

# In[21]:

_ = nli.experiment(train_reader=nli.SNLITrainReader(SNLI_HOME,
                                                    samp_percentage=0.10,
                                                    random_state=42),
                   phi=word_overlap_phi,
                   train_func=fit_softmax_with_crossvalidation,
                   assess_reader=None,
                   random_state=42)

# In[12]:

_ = nli.experiment(train_reader=nli.SNLITrainReader(SNLI_HOME,
                                                    samp_percentage=0.10,
                                                    random_state=42),
                   phi=word_cross_product_phi,
                   train_func=fit_softmax_with_crossvalidation,
                   assess_reader=None,
                   random_state=42)

# As expected `word_cross_product_phi` is very strong. At this point, one might consider scaling up to `samp_percentage=None`, i.e., the full training set. Such a baseline is very similar to the one established in [the original SNLI paper by Bowman et al.](https://aclanthology.info/papers/D15-1075/d15-1075) for models like this one.