How braaaeeedyn/bearlm works
BearLM is a cited, grounded Q&A assistant over course materials, with persistent project conversations and ad-hoc PDF chat as additional workflows. Course content is extracted, split, embedded, and stored; questions enter through the web/API, then retrieval and answer generation produce citations or a refusal. Projects add their own PDF collections and can fall back to the course corpus; ad-hoc uploads remain document-only. Analytics records query activity. The README and excerpts establish the main flows; some API, analytics, and project details are unsampled, so uncertain internal links are omitted.
Main entry points: rag.py Answer orchestration · api.py HTTP API · projects.py Project management · local_store.py Vector collections
Components 20
Corpus ingestion
- Course materials
- Document extraction
src/bearlm/doc_processor.py - Text splitting
src/bearlm/text_splitter.py - Corpus ingestion
src/bearlm/local_store.py - Vector collections
src/bearlm/local_store.py
Grounded answering
- Answer orchestration
src/bearlm/rag.py - Hybrid retrieval
src/bearlm/search.py - Confidence reranking
src/bearlm/rerank.py - Answer model
src/bearlm/rag.py - Backend configuration
src/bearlm/config.py
Personal documents
- Project management
src/bearlm/projects.py - Project PDF ingestion
src/bearlm/local_store.py - Ad-hoc PDF chat
src/bearlm/api.py
App and analytics
- Web interface
web/app.js - Projects interface
web/projects-app.js - HTTP API
src/bearlm/api.py - Usage analytics
src/bearlm/analytics.py
Other components
- Learner
- Ollama models
- MongoDB Atlas
Connections 27
- Learner → Web interface: asks through
README.md - Learner → Projects interface: manages documents
README.md - Web interface → HTTP API: calls
README.md - Projects interface → HTTP API: calls
README.md - HTTP API → Answer orchestration: answers via
src/bearlm/api.py - HTTP API → Project management: routes project actions
src/bearlm/api.py - HTTP API → Ad-hoc PDF chat: routes upload chat
src/bearlm/api.py - HTTP API → Usage analytics: records queries
src/bearlm/api.py - HTTP API → Web interface: serves frontend
README.md - Course materials → Document extraction: provides content
README.md - Document extraction → Corpus ingestion: extracts pages
src/bearlm/local_store.py - Corpus ingestion → Text splitting: splits text
src/bearlm/local_store.py - Corpus ingestion → Vector collections: embeds and stores
README.md - Answer orchestration → Hybrid retrieval: gets candidates
src/bearlm/rag.py - Answer orchestration → Confidence reranking: reranks candidates
src/bearlm/rag.py - Answer orchestration → Answer model: generates answer
src/bearlm/rag.py - Hybrid retrieval → Vector collections: searches vectors
src/bearlm/search.py - Confidence reranking → Answer model: scores passages
README.md - Answer orchestration → Ollama models: uses local models
README.md - Answer orchestration → MongoDB Atlas: uses OpenAI backend
README.md - Backend configuration → Answer orchestration: selects backend
src/bearlm/rag.py - Project management → Project PDF ingestion: ingests project PDFs
src/bearlm/projects.py - Project PDF ingestion → Vector collections: stores project chunks
src/bearlm/local_store.py - Project management → Answer orchestration: grounds project answers
src/bearlm/projects.py - Ad-hoc PDF chat → Project management: creates upload collection
src/bearlm/api.py - Ad-hoc PDF chat → Answer orchestration: answers without fallback
src/bearlm/api.py - Usage analytics → Vector collections: reads corpus stats
src/bearlm/analytics.py