Spaces:
Sleeping
Sleeping
Delete readme.md
Browse files
readme.md
DELETED
|
@@ -1,176 +0,0 @@
|
|
| 1 |
-
# π¦
Falcon-7B Instruct Chatbot
|
| 2 |
-
|
| 3 |
-
This project is a simple conversational chatbot built using the **[Falcon-7B-Instruct](https://huggingface.co/tiiuae/falcon-7b-instruct)** model from Hugging Face. It uses **Transformers**, **Gradio**, and **PyTorch** to create a web interface for interacting with the model in real-time.
|
| 4 |
-
|
| 5 |
-
---
|
| 6 |
-
|
| 7 |
-
## π Features
|
| 8 |
-
|
| 9 |
-
- Open-access LLM: No API keys or approvals needed
|
| 10 |
-
- Real-time interaction using Gradio
|
| 11 |
-
- Clean UI with chat history
|
| 12 |
-
- Easy to run locally or on cloud platforms like Google Colab or Hugging Face Spaces
|
| 13 |
-
|
| 14 |
-
---
|
| 15 |
-
|
| 16 |
-
## π οΈ Installation
|
| 17 |
-
|
| 18 |
-
Make sure Python 3.8+ is installed.
|
| 19 |
-
|
| 20 |
-
```bash
|
| 21 |
-
pip install transformers torch gradio
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
# π¦
Falcon-7B Instruct Chatbot using Hugging Face & Gradio
|
| 26 |
-
|
| 27 |
-
This project implements an AI-powered chatbot using the open-access **Falcon-7B-Instruct** model. Built with π€ Hugging Face Transformers and π Gradio, this chatbot can understand and respond to a wide variety of instructions and questions.
|
| 28 |
-
|
| 29 |
-
---
|
| 30 |
-
|
| 31 |
-
## π Table of Contents
|
| 32 |
-
|
| 33 |
-
- [Features](#-features)
|
| 34 |
-
- [Demo](#-demo)
|
| 35 |
-
- [Model Details](#-model-details)
|
| 36 |
-
- [Installation](#-installation)
|
| 37 |
-
- [Usage](#-usage)
|
| 38 |
-
- [File Structure](#-file-structure)
|
| 39 |
-
- [Requirements](#-requirements)
|
| 40 |
-
- [Deployment](#-deployment)
|
| 41 |
-
- [Limitations](#-limitations)
|
| 42 |
-
- [License](#-license)
|
| 43 |
-
- [Author](#-author)
|
| 44 |
-
|
| 45 |
-
---
|
| 46 |
-
|
| 47 |
-
## π Features
|
| 48 |
-
|
| 49 |
-
β
Instruction-following chatbot
|
| 50 |
-
β
Built using Falcon-7B-Instruct from Hugging Face
|
| 51 |
-
β
Runs locally with Gradio interface
|
| 52 |
-
β
Clean and minimal chat UI
|
| 53 |
-
β
No API key or login required
|
| 54 |
-
|
| 55 |
-
---
|
| 56 |
-
|
| 57 |
-
## π₯ Demo
|
| 58 |
-
|
| 59 |
-

|
| 60 |
-
*You can enter any question or instruction in the textbox and the model will reply.*
|
| 61 |
-
|
| 62 |
-
---
|
| 63 |
-
|
| 64 |
-
## π§ Model Details
|
| 65 |
-
|
| 66 |
-
- **Model**: [`tiiuae/falcon-7b-instruct`](https://huggingface.co/tiiuae/falcon-7b-instruct)
|
| 67 |
-
- **Type**: Transformer-based language model
|
| 68 |
-
- **Size**: 7 Billion parameters
|
| 69 |
-
- **Tuned for**: Instruction-following and helpful conversational behavior
|
| 70 |
-
- **License**: Apache 2.0
|
| 71 |
-
|
| 72 |
-
> β οΈ Requires GPU for smooth performance
|
| 73 |
-
|
| 74 |
-
---
|
| 75 |
-
|
| 76 |
-
## π» Installation
|
| 77 |
-
|
| 78 |
-
### 1. Clone the repository
|
| 79 |
-
|
| 80 |
-
```bash
|
| 81 |
-
git clone https://github.com/yourusername/falcon-chatbot.git
|
| 82 |
-
cd falcon-chatbot
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
Or manually:
|
| 86 |
-
|
| 87 |
-
bash
|
| 88 |
-
Copy
|
| 89 |
-
Edit
|
| 90 |
-
pip install transformers torch gradio
|
| 91 |
-
βΆοΈ Usage
|
| 92 |
-
1. Run the chatbot
|
| 93 |
-
bash
|
| 94 |
-
Copy
|
| 95 |
-
Edit
|
| 96 |
-
python app.py
|
| 97 |
-
2. Open in browser
|
| 98 |
-
Visit http://127.0.0.1:7860 to chat.
|
| 99 |
-
|
| 100 |
-
π File Structure
|
| 101 |
-
bash
|
| 102 |
-
Copy
|
| 103 |
-
Edit
|
| 104 |
-
falcon-chatbot/
|
| 105 |
-
βββ app.py # Main app with Gradio interface
|
| 106 |
-
βββ README.md # Project documentation
|
| 107 |
-
βββ requirements.txt # Python dependencies
|
| 108 |
-
π Code Overview (app.py)
|
| 109 |
-
python
|
| 110 |
-
Copy
|
| 111 |
-
Edit
|
| 112 |
-
import gradio as gr
|
| 113 |
-
from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
|
| 114 |
-
|
| 115 |
-
model_name = "tiiuae/falcon-7b-instruct"
|
| 116 |
-
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 117 |
-
model = AutoModelForCausalLM.from_pretrained(model_name, device_map="auto", trust_remote_code=True)
|
| 118 |
-
|
| 119 |
-
chat_pipeline = pipeline("text-generation", model=model, tokenizer=tokenizer, max_new_tokens=200)
|
| 120 |
-
|
| 121 |
-
def chat(user_input, history=[]):
|
| 122 |
-
prompt = f"User: {user_input}\nAssistant:"
|
| 123 |
-
result = chat_pipeline(prompt)[0]["generated_text"]
|
| 124 |
-
response = result.split("Assistant:")[-1].strip()
|
| 125 |
-
history.append((user_input, response))
|
| 126 |
-
return history, history
|
| 127 |
-
|
| 128 |
-
interface = gr.ChatInterface(
|
| 129 |
-
fn=chat,
|
| 130 |
-
chatbot=gr.Chatbot(),
|
| 131 |
-
textbox=gr.Textbox(placeholder="Ask a question..."),
|
| 132 |
-
title="π£οΈ Falcon 7B Chatbot",
|
| 133 |
-
description="Chat with an open-source LLM using Falcon-7B-Instruct model."
|
| 134 |
-
)
|
| 135 |
-
|
| 136 |
-
interface.launch()
|
| 137 |
-
π¦ Requirements
|
| 138 |
-
text
|
| 139 |
-
Copy
|
| 140 |
-
Edit
|
| 141 |
-
transformers
|
| 142 |
-
torch
|
| 143 |
-
gradio
|
| 144 |
-
Save as requirements.txt.
|
| 145 |
-
|
| 146 |
-
π Deployment Options
|
| 147 |
-
β
Local
|
| 148 |
-
Run with python app.py
|
| 149 |
-
|
| 150 |
-
β
Hugging Face Spaces
|
| 151 |
-
Upload app.py, requirements.txt, and README.md
|
| 152 |
-
|
| 153 |
-
Choose Gradio SDK
|
| 154 |
-
|
| 155 |
-
β
Google Colab
|
| 156 |
-
Add the same code into a Colab notebook and run with GPU runtime.
|
| 157 |
-
|
| 158 |
-
β οΈ Limitations
|
| 159 |
-
Works best on machines with GPU (>=16GB VRAM)
|
| 160 |
-
|
| 161 |
-
May be slow on CPU
|
| 162 |
-
|
| 163 |
-
Limited to English conversation and general instructions
|
| 164 |
-
|
| 165 |
-
Not fine-tuned for safety or moderation
|
| 166 |
-
|
| 167 |
-
π License
|
| 168 |
-
This project is licensed under the Apache 2.0 License.
|
| 169 |
-
The Falcon-7B-Instruct model also follows the Apache-2.0 license.
|
| 170 |
-
|
| 171 |
-
π©βπ» Author
|
| 172 |
-
Dr. Shailja Pandit
|
| 173 |
-
AI Consultant & Trainer
|
| 174 |
-
π§ [[email protected]]
|
| 175 |
-
π LinkedIn | Website
|
| 176 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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