A newer version of the Gradio SDK is available:
5.27.0
metadata
license: mit
title: Iver
sdk: gradio
emoji: π
colorFrom: blue
colorTo: red
short_description: Verifiseringsspesialisten Iver
sdk_version: 5.23.3
Iver
A Retrieval-Augmented Generation (RAG) based chatbot with excellent Norwegian language support, built using Hugging Face's Inference API.
Features
- Norwegian Language Support: Leverages state-of-the-art Norwegian language models like NorMistral, Viking, and NorskGPT
- Document Processing: Upload and process documents in various formats (PDF, TXT, HTML)
- RAG Implementation: Retrieves relevant context from documents to generate accurate responses
- Embeddable Interface: Easily embed the chatbot in any website using iframe or JavaScript widget
- Lightweight Architecture: Uses Hugging Face's Inference API instead of running models locally
Architecture
This chatbot uses a lightweight architecture that leverages Hugging Face's hosted models:
- Document Processing: Documents are processed locally, extracting text and splitting into chunks
- Embedding Generation: Document chunks are embedded using Hugging Face's Inference API
- Retrieval: When a query is received, the most relevant document chunks are retrieved
- Response Generation: The LLM generates a response based on the retrieved context
Getting Started
Prerequisites
- Python 3.10+
- A Hugging Face account (for API access)
Installation
- Clone the repository:
git clone https://huggingface.co/spaces/username/norwegian-rag-chatbot
cd norwegian-rag-chatbot
- Install dependencies:
pip install -r requirements-ultra-light.txt
- Set up your Hugging Face API key:
export HF_API_KEY="your_api_key_here"
Running the Chatbot
python app.py
The chatbot will be available at http://localhost:7860
Usage
Chat Interface
The main chat interface allows you to:
- Ask questions in Norwegian
- Receive responses based on your uploaded documents
- Adjust temperature and other settings
Document Upload
You can upload documents to provide context for the chatbot:
- Supported formats: PDF, TXT, HTML
- Documents are automatically processed and indexed
- The chatbot will use these documents to provide more accurate responses
Embedding
You can embed the chatbot in your website using:
- iFrame embedding
- JavaScript widget
- Direct link
Deployment
The chatbot is designed to be deployed to Hugging Face Spaces:
- Create a new Space on Hugging Face
- Upload the code to the Space
- Set the HF_API_KEY secret in the Space settings
- The Space will automatically build and deploy the chatbot
Models
The chatbot can use various Norwegian language models:
- NorMistral-7b-scratch: A large Norwegian language model pretrained from scratch
- Viking 7B: A multilingual model for Nordic languages
- NorskGPT: A Norwegian language model based on Mistral or LLAMA2
For embeddings, it uses:
- NbAiLab/nb-sbert-base: A Norwegian sentence embedding model
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgements
- Hugging Face for hosting the models and providing the Inference API
- Gradio for the web interface framework
- The creators of the Norwegian language models used in this project