A newer version of the Streamlit SDK is available: 1.58.0
π PaperChat - Complete Deployment Guide
π Quick Checklist
- All files created
- HF account ready
- HF Token obtained
- Space created
- Files uploaded
- App running
π Project Structure
Create a folder called paperchat with these files:
paperchat/
βββ app.py # Main Streamlit application
βββ requirements.txt # Python dependencies
βββ README.md # Hugging Face Spaces config
βββ .env # Local environment variables (don't upload this!)
π§ Step 1: Local Setup & Testing (Optional but Recommended)
1.1 Create virtual environment
# Create project folder
mkdir paperchat
cd paperchat
# Create virtual environment
python -m venv venv
# Activate it
# On Windows:
venv\Scripts\activate
# On Mac/Linux:
source venv/bin/activate
1.2 Install dependencies
pip install -r requirements.txt
1.3 Set up HF Token
Create a .env file:
# .env file content
HF_TOKEN=hf_your_token_here
Get your token: https://huggingface.co/settings/tokens
1.4 Test locally
streamlit run app.py
Open http://localhost:8501 and test with a sample PDF!
π Step 2: Deploy to Hugging Face Spaces
2.1 Create a new Space
- Go to https://huggingface.co/spaces
- Click "Create new Space"
- Fill in:
- Space name:
paperchat(or your preferred name) - License: MIT
- Select SDK: Streamlit
- Hardware: CPU (free tier is fine!)
- Visibility: Public
- Space name:
2.2 Upload files
Option A: Via Web Interface
- Click "Files" tab in your Space
- Click "Add file" β "Upload files"
- Upload:
app.py,requirements.txt,README.md - Commit changes
Option B: Via Git (Recommended)
# Clone your space
git clone https://huggingface.co/spaces/YOUR_USERNAME/paperchat
cd paperchat
# Copy your files
cp /path/to/app.py .
cp /path/to/requirements.txt .
cp /path/to/README.md .
# Commit and push
git add .
git commit -m "Initial commit"
git push
2.3 Add HF Token to Secrets
- Go to your Space settings
- Click "Settings" β "Repository secrets"
- Click "Add a secret"
- Name:
HF_TOKEN - Value: Your Hugging Face token
- Save
2.4 Wait for build
The Space will automatically build and deploy. Watch the logs:
- β³ Building... (1-2 minutes)
- β Running!
β Step 3: Verify Deployment
- Visit your Space URL:
https://huggingface.co/spaces/YOUR_USERNAME/paperchat - Upload a test PDF (try a short research paper)
- Ask a question
- Verify you get an answer
π Common Issues & Fixes
Issue 1: "Module not found" error
Fix: Check requirements.txt has all dependencies
smolagents
streamlit
pypdf
langchain
langchain-community
sentence-transformers
python-dotenv
rank_bm25
Issue 2: "HF_TOKEN not found"
Fix: Add token to Space secrets (Step 2.3)
Issue 3: App crashes on PDF upload
Fix: Usually a memory issue. Try:
- Smaller PDF (< 10 MB)
- Reduce
chunk_sizein app.py to 300
Issue 4: Slow response times
Fix: This is normal for free tier. Upgrade to better hardware in Space settings if needed.
π¨ Step 4: Customization (Optional)
Change the model
In app.py, modify the agent creation:
agent = CodeAgent(
tools=[retriever_tool],
model=InferenceClientModel(model_id="meta-llama/Llama-3.3-70B-Instruct"),
max_steps=4,
verbosity_level=0,
)
Change colors/theme
Update README.md header:
colorFrom: red
colorTo: yellow
Add example papers
Pre-load famous papers in the sidebar for quick demos.
π Step 5: Monitor & Improve
Track usage
- Check Space analytics in HF dashboard
- Monitor error logs
Collect feedback
Add a feedback button:
if st.button("π Helpful"):
st.success("Thanks for your feedback!")
Add features
Ideas:
- Multiple paper comparison
- Export chat as PDF
- Highlight relevant sections
- Paper summarization mode
π Step 6: Add to Resume/Portfolio
Resume bullet point
β’ Built PaperChat, an AI-powered research paper Q&A tool using Agentic RAG,
deployed on Hugging Face Spaces with 100+ users
β’ Implemented retrieval-augmented generation with BM25 + LLM agents for
accurate question answering with source citations
Portfolio description
PaperChat - Research Paper Q&A Assistant
An intelligent document assistant that helps researchers quickly understand
and extract information from academic papers. Built with smolagents and
deployed on Hugging Face Spaces.
Tech: Python, Streamlit, LangChain, RAG, BM25, LLM Agents
Live Demo: [your-space-url]
π You're Done!
Your app is now:
- β Live on the internet
- β Accessible to anyone
- β Resume-ready
- β Portfolio-worthy
Share your Space URL with friends, on LinkedIn, or in your resume!
π Need Help?
- Hugging Face Docs: https://huggingface.co/docs/hub/spaces
- Streamlit Docs: https://docs.streamlit.io
- smolagents Docs: https://github.com/huggingface/smolagents
Pro Tip: Record a 30-second demo video showing:
- Upload a paper
- Ask a question
- Get an answer
Use this video in your portfolio or LinkedIn post! π¬