nlp

Torchtext AttributeError: 'Example' object has no attribute 'text_content'

Deadly 提交于 2020-08-23 05:04:03
问题 I'm working with RNN and using Pytorch & Torchtext. I've got a problem with building vocab in my RNN. My code is as follows: TEXT = Field(tokenize=tokenizer, lower=True) LABEL = LabelField(dtype=torch.float) trainds = TabularDataset( path='drive/{}'.format(TRAIN_PATH), format='tsv', fields=[ ('label_start', LABEL), ('label_end', None), ('title', None), ('symbol', None), ('text_content', TEXT), ]) testds = TabularDataset( path='drive/{}'.format(TEST_PATH), format='tsv', fields=[ ('text_content

Torchtext AttributeError: 'Example' object has no attribute 'text_content'

不羁岁月 提交于 2020-08-23 05:02:16
问题 I'm working with RNN and using Pytorch & Torchtext. I've got a problem with building vocab in my RNN. My code is as follows: TEXT = Field(tokenize=tokenizer, lower=True) LABEL = LabelField(dtype=torch.float) trainds = TabularDataset( path='drive/{}'.format(TRAIN_PATH), format='tsv', fields=[ ('label_start', LABEL), ('label_end', None), ('title', None), ('symbol', None), ('text_content', TEXT), ]) testds = TabularDataset( path='drive/{}'.format(TEST_PATH), format='tsv', fields=[ ('text_content

Extracting Related Date and Location from a sentence

a 夏天 提交于 2020-08-10 23:00:31
问题 I'm working with written text (paragraphs of articles and books) that includes both locations and dates. I want to extract from the texts pairs that contain locations and dates that are associated with one another. For example, given the following phrase: The man left Amsterdam on January and reached Nepal on October 21st I would have an output such as this: >>>[(Amsterdam, January), (Nepal, October 21st)] I tried splitting the text through "connecting words" (such as "and" for example) and

Extracting Related Date and Location from a sentence

▼魔方 西西 提交于 2020-08-10 22:58:52
问题 I'm working with written text (paragraphs of articles and books) that includes both locations and dates. I want to extract from the texts pairs that contain locations and dates that are associated with one another. For example, given the following phrase: The man left Amsterdam on January and reached Nepal on October 21st I would have an output such as this: >>>[(Amsterdam, January), (Nepal, October 21st)] I tried splitting the text through "connecting words" (such as "and" for example) and

Keras model.predict giving same values

China☆狼群 提交于 2020-08-10 19:31:34
问题 I am using Keras model.predict to get label for new sentences not present in the dataset. But the prediction is always giving the same value irrespective of the sentence. Here is my prediction code from sklearn.preprocessing import LabelEncoder maxlen = 300 ### PREDICT NEW UNSEEN DATA ### tokenizer = Tokenizer() label_enc = LabelEncoder() label_enc.fit(tar_list) X_test = ['asdsadav dawd','this is boring', 'wow i like this you did a great job', 'ima cry tht was mean','1 nov 1968 george

How should properly formatted data for NER in BERT look like?

别来无恙 提交于 2020-08-09 08:57:28
问题 I am using Huggingface's transformers library and want to perform NER using BERT. I tried to find an explicit example of how to properly format the data for NER using BERT. It is not entirely clear to me from the paper and the comments I've found. Let's say we have a following sentence and labels: sent = "John Johanson lives in Ramat Gan." labels = ['B-PER', 'I-PER', 'O', 'O', 'B-LOC', 'I-LOC'] Would data that we input to the model be something like this: sent = ['[CLS]', 'john', 'johan', '#

OpenAI GPT-2 model use with TensorFlow JS

不打扰是莪最后的温柔 提交于 2020-08-08 08:22:26
问题 Is that possible to generate texts from OpenAI GPT-2 using TensorFlowJS? If not what is the limitation, like model format or ...? 回答1: I don't see any reason as to why not, other than maybe some operation that is in gpt-2 that is not supported by tensorflowjs. I don't know how to do it, but here's a nice starting point: install.sh python3 -m pip install -q git+https://github.com/huggingface/transformers.git python3 -m pip install tensorflow tensorflowjs save.py from transformers import

OpenAI GPT-2 model use with TensorFlow JS

自古美人都是妖i 提交于 2020-08-08 08:20:52
问题 Is that possible to generate texts from OpenAI GPT-2 using TensorFlowJS? If not what is the limitation, like model format or ...? 回答1: I don't see any reason as to why not, other than maybe some operation that is in gpt-2 that is not supported by tensorflowjs. I don't know how to do it, but here's a nice starting point: install.sh python3 -m pip install -q git+https://github.com/huggingface/transformers.git python3 -m pip install tensorflow tensorflowjs save.py from transformers import