import time import torch import gradio as gr from transformers import AutoTokenizer, AutoModelForCausalLM model_id = "nicholasKluge/Aira-Instruct-124" token = "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" device = "cuda" if torch.cuda.is_available() else "cpu" if device == "cuda": model = AutoModelForCausalLM.from_pretrained(model_id, use_auth_token=token, load_in_8bit=True) else: model = AutoModelForCausalLM.from_pretrained(model_id, use_auth_token=token) tokenizer = AutoTokenizer.from_pretrained(model_id, use_auth_token=token) model.to(device) intro = """ ## What is `Aira`? [`Aira`](https://github.com/Nkluge-correa/Aira-EXPERT) is a `chatbot` designed to simulate the way a human (expert) would behave during a round of questions and answers (Q&A). `Aira` has many iterations, from a closed-domain chatbot based on pre-defined rules to an open-domain chatbot achieved via fine-tuning pre-trained large language models. Aira has an area of expertise that comprises topics related to AI Ethics and AI Safety research. We developed our open-domain conversational chatbots via conditional text generation/instruction fine-tuning. This approach has a lot of limitations. Even though we can make a chatbot that can answer questions about anything, forcing the model to produce good-quality responses is hard. And by good, we mean **factual** and **nontoxic** text. This leads us to two of the most common problems of generative models used in conversational applications: ๐คฅ Generative models can perpetuate the generation of pseudo-informative content, that is, false information that may appear truthful. ๐คฌ In certain types of tasks, generative models can produce harmful and discriminatory content inspired by historical stereotypes against sensitive attributes (for example, gender, race, and religion). `Aira` is intended only for academic research. For more information, visit our [HuggingFace models](https://huggingface.co/nicholasKluge) to see how we developed `Aira`. """ disclaimer = """ **Disclaimer:** You should use this demo for research purposes only. Moderators do not censor the model output, and the authors do not endorse the opinions generated by this model. If you would like to complain about any message produced by `Aira`, please contact [nicholas@airespucrs.org](mailto:nicholas@airespucrs.org). """ with gr.Blocks(theme='freddyaboulton/dracula_revamped') as demo: gr.Markdown("""