-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add stacked embedding in LanguageModel model #3165
Comments
Hello @datanerdo, you can combine your Flair language models with We do not yet have text generation as a trainable downstream task and use the |
Our main project objective is to automate the text generation of a report. We tried to customise our own embedding by following the tutorials in Chapters 5 and 7 from the book, "Natural Language Processing with Flair (by Tadej Magajna)". We have trained the forward and backward model separately. So the issue here is, we are unsure of how to stack both the forward & backward flair embeddings together. So far we have used the LanguageModel class in our model. However, we found that there is no parameter available in the class to allow us to use StackedEmbeddings. Do you have any suggestions on how to approach this matter? Also, as an alternative, we are thinking of using Seq2SeqGenerator class. We would like to ask your advice on this. Is it available in Flair and is it suitable for our project? If yes, do you have a tutorial for this that you can kindly share with us? If no, is it possible to add a parameter in LanguageModel class that can allow us to use StackedEmbeddings? Thank you for your kind help. We really appreciate it. |
Hello @datanerdo the two language models can each generate text, but they cannot be combined. The forward LM can generate likely continuations, which is probably what you are looking for. (The backward LM can only generate "previous" text in inverted form, so it is unlikely to be useful for text generation.) Have you tried using the from flair.models import LanguageModel
language_model = LanguageModel.load_language_model("resources/LMs/1BW-1024/best-lm.pt")
print(language_model)
# set a prefix you want to continue
prefix = 'The meaning of life is'
# generate 10 samples of text continuations
for i in range(10):
# print generated text (50 generated characters)
generated_continuation = language_model.generate_text(prefix, number_of_characters=50)
print(generated_continuation) Regarding Seq2SeqGenerator we don't have good support for Seq2Seq in Flair at the moment, so I cannot say how well this would work. |
yes that works for me! One final question; what is the best technique to evaluate language model in terms of its perplexity and to see how well our model generalizes? Thank you :)) |
Hello @datanerdo we typically do an "intrinsic" and an "extrinsic" evaluation. For the intrinsic evaluation, we compute perplexity on holdout data. This automatically happens when you train the model. In our case, the extrinsic evaluation is done using downstream NLP tasks like NER and PoS tagging: we use the language model as an embedding and see how well the downstream task is solved. In your case for text generation you could have a look a BLEU or other metrics that deal with text generation, provided you have suitable evaluation data. |
thanks Alan! will do |
Thank you for the clarification.
…On Fri, 14 Apr 2023, 21:10 Alan Akbik, ***@***.***> wrote:
Hello @datanerdo <https://github.com/datanerdo> we typically do an
"intrinsic" and an "extrinsic" evaluation. For the intrinsic evaluation, we
compute perplexity on holdout data. This automatically happens when you
train the model. In our case, the extrinsic evaluation is done using
downstream NLP tasks like NER and PoS tagging: we use the language model as
an embedding and see how well the downstream task is solved.
In your case for text generation you could have a look a BLEU or other
metrics that deal with text generation, provided you have suitable
evaluation data.
—
Reply to this email directly, view it on GitHub
<#3165 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ASSXLPEEQKIMFADBIJAPW7LXBFEDLANCNFSM6AAAAAAWJ5YVF4>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Hi. I did tried to use generate_text method and now the result is giving generated text and some number behind the generated text. What does that indicates? |
The number is the average log probability of the generated sample text. The higher the number, the more "unusual" is the sampling (i.e. more characters were sampled that were less likely given the text before). |
Hi @datanerdo |
Question
How to add stacked embedding features in our LanguageModel model? I have customised the embedding and done 2 models; forward and backward model for my text generation project, I didn't find the correct method to add the stacked embedding yet into the LanguageModel model..
The text was updated successfully, but these errors were encountered: