| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
An example where the bot answers some sample questions:
NOTE: ChatDOCx is experimental and may not work properly. Please provide context-based questions for better results.
We will use the following models for our chatbot:
Facebook AI's RoBERTa (Robustly Optimized BERT Approach) is an improvement to Google AI's BERT (Bidirectional Encoder Representations from Transformers). While BERT laid the foundation for transformer-based models in NLP, RoBERTa further optimized the pre-training process and achieved better performance by leveraging larger datasets and advanced training techniques:
Advanced Training Techniques: RoBERTa incorporated techniques such as dynamic masking and increased batch sizes. Dynamic masking involves masking tokens dynamically during pre-training, allowing the model to focus more on learning contextual information. Additionally, RoBERTa used larger mini-batches during training, which helped in better generalization and optimization.
Focus on Masked Language Modeling (MLM): Unlike BERT, which also included the next sentence prediction (NSP) task during pre-training, RoBERTa focused solely on the MLM task. By dedicating all resources to improving the accuracy of predicting masked tokens, RoBERTa was able to fine-tune its language understanding capabilities more effectively.
BART (Bidirectional and Auto-Regressive Transformers) is a sequence-to-sequence model introduced by Facebook AI:
Bidirectional: It can process input sequences in both forward and backward directions. This bidirectional capability enables BART to capture context from both preceding and succeeding tokens, enhancing its understanding of the input sequence.
Auto-Regressive: It employs an auto-regressive decoding strategy during generation, where it generates one token at a time from left to right based on the previously generated tokens. This approach ensures that each token is conditioned on the tokens generated before it, allowing it to produce coherent and contextually relevant outputs.
First up, install all the required Python dependencies by running: pip install -r requirements.txt
NOTE: Development environment is Windows/Python version 3.12.2 (there can always be version conflicts between the dependencies, OS, hardware etc.).
The web application is powered by Flask, run it with: python nlp.py. In the command window, you should see something like WARNING: This is a development server. Do not use it in a production deployment.
Which is your web adress (just copy paste it in your browser to access the app). Please refer to Features to customize the app.
The following can be configured in mylib/config.json:
{
"qa_model_name": "deepset/roberta-base-squad2",
"summary_model_name": "facebook/bart-large-cnn",
"app_name": "",
"use_stopwords": true
}Setting domains/topics is a core component of the chatbot as it performs better if the data is structured as a single domain, because it will help the bot to remember the context behind the data when asking questions.
When you run the app, you are enforced to select a domain to start asking questions, not because you can, but because you get better responses :) So just select a domain, ask your question and then press Enter or click Submit, as seen from the example at the start.
After selecting a domain, simply include the keywords summary or summarize in your input question e.g., summary of transformers, summarize nlp etc., to get a summary of the domain:
NOTE: Text summarization appears to be a bit slow. Performance probably depends on the model, the amount of data etc.
The chatbot can be highly customized as many functions are designed from scratch with flexibility. For instance:
{% set topic_colors = {'Contacts': '#FFD700', 'Links': '#FFD700', 'Errors': '#f36262'} %}NOTE: Links are also matched to your questions. In the example below, the keyword transformers in your question is also in the links.json database, which gives you a streamlined answer to learn more about transformers as a clickable link.
Errors will be shown on the red bar in the app. Implemented logic to handle domain selection, empty/short inputs, questions outside the scope of chatbot to prevent misinformation. Below is the showcase, including an example where the bot handles questions outside the scope of its knowledge (NOTE: use_stopwords will enhance this function):
saimj7/ 14-04-2024 - © Sai_Mj.
| Back | FazBrowse Home | New Git URL |