CMRC Metric


# find longest common string
def find_lcs(s1, s2):
    m = [[0 for i in range(len(s2)+1)] for j in range(len(s1)+1)]
    mmax = 0
    p = 0
    for i in range(len(s1)):
        for j in range(len(s2)):
            if s1[i] == s2[j]:
                m[i+1 …
more ...

【RL】Q Learning

import numpy as np
import gym
import random
import time
from IPython.display import clear_output
"""Creating the Environment"""
env = gym.make("FrozenLake-v0")
"""Creating the Q-Table and initializing all the Q-Values to zero for each state-action pair."""

action_space_size = env.action_space.n
state_space_size = env.observation_space …
more ...

【RL】User Simulator

User Simulator BackGround



  1. 需要收集大量实际的人机与人人的训练标注数据,昂贵且耗时。

  2. 此外,即 …

more ...

NLP Attention

Context attention - LSTM

Encoder and Decoder

class Attention(nn.Module):
    def __init__(self, method, hidden_size):
        super(Attention, self).__init__()
        self.method = method
        self.hidden_size = hidden_size

        if self.method == 'general':
            self.attention = nn.Linear(self.hidden_size, self.hidden_size)
        elif self.method …
more ...



    ELMo: Embeddings from Language models, BiLSTM vector concat,weighed hidden layers stacked

    • 与GloVe embedding最大区别,引入了上下文,contextualized word-embeddings (BERT, ELMo)

    • ELMo不会为每个单词使用固定的embedding向量,而是会在 …

    more ...