#The goal is to deploy the Falcon 3B model in a chatbot using Gradio import gradio from transformers import AutoModelForCausalLM, AutoTokenizer model = AutoModelForCausalLM.from_pretrained("tiiuae/Falcon3-3B-Instruct") tokenizer = AutoTokenizer.from_pretrained("tiiuae/Falcon3-3B-Instruct") history = "" def chat(user_input): global history history += f"User: {user_input}\n" inputs = tokenizer(history, return_tensors="pt", max_length=1024) generated_ids = model.generate(**inputs, max_length=1024) output = tokenizer.decode(generated_ids[0], skip_special_tokens=True) bot_response = output.split("Bot:")[-1].strip() history += f"Bot: {bot_response}\n" return bot_response gradio.Interface(fn=chat, inputs=gradio.Textbox(label="Your Message", placeholder="Ask me anything...", lines=1), outputs=gradio.Textbox(label="Response", interactive=False, placeholder="I will respond here..."), title="Falcon 3B Chatbot", description="An AI model powered by Falcon 3B. Talk to me about anything!", article="Note: This is a simple chatbot built with Gradio. Type below and let the model respond.", theme="huggingface").launch(share=True)