Prepare a data.table of queries and variables for the FMAT.
Arguments
- query
Query text (should be a character string/vector with at least one
[MASK]
token). Multiple queries share the same set ofMASK
,TARGET
, andATTRIB
. For multiple queries with differentMASK
,TARGET
, and/orATTRIB
, please useFMAT_query_bind
to combine them.- MASK
A named list of
[MASK]
target words. Must be single words in the vocabulary of a certain masked language model.For model vocabulary, see, e.g., https://huggingface.co/bert-base-uncased/raw/main/vocab.txt
Infrequent words may be not included in a model's vocabulary, and in this case you may insert the words into the context by specifying either
TARGET
orATTRIB
.- TARGET, ATTRIB
A named list of Target/Attribute words or phrases. If specified, then
query
must contain{TARGET}
and/or{ATTRIB}
(in all uppercase and in braces) to be replaced by the words/phrases.
Examples
FMAT_query("[MASK] is a nurse.", MASK = .(Male="He", Female="She"))
#> query MASK M_pair M_word
#> <fctr> <fctr> <fctr> <fctr>
#> 1: [MASK] is a nurse. Male 1 He
#> 2: [MASK] is a nurse. Female 1 She
FMAT_query(
c("[MASK] is {TARGET}.", "[MASK] works as {TARGET}."),
MASK = .(Male="He", Female="She"),
TARGET = .(Occupation=cc("a doctor, a nurse, an artist"))
)
#> qid query MASK M_pair M_word TARGET
#> <fctr> <fctr> <fctr> <fctr> <fctr> <fctr>
#> 1: 1 [MASK] is {TARGET}. Male 1 He Occupation
#> 2: 1 [MASK] is {TARGET}. Female 1 She Occupation
#> 3: 1 [MASK] is {TARGET}. Male 1 He Occupation
#> 4: 1 [MASK] is {TARGET}. Female 1 She Occupation
#> 5: 1 [MASK] is {TARGET}. Male 1 He Occupation
#> 6: 1 [MASK] is {TARGET}. Female 1 She Occupation
#> 7: 2 [MASK] works as {TARGET}. Male 1 He Occupation
#> 8: 2 [MASK] works as {TARGET}. Female 1 She Occupation
#> 9: 2 [MASK] works as {TARGET}. Male 1 He Occupation
#> 10: 2 [MASK] works as {TARGET}. Female 1 She Occupation
#> 11: 2 [MASK] works as {TARGET}. Male 1 He Occupation
#> 12: 2 [MASK] works as {TARGET}. Female 1 She Occupation
#> T_pair T_word
#> <fctr> <fctr>
#> 1: Occupation.1 a doctor
#> 2: Occupation.1 a doctor
#> 3: Occupation.2 a nurse
#> 4: Occupation.2 a nurse
#> 5: Occupation.3 an artist
#> 6: Occupation.3 an artist
#> 7: Occupation.1 a doctor
#> 8: Occupation.1 a doctor
#> 9: Occupation.2 a nurse
#> 10: Occupation.2 a nurse
#> 11: Occupation.3 an artist
#> 12: Occupation.3 an artist
FMAT_query(
"The [MASK] {ATTRIB}.",
MASK = .(Male=cc("man, boy"),
Female=cc("woman, girl")),
ATTRIB = .(Masc=cc("is masculine, has a masculine personality"),
Femi=cc("is feminine, has a feminine personality"))
)
#> query MASK M_pair M_word ATTRIB A_pair
#> <fctr> <fctr> <fctr> <fctr> <fctr> <fctr>
#> 1: The [MASK] {ATTRIB}. Male 1 man Masc Masc-Femi.1
#> 2: The [MASK] {ATTRIB}. Male 2 boy Masc Masc-Femi.1
#> 3: The [MASK] {ATTRIB}. Female 1 woman Masc Masc-Femi.1
#> 4: The [MASK] {ATTRIB}. Female 2 girl Masc Masc-Femi.1
#> 5: The [MASK] {ATTRIB}. Male 1 man Masc Masc-Femi.2
#> 6: The [MASK] {ATTRIB}. Male 2 boy Masc Masc-Femi.2
#> 7: The [MASK] {ATTRIB}. Female 1 woman Masc Masc-Femi.2
#> 8: The [MASK] {ATTRIB}. Female 2 girl Masc Masc-Femi.2
#> 9: The [MASK] {ATTRIB}. Male 1 man Femi Masc-Femi.1
#> 10: The [MASK] {ATTRIB}. Male 2 boy Femi Masc-Femi.1
#> 11: The [MASK] {ATTRIB}. Female 1 woman Femi Masc-Femi.1
#> 12: The [MASK] {ATTRIB}. Female 2 girl Femi Masc-Femi.1
#> 13: The [MASK] {ATTRIB}. Male 1 man Femi Masc-Femi.2
#> 14: The [MASK] {ATTRIB}. Male 2 boy Femi Masc-Femi.2
#> 15: The [MASK] {ATTRIB}. Female 1 woman Femi Masc-Femi.2
#> 16: The [MASK] {ATTRIB}. Female 2 girl Femi Masc-Femi.2
#> A_word
#> <fctr>
#> 1: is masculine
#> 2: is masculine
#> 3: is masculine
#> 4: is masculine
#> 5: has a masculine personality
#> 6: has a masculine personality
#> 7: has a masculine personality
#> 8: has a masculine personality
#> 9: is feminine
#> 10: is feminine
#> 11: is feminine
#> 12: is feminine
#> 13: has a feminine personality
#> 14: has a feminine personality
#> 15: has a feminine personality
#> 16: has a feminine personality
FMAT_query(
"The association between {TARGET} and {ATTRIB} is [MASK].",
MASK = .(H="strong", L="weak"),
TARGET = .(Flower=cc("rose, iris, lily"),
Insect=cc("ant, cockroach, spider")),
ATTRIB = .(Pos=cc("health, happiness, love, peace"),
Neg=cc("death, sickness, hatred, disaster"))
)
#> query MASK M_pair
#> <fctr> <fctr> <fctr>
#> 1: The association between {TARGET} and {ATTRIB} is [MASK]. H 1
#> 2: The association between {TARGET} and {ATTRIB} is [MASK]. L 1
#> 3: The association between {TARGET} and {ATTRIB} is [MASK]. H 1
#> 4: The association between {TARGET} and {ATTRIB} is [MASK]. L 1
#> 5: The association between {TARGET} and {ATTRIB} is [MASK]. H 1
#> 6: The association between {TARGET} and {ATTRIB} is [MASK]. L 1
#> 7: The association between {TARGET} and {ATTRIB} is [MASK]. H 1
#> 8: The association between {TARGET} and {ATTRIB} is [MASK]. L 1
#> 9: The association between {TARGET} and {ATTRIB} is [MASK]. H 1
#> 10: The association between {TARGET} and {ATTRIB} is [MASK]. L 1
#> 11: The association between {TARGET} and {ATTRIB} is [MASK]. H 1
#> 12: The association between {TARGET} and {ATTRIB} is [MASK]. L 1
#> 13: The association between {TARGET} and {ATTRIB} is [MASK]. H 1
#> 14: The association between {TARGET} and {ATTRIB} is [MASK]. L 1
#> 15: The association between {TARGET} and {ATTRIB} is [MASK]. H 1
#> 16: The association between {TARGET} and {ATTRIB} is [MASK]. L 1
#> 17: The association between {TARGET} and {ATTRIB} is [MASK]. H 1
#> 18: The association between {TARGET} and {ATTRIB} is [MASK]. L 1
#> 19: The association between {TARGET} and {ATTRIB} is [MASK]. H 1
#> 20: The association between {TARGET} and {ATTRIB} is [MASK]. L 1
#> 21: The association between {TARGET} and {ATTRIB} is [MASK]. H 1
#> 22: The association between {TARGET} and {ATTRIB} is [MASK]. L 1
#> 23: The association between {TARGET} and {ATTRIB} is [MASK]. H 1
#> 24: The association between {TARGET} and {ATTRIB} is [MASK]. L 1
#> 25: The association between {TARGET} and {ATTRIB} is [MASK]. H 1
#> 26: The association between {TARGET} and {ATTRIB} is [MASK]. L 1
#> 27: The association between {TARGET} and {ATTRIB} is [MASK]. H 1
#> 28: The association between {TARGET} and {ATTRIB} is [MASK]. L 1
#> 29: The association between {TARGET} and {ATTRIB} is [MASK]. H 1
#> 30: The association between {TARGET} and {ATTRIB} is [MASK]. L 1
#> 31: The association between {TARGET} and {ATTRIB} is [MASK]. H 1
#> 32: The association between {TARGET} and {ATTRIB} is [MASK]. L 1
#> 33: The association between {TARGET} and {ATTRIB} is [MASK]. H 1
#> 34: The association between {TARGET} and {ATTRIB} is [MASK]. L 1
#> 35: The association between {TARGET} and {ATTRIB} is [MASK]. H 1
#> 36: The association between {TARGET} and {ATTRIB} is [MASK]. L 1
#> 37: The association between {TARGET} and {ATTRIB} is [MASK]. H 1
#> 38: The association between {TARGET} and {ATTRIB} is [MASK]. L 1
#> 39: The association between {TARGET} and {ATTRIB} is [MASK]. H 1
#> 40: The association between {TARGET} and {ATTRIB} is [MASK]. L 1
#> 41: The association between {TARGET} and {ATTRIB} is [MASK]. H 1
#> 42: The association between {TARGET} and {ATTRIB} is [MASK]. L 1
#> 43: The association between {TARGET} and {ATTRIB} is [MASK]. H 1
#> 44: The association between {TARGET} and {ATTRIB} is [MASK]. L 1
#> 45: The association between {TARGET} and {ATTRIB} is [MASK]. H 1
#> 46: The association between {TARGET} and {ATTRIB} is [MASK]. L 1
#> 47: The association between {TARGET} and {ATTRIB} is [MASK]. H 1
#> 48: The association between {TARGET} and {ATTRIB} is [MASK]. L 1
#> 49: The association between {TARGET} and {ATTRIB} is [MASK]. H 1
#> 50: The association between {TARGET} and {ATTRIB} is [MASK]. L 1
#> 51: The association between {TARGET} and {ATTRIB} is [MASK]. H 1
#> 52: The association between {TARGET} and {ATTRIB} is [MASK]. L 1
#> 53: The association between {TARGET} and {ATTRIB} is [MASK]. H 1
#> 54: The association between {TARGET} and {ATTRIB} is [MASK]. L 1
#> 55: The association between {TARGET} and {ATTRIB} is [MASK]. H 1
#> 56: The association between {TARGET} and {ATTRIB} is [MASK]. L 1
#> 57: The association between {TARGET} and {ATTRIB} is [MASK]. H 1
#> 58: The association between {TARGET} and {ATTRIB} is [MASK]. L 1
#> 59: The association between {TARGET} and {ATTRIB} is [MASK]. H 1
#> 60: The association between {TARGET} and {ATTRIB} is [MASK]. L 1
#> 61: The association between {TARGET} and {ATTRIB} is [MASK]. H 1
#> 62: The association between {TARGET} and {ATTRIB} is [MASK]. L 1
#> 63: The association between {TARGET} and {ATTRIB} is [MASK]. H 1
#> 64: The association between {TARGET} and {ATTRIB} is [MASK]. L 1
#> 65: The association between {TARGET} and {ATTRIB} is [MASK]. H 1
#> 66: The association between {TARGET} and {ATTRIB} is [MASK]. L 1
#> 67: The association between {TARGET} and {ATTRIB} is [MASK]. H 1
#> 68: The association between {TARGET} and {ATTRIB} is [MASK]. L 1
#> 69: The association between {TARGET} and {ATTRIB} is [MASK]. H 1
#> 70: The association between {TARGET} and {ATTRIB} is [MASK]. L 1
#> 71: The association between {TARGET} and {ATTRIB} is [MASK]. H 1
#> 72: The association between {TARGET} and {ATTRIB} is [MASK]. L 1
#> 73: The association between {TARGET} and {ATTRIB} is [MASK]. H 1
#> 74: The association between {TARGET} and {ATTRIB} is [MASK]. L 1
#> 75: The association between {TARGET} and {ATTRIB} is [MASK]. H 1
#> 76: The association between {TARGET} and {ATTRIB} is [MASK]. L 1
#> 77: The association between {TARGET} and {ATTRIB} is [MASK]. H 1
#> 78: The association between {TARGET} and {ATTRIB} is [MASK]. L 1
#> 79: The association between {TARGET} and {ATTRIB} is [MASK]. H 1
#> 80: The association between {TARGET} and {ATTRIB} is [MASK]. L 1
#> 81: The association between {TARGET} and {ATTRIB} is [MASK]. H 1
#> 82: The association between {TARGET} and {ATTRIB} is [MASK]. L 1
#> 83: The association between {TARGET} and {ATTRIB} is [MASK]. H 1
#> 84: The association between {TARGET} and {ATTRIB} is [MASK]. L 1
#> 85: The association between {TARGET} and {ATTRIB} is [MASK]. H 1
#> 86: The association between {TARGET} and {ATTRIB} is [MASK]. L 1
#> 87: The association between {TARGET} and {ATTRIB} is [MASK]. H 1
#> 88: The association between {TARGET} and {ATTRIB} is [MASK]. L 1
#> 89: The association between {TARGET} and {ATTRIB} is [MASK]. H 1
#> 90: The association between {TARGET} and {ATTRIB} is [MASK]. L 1
#> 91: The association between {TARGET} and {ATTRIB} is [MASK]. H 1
#> 92: The association between {TARGET} and {ATTRIB} is [MASK]. L 1
#> 93: The association between {TARGET} and {ATTRIB} is [MASK]. H 1
#> 94: The association between {TARGET} and {ATTRIB} is [MASK]. L 1
#> 95: The association between {TARGET} and {ATTRIB} is [MASK]. H 1
#> 96: The association between {TARGET} and {ATTRIB} is [MASK]. L 1
#> query MASK M_pair
#> M_word TARGET T_word ATTRIB A_word
#> <fctr> <fctr> <fctr> <fctr> <fctr>
#> 1: strong Flower rose Pos health
#> 2: weak Flower rose Pos health
#> 3: strong Flower iris Pos health
#> 4: weak Flower iris Pos health
#> 5: strong Flower lily Pos health
#> 6: weak Flower lily Pos health
#> 7: strong Flower rose Pos happiness
#> 8: weak Flower rose Pos happiness
#> 9: strong Flower iris Pos happiness
#> 10: weak Flower iris Pos happiness
#> 11: strong Flower lily Pos happiness
#> 12: weak Flower lily Pos happiness
#> 13: strong Flower rose Pos love
#> 14: weak Flower rose Pos love
#> 15: strong Flower iris Pos love
#> 16: weak Flower iris Pos love
#> 17: strong Flower lily Pos love
#> 18: weak Flower lily Pos love
#> 19: strong Flower rose Pos peace
#> 20: weak Flower rose Pos peace
#> 21: strong Flower iris Pos peace
#> 22: weak Flower iris Pos peace
#> 23: strong Flower lily Pos peace
#> 24: weak Flower lily Pos peace
#> 25: strong Flower rose Neg death
#> 26: weak Flower rose Neg death
#> 27: strong Flower iris Neg death
#> 28: weak Flower iris Neg death
#> 29: strong Flower lily Neg death
#> 30: weak Flower lily Neg death
#> 31: strong Flower rose Neg sickness
#> 32: weak Flower rose Neg sickness
#> 33: strong Flower iris Neg sickness
#> 34: weak Flower iris Neg sickness
#> 35: strong Flower lily Neg sickness
#> 36: weak Flower lily Neg sickness
#> 37: strong Flower rose Neg hatred
#> 38: weak Flower rose Neg hatred
#> 39: strong Flower iris Neg hatred
#> 40: weak Flower iris Neg hatred
#> 41: strong Flower lily Neg hatred
#> 42: weak Flower lily Neg hatred
#> 43: strong Flower rose Neg disaster
#> 44: weak Flower rose Neg disaster
#> 45: strong Flower iris Neg disaster
#> 46: weak Flower iris Neg disaster
#> 47: strong Flower lily Neg disaster
#> 48: weak Flower lily Neg disaster
#> 49: strong Insect ant Pos health
#> 50: weak Insect ant Pos health
#> 51: strong Insect cockroach Pos health
#> 52: weak Insect cockroach Pos health
#> 53: strong Insect spider Pos health
#> 54: weak Insect spider Pos health
#> 55: strong Insect ant Pos happiness
#> 56: weak Insect ant Pos happiness
#> 57: strong Insect cockroach Pos happiness
#> 58: weak Insect cockroach Pos happiness
#> 59: strong Insect spider Pos happiness
#> 60: weak Insect spider Pos happiness
#> 61: strong Insect ant Pos love
#> 62: weak Insect ant Pos love
#> 63: strong Insect cockroach Pos love
#> 64: weak Insect cockroach Pos love
#> 65: strong Insect spider Pos love
#> 66: weak Insect spider Pos love
#> 67: strong Insect ant Pos peace
#> 68: weak Insect ant Pos peace
#> 69: strong Insect cockroach Pos peace
#> 70: weak Insect cockroach Pos peace
#> 71: strong Insect spider Pos peace
#> 72: weak Insect spider Pos peace
#> 73: strong Insect ant Neg death
#> 74: weak Insect ant Neg death
#> 75: strong Insect cockroach Neg death
#> 76: weak Insect cockroach Neg death
#> 77: strong Insect spider Neg death
#> 78: weak Insect spider Neg death
#> 79: strong Insect ant Neg sickness
#> 80: weak Insect ant Neg sickness
#> 81: strong Insect cockroach Neg sickness
#> 82: weak Insect cockroach Neg sickness
#> 83: strong Insect spider Neg sickness
#> 84: weak Insect spider Neg sickness
#> 85: strong Insect ant Neg hatred
#> 86: weak Insect ant Neg hatred
#> 87: strong Insect cockroach Neg hatred
#> 88: weak Insect cockroach Neg hatred
#> 89: strong Insect spider Neg hatred
#> 90: weak Insect spider Neg hatred
#> 91: strong Insect ant Neg disaster
#> 92: weak Insect ant Neg disaster
#> 93: strong Insect cockroach Neg disaster
#> 94: weak Insect cockroach Neg disaster
#> 95: strong Insect spider Neg disaster
#> 96: weak Insect spider Neg disaster
#> M_word TARGET T_word ATTRIB A_word