--- title: Chat With Pdf emoji: 💬 colorFrom: yellow colorTo: purple sdk: gradio sdk_version: 4.36.1 app_file: app.py pinned: false license: apache-2.0 short_description: 'AI-powered system to interact with Arabic-language PDF doc ' --- # Arabic PDF Chat Assistant **Arabic PDF Chat Assistant** is an advanced, fine-tuned AI-powered system designed to interact with Arabic-language PDF documents. The system enables users to upload PDF files and engage in natural language conversations, asking questions in Arabic. The assistant provides precise and relevant answers based on the content of the uploaded document, making it a powerful tool for querying Arabic texts in a streamlined and user-friendly way. ## Table of Contents - [Overview](#overview) - [Features](#features) - [Model](#model) - [Installation](#installation) - [Usage](#usage) - [Fine-Tuning](#fine-tuning) - [Gradio Interface](#gradio-interface) - [License](#license) ## Overview The **Arabic PDF Chat Assistant** is specialized for analyzing Arabic-language PDF documents. The assistant is fine-tuned to handle a variety of complex queries, ensuring that responses reflect the content accurately, with a focus on professionalism and clarity. The system employs advanced natural language processing techniques to extract and present key information from PDFs. It is particularly useful for professionals, researchers, students, and organizations dealing with Arabic-language documents who need fast and precise answers. ## Features - **Arabic Language Support**: Fully supports queries and responses in Modern Standard Arabic (الفصحى). - **PDF Querying**: Upload any Arabic PDF document and ask natural language questions. The assistant will analyze and respond based on the content. - **Fine-tuned Model**: The model is fine-tuned on Arabic question-answering datasets to provide high accuracy and relevance in responses. - **Multimodal Outputs**: In addition to text-based responses, the assistant can generate audio responses in Arabic using text-to-speech (TTS) technology. - **Interactive Gradio Interface**: Intuitive and easy-to-use interface, allowing users to chat, upload files, and listen to audio responses directly from their browser. - **Customizable**: The system is built to be flexible, with room for expansion and improvements based on specific use cases. ## Model The assistant uses a fine-tuned transformer-based model specialized in Arabic question-answering tasks. The model has been trained to: - Understand Arabic syntax and semantics. - Analyze and extract relevant information from PDF documents. - Provide clear and concise answers in Arabic while avoiding informal or colloquial language. ### Model Details - **Base Model**: Transformer-based architecture (e.g., BERT, GPT, etc.) - **Fine-Tuning**: The model has been fine-tuned using Arabic-language datasets focusing on question-answering, document comprehension, and professional tone communication. - **Training Dataset**: A mix of publicly available and custom-created Arabic datasets for Q&A tasks. ## Installation ### Clone the repository ```bash git clone https://huggingface.co/spaces/MohammedNasser/Arabic-PDF-Chat cd Arabic-PDF-Chat ``` ### Install dependencies Make sure to have Python installed, and then run: ```bash pip install -r requirements.txt ``` ### API Keys (Optional) If you're using any external services (e.g., Hugging Face Transformers, or any custom language model API), ensure you have the necessary API keys. ## Usage 1. **Launch the application:** Run the following command to launch the app in your browser: ```bash python app.py ``` 2. **Upload PDF:** Upload your Arabic-language PDF document through the Gradio interface. 3. **Ask Questions:** After uploading the document, enter your question in Arabic. The chatbot will analyze the content of the PDF and return an answer. 4. **Listen to Audio Responses (Optional):** If enabled, you can listen to the assistant's response via audio generated using Text-to-Speech (TTS). ## Fine-Tuning The model is fine-tuned on a set of Arabic-language question-answering datasets. To fine-tune or modify the current model, follow these steps: ### Prerequisites - Ensure you have access to a powerful GPU (e.g., NVIDIA A100) for training. - Use a dataset that consists of Arabic-language documents paired with question-answer pairs. ``` ## Gradio Interface The user interface is built using Gradio, making it intuitive and accessible via the web. ### Main Interface Components: - **PDF Upload**: A file uploader for Arabic PDFs. - **Chatbox**: A two-part chat component where users enter questions, and the assistant responds based on the document’s content. - **Audio Response**: A feature that plays the response using TTS in Arabic. - **Clear Chat**: A button to reset the chat history. Here’s a simplified look at the Gradio UI: ```python import gradio as gr def chat(user_input): # Chat function logic here pass with gr.Blocks() as demo: with gr.Row(): gr.Image("logo.png") # Display company logo with gr.Row(): pdf_input = gr.File(label="اختر ملف PDF") with gr.Row(): chat_input = gr.Textbox(placeholder="أدخل سؤالك هنا ..") with gr.Row(): submit_button_chat = gr.Button("إرسال") submit_button_chat.click(chat, inputs=chat_input, outputs=chatbot) demo.launch() ``` ## License This project is licensed under the MIT License. See the `LICENSE` file for more details. ---