Spaces:
Paused
Paused
Update app.py
Browse files123453 unmodified lines91011121314151617181920212223242547 unmodified lines73747576777879164 unmodified lines244245246247248249250import osimport streamlit as stimport subprocessfrom transformers import pipeline, AutoModelForCausalLM, AutoTokenizer, AutoModel, RagRetriever, AutoModelForSeq2SeqLMimport black3 unmodified linesimport torchfrom huggingface_hub import hf_hub_url, cached_download, HfApi, InferenceClientimport base64# Set environment variable for Hugging Face tokenos.environ["HUGGINGFACE_TOKEN"] = "your_token_here"# Load .env file to set additional environment variablesload_dotenv()# Use the HUGGINGFACE_TOKEN in your codeHUGGINGFACE_TOKEN = os.getenv("HUGGINGFACE_TOKEN")print(HUGGINGFACE_TOKEN)r# Add the new HTML code belowcustom_html = '''<div style='position:fixed;bottom:0;left:0;width:100%;'>47 unmodified lines]# Load pre-trained RAG retrieverrag_retriever = RagRetriever.from_pretrained("facebook/rag-token-base") # Use a Hugging Face RAG model# Load pre-trained chat modelchat_model = AutoModelForSeq2SeqLM.from_pretrained("microsoft/DialoGPT-medium") # Use a Hugging Face chat model164 unmodified linesinput_ids = input_ids[:, :max_input_length]outputs = model.generate(input_ids, max_new_tokens=50, num_return_sequences=1, do_sample=True,pad_token_id=tokenizer.eos_token_id # Set pad_token_id to eos_token_id)response = tokenizer.decode(outputs[0], skip_special_tokens=True)12343 unmodified lines89101112131415161718192047 unmodified lines68697071727374164 unmodified lines239240241242243244245import osimport subprocessfrom transformers import pipeline, AutoModelForCausalLM, AutoTokenizer, AutoModel, RagRetriever, AutoModelForSeq2SeqLMimport black3 unmodified linesimport torchfrom huggingface_hub import hf_hub_url, cached_download, HfApi, InferenceClientimport base64import streamlit as st# Use a publicly available model that doesn't require authenticationrag_retriever = pipeline("retrieval-question-answering", model="distilbert-base-nq")st.write("Pipeline created successfully")# Add the new HTML code belowcustom_html = '''<div style='position:fixed;bottom:0;left:0;width:100%;'>47 unmodified lines]# Load pre-trained RAG retriever# rag_retriever = RagRetriever.from_pretrained("facebook/rag-token-base") # Use a Hugging Face RAG model# Load pre-trained chat modelchat_model = AutoModelForSeq2SeqLM.from_pretrained("microsoft/DialoGPT-medium") # Use a Hugging Face chat model164 unmodified linesinput_ids = input_ids[:, :max_input_length]outputs = model.generate(input_ids, max_new_tokens=1000, num_return_sequences=1, do_sample=True,pad_token_id=tokenizer.eos_token_id # Set pad_token_id to eos_token_id)response = tokenizer.decode(outputs[0], skip_special_tokens=True)
app.py+6-11