代写COMPSCI 5096 TEXT AS DATA调试Haskell程序

DEGREES of MSci, MEng, BEng, BSc, MA and MA (Social Sciences)

TEXT AS DATA (M)

COMPSCI 5096

Wednesday, 20 May, 09:15 BST

1. This question is about tokenisation and similarity.

(a) This part concerns processing text. Consider the input string:

[He didn’t like the U.S. movie Snakes on a train, revenge of Viper-man!”, now playing in the U.K.]

(i)  Provide a tokenised form of the above string. Identify and discuss two elements of the above string that present ambiguities. Justify your tokenisation decision for each.  [3] (ii)  Compare and contrast ‘standard’ word-based tokenisation with the tokenisation method used by BERT. Illustrate key differences using the example provided.  Analyse and  discuss why they differ and their relative advantages and disadvantages. (Hint: Recall we used BERT’s tokeniser in Lab 1 and in the in-class embedding exercise.)           [4]

(b) Consider the two tokenized documents:

S1: [a, woman, is, under, a, mayan, curse]

S2: [a, woman, sees, a, mayan, shaman, to, lift, the, curse]

Create a Dictionary from the two documents above (S1 and S2) with appropriate ordering. Give your answer in the form of a table with ID and token. Discuss the following properties  of the dictionary and provide reasons for the decision:  1) what is included in the dictionary and 2) the order of the dictionary.                  [3]

(c) Critically evaluate the Bag-of-Words (BoW) model as a term weighting feature model for documents. Discuss its strengths and give three weaknesses of the model and propose a modification that addresses each. You should relate each to Sci-kit Learn vectorizers and their important parameters.                                                                                                [4]

(d) You are measuring the similarity between two molecular compounds for drug discovery  research. They have been processed to create a series of unique structural ‘fingerprints’ and a one-hot encoding of the compounds is created. A compound has tens of thousands  of fingerprints on average and all the compounds are approximately the same size. Also,  most of the compounds in the dataset share more than 90% of ngerprints in common. A  lab partner suggests using Jaccard overlap to measure the similarity between compounds. First, critically discuss why Jaccard is or is not appropriate for this task and the challenges  it presents. Second, propose and justify a change to both the representation and similarity measure to address them.                                                                  [6]

2. This question is about language modelling and classication.

(a) This task involves developing an order error corrector for a popular burger chain, ‘out-and-in burger’. Below is a table of five separate order interactions transcribed from a mobile app.

forget it i wanna eat a hamburger no i wanna eat a hamburger

i would like to eat breakfast

i would like to eat a cheeseburger and a beer would you like fries with that

Table 1: Five interactions for a burger restaurant ordering system.

Sample text collections statistics for a bigram model are below:

V = 22 unique words (including reserved tokens)

N = 45 tokens, including padding

(i)  Use the text provided in Table 1 above to compute word unigram probabilities. In a list  or table format complete the probability table with Laplace smoothing that has K = 0.5. Show your workings.  Discuss the impact on the probability values of increasing or decreasing the value of K. Describe the effect of K when these probabilities are used in  a spelling (error) correction task.

Word

Unigram Probability

breakfast

beer

hamburger

[5]

(ii)  A larger collection of restaurant ordering data is collected. It has the following statistics: N = 73194, V = 1996 from a total of 8565 documents (utterances).

Compute the bigram probability of the following sequence:

[i  might  like  a  cheeseburger]

with Stupid Backoff smoothing with default values. Collection statistics for the required  terms are provided below. Show your workings, including each bigram’s probability. Describe how and why a smoothing method is used here.    [6]

Term

Count

i

2815

might

4

like

1522

a

1051

cheeseburger

3

(si

1926

i might

0

might like

1

like a

49

a cheeseburger

3

cheeseburger (\s

2

(b) Compare and contrast the APIs for SKLearn Transformers (e.g.  Count or TF-IDF) and Classifiers/Predictors (e.g. NaiveBayes, LogisticRegression). Include descriptions of their key interface functions with descriptions of their behaviour.  Discuss how they are used together to solve machine learning tasks on text.                            [3]

(c) Below is a snippet of code to vectorize and classify text with Scikit-learn.  Assume that tokenize_normalize and evaluation_summary have been defined, as we did in the labs.  The input data has been pre-processed into a vector of unnormalized text documents (each a single string).

from  sklearn .feature_extraction .text  import  CountVectorizer

from  sklearn .linear_model  import  LogisticRegression

#  Data  processing

data  =   . . .  #  Loads  a  vector  of  raw  text  documents

train_index  =  int(len(data)  *  0 . 1)

train_data  =  data[:train_index,:]

validation_data  =  data[int(train_index *0 .2):,:]

test_data  =  data[train_index:,:]

#  Assume  corresponding  labels  for  each  data  subset

train_labels,  test_labels,  validation_labels  =  . . .

#  Vectorization

one_hot_vectorizer  =  CountVectorizer(tokenizer=tokenize_normalize,

binary=True,  max_features=20)   one_hot_vectorizer .fit(train_data)

train_features  =  one_hot_vectorizer .transform(train_features)

validation_features  =  one_hot_vectorizer .fit_transform(validation_data) test_features  =  one_hot_vectorizer .transform(test_data)

#  Classification

lr  =  LogisticRegression(solver=’saga’,  max_iter=500)

lr_model  =  lr .fit(train_features,  train_labels)

evaluation_summary("LR  Train  summary",

lr_model .predict(train_features),  validation_labels)

lr_model  =  lr .fit(validation_features,  validation_features)

evaluation_summary("LR  Validation  summary",

lr_model .predict(validation_features),  validation_labels) lr_model  =  lr .fit(test_features,  test_labels)

evaluation_summary("LR  Test  summary",

lr_model .predict(validation_features),  test_labels)

Copy and paste the code above and fix its mistakes. Although there may be more, discuss three important mistakes with their consequence, one from each section (data processing, vectorization, classification).                     [6]

3. This question is about word embedding models and Natural Language Processing.

(a) Compare and contrast static word embeddings with contextual embedding models. Discuss the trade-offs between them for downstream tasks.                           [4]

(b) Using your knowledge of the self-attention mechanism, answer the following question considering the following sentence:

S1: [The president of the European Union spoke]

Use the following weight matrices and layer parameters to compute the unnormalised attention weights between the query president” and the keys “spoke” and “the”. What can you infer from these values?

Token

X weights

the

president of

the

european union

spoke

[0,1]

[1,-1]

[1,2]

[0,1]

[1,2]

[1,2]

[2,0]

[3]

(c) Explain how and why attention-based encoders can be “stacked” to form layers in Trans- former models.                  [2]

(d) In this question we explore what can be done when faced with a completely alien” scenario. Klingon is a language originating from TV series Star Trek. Many classic works such as  Hamlet, Much Ado About Nothing, Tao Te Ching, and Gilgamesh have been translated  by hand to Klingon. It is studied and formalised by the Klingon Language Institute (KLI) and was designed to be dissimilar from English. Below are some sample Klingon-English  translations.

Klingon

Approximate English Translation

taH pagh, taHbe’ bIpIv’a’

munglIj nuq

Huch ar DaneH?

Whether to continue, or not to continue [existence]

How are you? Where are you from? How much is this?

Figure 1: Sample sentences in Klingon

We will use knowledge of text processing and NLP to understand what is being said by Klingons and the actors portraying them in the Star Trek series.

(i)  Describe the process for pre-training BERT on Klingon.  Briefly describe what is required and any changes needed for the model.           [3]

(ii)  We want to identify when an actor makes a mistake (uses an incorrect word) when reciting a Klingon sentence from the script. Describe how to apply BERT to identify and to suggest xes for likely mistakes.               [4]

(iii)  We want to build a Klingon intent classifier to distinguish between ‘romance’, ‘anger’, and ‘other’ utterances. Describe how you would use an existing pre-trained Klingon BERT model for this task. Describe the data required and important challenges.     [4]


热门主题

课程名

mktg2509 csci 2600 38170 lng302 csse3010 phas3226 77938 arch1162 engn4536/engn6536 acx5903 comp151101 phl245 cse12 comp9312 stat3016/6016 phas0038 comp2140 6qqmb312 xjco3011 rest0005 ematm0051 5qqmn219 lubs5062m eee8155 cege0100 eap033 artd1109 mat246 etc3430 ecmm462 mis102 inft6800 ddes9903 comp6521 comp9517 comp3331/9331 comp4337 comp6008 comp9414 bu.231.790.81 man00150m csb352h math1041 eengm4100 isys1002 08 6057cem mktg3504 mthm036 mtrx1701 mth3241 eeee3086 cmp-7038b cmp-7000a ints4010 econ2151 infs5710 fins5516 fin3309 fins5510 gsoe9340 math2007 math2036 soee5010 mark3088 infs3605 elec9714 comp2271 ma214 comp2211 infs3604 600426 sit254 acct3091 bbt405 msin0116 com107/com113 mark5826 sit120 comp9021 eco2101 eeen40700 cs253 ece3114 ecmm447 chns3000 math377 itd102 comp9444 comp(2041|9044) econ0060 econ7230 mgt001371 ecs-323 cs6250 mgdi60012 mdia2012 comm221001 comm5000 ma1008 engl642 econ241 com333 math367 mis201 nbs-7041x meek16104 econ2003 comm1190 mbas902 comp-1027 dpst1091 comp7315 eppd1033 m06 ee3025 msci231 bb113/bbs1063 fc709 comp3425 comp9417 econ42915 cb9101 math1102e chme0017 fc307 mkt60104 5522usst litr1-uc6201.200 ee1102 cosc2803 math39512 omp9727 int2067/int5051 bsb151 mgt253 fc021 babs2202 mis2002s phya21 18-213 cege0012 mdia1002 math38032 mech5125 07 cisc102 mgx3110 cs240 11175 fin3020s eco3420 ictten622 comp9727 cpt111 de114102d mgm320h5s bafi1019 math21112 efim20036 mn-3503 fins5568 110.807 bcpm000028 info6030 bma0092 bcpm0054 math20212 ce335 cs365 cenv6141 ftec5580 math2010 ec3450 comm1170 ecmt1010 csci-ua.0480-003 econ12-200 ib3960 ectb60h3f cs247—assignment tk3163 ics3u ib3j80 comp20008 comp9334 eppd1063 acct2343 cct109 isys1055/3412 math350-real math2014 eec180 stat141b econ2101 msinm014/msing014/msing014b fit2004 comp643 bu1002 cm2030
联系我们
EMail: 99515681@qq.com
QQ: 99515681
留学生作业帮-留学生的知心伴侣!
工作时间:08:00-21:00
python代写
微信客服:codinghelp
站长地图