The Small Language Model Chatbot is a Python-based interactive chatbot built using Hugging Face's distilGPT-2
model. The chatbot is fun, lightweight, and ideal for demonstrating the capabilities of small-scale language models. It includes interactive widgets for user input and a visual element that tracks and displays the word count of user inputs over time.
This project is designed to run seamlessly in Google Colab.
- Accepts user input and generates meaningful responses using
distilGPT-2
. - Incorporates randomness and creativity in responses through fine-tuned parameters.
- Displays a bar chart to track the word count of user inputs for each interaction.
temperature=0.7
: Balances creativity and determinism.top_p=0.9
: Uses nucleus sampling to generate high-quality responses.min_length=20
: Ensures meaningful replies.
- If the chatbot generates a very short or meaningless response, it provides a fallback message:
I couldn't think of anything interesting to say! Let's try again.
git clone https://github.com/thekartikeyamishra/small-language-model-chatbot.git
cd small-language-model-chatbot
Make sure to install the necessary Python libraries:
pip install transformers ipywidgets
-
Open Google Colab:
- Copy and paste the code into a new Google Colab notebook.
-
Run the Script:
- Execute the code cells to initialize the chatbot.
-
Interact with the Chatbot:
- Enter your message in the text input field.
- Click the Send button to receive the chatbot's reply.
-
View Visualizations:
- The chatbot displays a bar chart showing the word count of user inputs after each interaction.
A bar chart shows the number of words in the user's message for each interaction.
-
Sentiment Analysis:
- Add a sentiment analysis layer to analyze the tone of user messages.
-
Multilingual Support:
- Integrate pre-trained multilingual models for global audiences.
-
Save Conversations:
- Allow users to save chat history for later review.
-
Fine-Tuned Models:
- Use domain-specific datasets to fine-tune the chatbot for specific applications (e.g., customer support, education).
-
Voice Input/Output:
- Add support for voice-based interactions using libraries like
SpeechRecognition
andpyttsx3
.
- Add support for voice-based interactions using libraries like
-
Learning Tool:
- Explore the capabilities of small language models.
- Understand text generation and visualization in NLP.
-
Prototyping:
- Use this chatbot as a starting point for building advanced conversational AI.
-
Fun and Engagement:
- Interact with a lightweight chatbot for entertainment or quick inspiration.
Contributions are welcome! To contribute:
- Fork the repository.
- Create a new branch:
git checkout -b feature-name
- Commit your changes:
git commit -m "Add new feature"
- Push to the branch:
git push origin feature-name
- Open a pull request.
If you enjoy using this project, please:
- 🌟 Star this repository on GitHub.
- 🗣️ Share it with your network.
- 💬 Submit feedback or feature requests.
- Hugging Face Transformers: For providing pre-trained models and an intuitive API.
- Matplotlib: For data visualization.
- IPyWidgets: For building an interactive interface.
Let me know if you'd like further refinements or additional sections! 🚀