Spaces:
Paused
Paused
Update app.py
Browse files122343 unmodified lines891011121314131415161716171920212218192047 unmodified lines6869707671727374164 unmodified lines239240241247242243244245import 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 base64import streamlit as st
# Set environment variable for Hugging Face tokenos.environ["HUGGINGFACE_TOKEN"] = "your_token_here"# Use a publicly available model that doesn't require authenticationrag_retriever = pipeline("retrieval-question-answering", model="distilbert-base-nq")
# Load .env file to set additional environment variablesload_dotenv()st.write("Pipeline created successfully")
# 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# 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 lines input_ids = input_ids[:, :max_input_length]
outputs = model.generate( input_ids, max_new_tokens=50, num_return_sequences=1, do_sample=True, 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